Skip to content

Commit 0889802

Browse files
committed
chore: add e2e test for upsell
1 parent e2f16ac commit 0889802

File tree

2 files changed

+134
-1
lines changed

2 files changed

+134
-1
lines changed

classes/Visualizer/Render/Layout.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,6 @@ class="dashicons dashicons-lock"></span></h2>
925925

926926
<input type="button" id="filter-chart-button" class="button button-secondary show-chart-toggle" value="<?php echo $bttn_label; ?>" data-current="chart" data-t-filter="<?php _e( 'Show Chart', 'visualizer' ); ?>" data-t-chart="<?php echo $bttn_label; ?>">
927927
<input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
928-
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
929928
</form>
930929
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
931930
</div>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
describe('Test Free - upsells', function() {
2+
before(function () {
3+
4+
// login to WP
5+
cy.visit('wp-login.php');
6+
cy.get('#user_login').clear().type(Cypress.env('login'));
7+
cy.get('#user_pass').clear().type(Cypress.env('pass'));
8+
cy.get('#wp-submit').click();
9+
});
10+
11+
it('Check upsell links', function() {
12+
cy.visit(Cypress.env('urls').library );
13+
cy.get('.visualizer-chart > .visualizer-chart-canvas > .visualizer-notfound > h2 > .add-new-h2').click()
14+
cy.wait( Cypress.env('wait') );
15+
16+
cy.get('iframe')
17+
.then(function ($iframe) {
18+
const $body = $iframe.contents().find('body');
19+
cy.wrap($body).find('#toolbar input[type="submit"]').click();
20+
cy.wait( Cypress.env('wait') );
21+
});
22+
23+
cy.get('iframe')
24+
.then(function ($iframe) {
25+
const $body = $iframe.contents().find('body');
26+
// Check Import form other chart upsell.
27+
const other_import = cy.wrap($body).find('.viz-import-from-other');
28+
other_import.click();
29+
other_import.should('have.class', 'only-pro-feature');
30+
const other_import_upsell_url = cy.wrap($body).find('.viz-import-from-other .viz-group-content .only-pro-content .only-pro-container .only-pro-inner a').should('have.attr', 'href').then((href) => {
31+
const other_import_search_params = new URLSearchParams(href);
32+
expect(other_import_search_params.get('utm_campaign')).to.equal('import-chart');
33+
});
34+
});
35+
36+
cy.get('iframe')
37+
.then(function ($iframe) {
38+
const $body = $iframe.contents().find('body');
39+
// Check import form WordPress upsell.
40+
const wp_import = cy.wrap($body).find('.visualizer_source_query_wp');
41+
wp_import.click();
42+
wp_import.should('have.class', 'only-pro-feature');
43+
const wp_import_upsell_url = cy.wrap($body).find('.visualizer_source_query_wp .viz-group-content .only-pro-content .only-pro-container .only-pro-inner a').should('have.attr', 'href').then((href) => {
44+
const wp_import_search_params = new URLSearchParams(href);
45+
expect(wp_import_search_params.get('utm_campaign')).to.equal('import-wp');
46+
});
47+
});
48+
49+
cy.get('iframe')
50+
.then(function ($iframe) {
51+
const $body = $iframe.contents().find('body');
52+
// Check import form database upsell.
53+
const db_import = cy.wrap($body).find('.visualizer_source_query');
54+
db_import.click();
55+
db_import.should('have.class', 'only-pro-feature');
56+
const db_import_upsell_url = cy.wrap($body).find('.visualizer_source_query .viz-group-content .only-pro-content .only-pro-container .only-pro-inner a').should('have.attr', 'href').then((href) => {
57+
const db_import_search_params = new URLSearchParams(href);
58+
expect(db_import_search_params.get('utm_campaign')).to.equal('db-query');
59+
});
60+
});
61+
62+
cy.get('iframe')
63+
.then(function ($iframe) {
64+
const $body = $iframe.contents().find('body');
65+
// Check import form manual data upsell.
66+
const manual_import = cy.wrap($body).find('.visualizer_source_manual');
67+
manual_import.click();
68+
manual_import.should('have.class', 'only-pro-feature');
69+
const manual_import_upsell_url = cy.wrap($body).find('.visualizer_source_manual .viz-group-content .only-pro-content .only-pro-container .only-pro-inner a').should('have.attr', 'href').then((href) => {
70+
const manual_import_search_params = new URLSearchParams(href);
71+
expect(manual_import_search_params.get('utm_campaign')).to.equal('manual-data');
72+
});
73+
});
74+
});
75+
76+
it('Check Settings upsell links', function() {
77+
cy.visit(Cypress.env('urls').library );
78+
cy.get('.visualizer-chart > .visualizer-chart-canvas > .visualizer-notfound > h2 > .add-new-h2').click()
79+
cy.wait( Cypress.env('wait') );
80+
81+
cy.get('iframe')
82+
.then(function ($iframe) {
83+
const $body = $iframe.contents().find('body');
84+
cy.wrap($body).find('#toolbar input[type="submit"]').click();
85+
cy.wait( Cypress.env('wait') );
86+
});
87+
88+
cy.get('iframe')
89+
.then(function ($iframe) {
90+
const $body = $iframe.contents().find('body');
91+
cy.wrap($body).find('#viz-tab-advanced').click();
92+
cy.wait( Cypress.env('wait') );
93+
});
94+
95+
cy.get('iframe')
96+
.then(function ($iframe) {
97+
const $body = $iframe.contents().find('body');
98+
// Check setting chart data filter configuration upsell.
99+
const data_control = cy.wrap($body).find('#vz-data-controls');
100+
data_control.click();
101+
data_control.should('have.class', 'only-pro-feature');
102+
const data_control_upsell_url = cy.wrap($body).find('#vz-data-controls .viz-group-content .only-pro-content .only-pro-container .only-pro-inner a').should('have.attr', 'href').then((href) => {
103+
const data_control_search_params = new URLSearchParams(href);
104+
expect(data_control_search_params.get('utm_campaign')).to.equal('data-filter-configuration');
105+
});
106+
});
107+
108+
cy.get('iframe')
109+
.then(function ($iframe) {
110+
const $body = $iframe.contents().find('body');
111+
// Check setting frontend actions upsell.
112+
const frontend_actions = cy.wrap($body).find('#vz-frontend-actions');
113+
frontend_actions.click();
114+
frontend_actions.should('have.class', 'only-pro-feature');
115+
const frontend_actions_upsell_url = cy.wrap($body).find('#vz-frontend-actions .viz-group-content .only-pro-content .only-pro-container .only-pro-inner a').should('have.attr', 'href').then((href) => {
116+
const frontend_actions_search_params = new URLSearchParams(href);
117+
expect(frontend_actions_search_params.get('utm_campaign')).to.equal('frontend-actions');
118+
});
119+
});
120+
121+
cy.get('iframe')
122+
.then(function ($iframe) {
123+
const $body = $iframe.contents().find('body');
124+
// Check setting permissions upsell.
125+
const permissions = cy.wrap($body).find('#vz-permissions');
126+
permissions.click();
127+
permissions.should('have.class', 'only-pro-feature');
128+
const permissions_upsell_url = cy.wrap($body).find('#vz-permissions .viz-group-content .only-pro-content .only-pro-container .only-pro-inner a').should('have.attr', 'href').then((href) => {
129+
const permissions_search_params = new URLSearchParams(href);
130+
expect(permissions_search_params.get('utm_campaign')).to.equal('chart-permissions');
131+
});
132+
});
133+
});
134+
});

0 commit comments

Comments
 (0)