Skip to content

Commit cc48b80

Browse files
Merge pull request #1097 from Codeinwp/fix/e2e_testing_for_pro
fix: e2e tests in pro version Codeinwp/visualizer-pro#418
2 parents aa5ace9 + 3152556 commit cc48b80

File tree

2 files changed

+137
-2
lines changed

2 files changed

+137
-2
lines changed

classes/Visualizer/Render/Layout.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,11 @@ class="dashicons dashicons-lock"></span></h2>
872872
<input type="button" id="existing-chart" class="button button-primary"
873873
value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
874874
data-viz-link="<?php echo $fetch_link; ?>">
875-
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' ); ?>
875+
<?php
876+
if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
877+
echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' );
878+
}
879+
?>
876880
</div>
877881
</div>
878882
</li>
@@ -921,7 +925,6 @@ class="dashicons dashicons-lock"></span></h2>
921925

922926
<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; ?>">
923927
<input type="button" id="db-filter-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
924-
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' ); ?>
925928
</form>
926929
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp' ); ?>
927930
</div>
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+
beforeEach(() => {
12+
cy.visit(Cypress.env('urls').library );
13+
cy.get('.add-new-h2.add-new-chart').first().click();
14+
cy.wait( Cypress.env('wait') );
15+
});
16+
17+
it('Check upsell links', function() {
18+
cy.get('iframe')
19+
.then(function ($iframe) {
20+
const $body = $iframe.contents().find('body');
21+
cy.wrap($body).find('#toolbar input[type="submit"]').click();
22+
cy.wait( Cypress.env('wait') );
23+
});
24+
25+
cy.get('iframe')
26+
.then(function ($iframe) {
27+
const $body = $iframe.contents().find('body');
28+
// Check Import form other chart upsell.
29+
const other_import = cy.wrap($body).find('.viz-import-from-other');
30+
other_import.click();
31+
other_import.should('have.class', 'only-pro-feature');
32+
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) => {
33+
const other_import_search_params = new URLSearchParams(href);
34+
expect(other_import_search_params.get('utm_campaign')).to.equal('import-chart');
35+
});
36+
});
37+
38+
cy.get('iframe')
39+
.then(function ($iframe) {
40+
const $body = $iframe.contents().find('body');
41+
// Check import form WordPress upsell.
42+
const wp_import = cy.wrap($body).find('.visualizer_source_query_wp');
43+
wp_import.click();
44+
wp_import.should('have.class', 'only-pro-feature');
45+
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) => {
46+
const wp_import_search_params = new URLSearchParams(href);
47+
expect(wp_import_search_params.get('utm_campaign')).to.equal('import-wp');
48+
});
49+
});
50+
51+
cy.get('iframe')
52+
.then(function ($iframe) {
53+
const $body = $iframe.contents().find('body');
54+
// Check import form database upsell.
55+
const db_import = cy.wrap($body).find('.visualizer_source_query');
56+
db_import.click();
57+
db_import.should('have.class', 'only-pro-feature');
58+
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) => {
59+
const db_import_search_params = new URLSearchParams(href);
60+
expect(db_import_search_params.get('utm_campaign')).to.equal('db-query');
61+
});
62+
});
63+
64+
cy.get('iframe')
65+
.then(function ($iframe) {
66+
const $body = $iframe.contents().find('body');
67+
// Check import form manual data upsell.
68+
const manual_import = cy.wrap($body).find('.visualizer_source_manual');
69+
manual_import.click();
70+
manual_import.should('have.class', 'only-pro-feature');
71+
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) => {
72+
const manual_import_search_params = new URLSearchParams(href);
73+
expect(manual_import_search_params.get('utm_campaign')).to.equal('manual-data');
74+
});
75+
});
76+
});
77+
78+
it('Check Settings upsell links', function() {
79+
cy.get('iframe')
80+
.then(function ($iframe) {
81+
const $body = $iframe.contents().find('body');
82+
cy.wrap($body).find('#toolbar input[type="submit"]').click();
83+
cy.wait( Cypress.env('wait') );
84+
});
85+
86+
cy.get('iframe')
87+
.then(function ($iframe) {
88+
const $body = $iframe.contents().find('body');
89+
cy.wrap($body).find('#viz-tab-advanced').click();
90+
cy.wait( Cypress.env('wait') );
91+
});
92+
93+
cy.get('iframe')
94+
.then(function ($iframe) {
95+
const $body = $iframe.contents().find('body');
96+
// Check setting chart data filter configuration upsell.
97+
const data_control = cy.wrap($body).find('#vz-data-controls');
98+
data_control.click();
99+
data_control.should('have.class', 'only-pro-feature');
100+
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) => {
101+
const data_control_search_params = new URLSearchParams(href);
102+
expect(data_control_search_params.get('utm_campaign')).to.equal('data-filter-configuration');
103+
});
104+
});
105+
106+
cy.get('iframe')
107+
.then(function ($iframe) {
108+
const $body = $iframe.contents().find('body');
109+
// Check setting frontend actions upsell.
110+
const frontend_actions = cy.wrap($body).find('#vz-frontend-actions');
111+
frontend_actions.click();
112+
frontend_actions.should('have.class', 'only-pro-feature');
113+
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) => {
114+
const frontend_actions_search_params = new URLSearchParams(href);
115+
expect(frontend_actions_search_params.get('utm_campaign')).to.equal('frontend-actions');
116+
});
117+
});
118+
119+
cy.get('iframe')
120+
.then(function ($iframe) {
121+
const $body = $iframe.contents().find('body');
122+
// Check setting permissions upsell.
123+
const permissions = cy.wrap($body).find('#vz-permissions');
124+
permissions.click();
125+
permissions.should('have.class', 'only-pro-feature');
126+
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) => {
127+
const permissions_search_params = new URLSearchParams(href);
128+
expect(permissions_search_params.get('utm_campaign')).to.equal('chart-permissions');
129+
});
130+
});
131+
});
132+
});

0 commit comments

Comments
 (0)