Skip to content

Commit

Permalink
Adds e2e test for Enterprise Newsletter (#3595)
Browse files Browse the repository at this point in the history
* add publisher script to show newsletter from available interventions

* add e2e test for enterprise newsletter

* update title and text

* remove wait statements

* try not strict equality ont ype

* add print statements

* add print statements

* fix return

* add contribution to see if it will render

* debug

* remove bad screenshots

* debug more

* debug

* revert

* fix show call

* delete bad screenshot

* remove console statement

* fix baseline path for ss

* update config to upload baseline too, add enterprise screenshots

---------

Co-authored-by: justinchou-google <justinchou-google@users.noreply.github.com>
  • Loading branch information
justinchou-google and justinchou-google authored Nov 8, 2024
1 parent fe798b1 commit 8383e70
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ jobs:
- name: E2E Tests
run: . ./build_and_run_e2e.sh

- name: Upload e2e VRT baseline
if: always()
uses: actions/upload-artifact@v4
with:
name: vrt-baseline
path: test/e2e/vrt/baseline

- name: Upload e2e VRT report
if: always()
uses: actions/upload-artifact@v4
Expand All @@ -68,6 +75,13 @@ jobs:
- name: E2E Tests with all experiments enabled
run: . ./build_and_run_e2e.sh all_experiments_enabled

- name: Upload e2e with all experiments VRT baseline
if: always()
uses: actions/upload-artifact@v4
with:
name: all-experiments-vrt-baseline
path: test/e2e/vrt/baseline

- name: Upload e2e with all experiments VRT report
if: always()
uses: actions/upload-artifact@v4
Expand Down
15 changes: 15 additions & 0 deletions examples/sample-pub/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,21 @@ function startFlowAuto() {
return;
}

if (flow == 'showNewsletterSignup') {
onEntitlements = (subscriptions) => {
subscriptions.getAvailableInterventions().then((interventions) => {
const newsletterIntervention = interventions.find(
(intervention) => intervention.type == 'TYPE_NEWSLETTER_SIGNUP'
);
newsletterIntervention.show({});
});
};
whenReady((subscriptions) => {
subscriptions.start();
});
return;
}

startFlow(flow);
}

Expand Down
64 changes: 64 additions & 0 deletions test/e2e/pages/enterpriseNewsletter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright 2019 The Subscribe with Google Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

const {swgPageUrl} = require('../util');

/**
* @fileoverview Page object for the basic contribution page.
*/
const commands = {
viewNewsletter: function () {
return this.pause(1000)
.log('Viewing newsletter')
.switchToFrame('[src*="about:blank"]', 'SwG outer iFrame')
.switchToFrame('[src*="newsletteriframe"]', 'SwG inner iFrame');
},
consentToNewsletter: function () {
return this.log('Checking consent checkbox').click('@consentCheckbox');
},
optInAction: function () {
return this.log('Clicking opt in button').click('@optInButton');
},
};

module.exports = {
url: function () {
return swgPageUrl(
this.api.launchUrl,
'/examples/sample-pub/config/rrme-contributions-prod/1?showNewsletterSignup',
this.api.globals.swg_experiments
);
},
commands: [commands],
elements: {
consentCheckbox: {
selector: '.MlG5Jc input',
},
consentMessage: {
selector: '.MlG5Jc label',
},
newsletterHeader: {
selector: '.sJIgh',
},
optInButton: {
selector: '.C2qNIf button',
},
swgDialog: {
selector: '.swg-dialog',
},
},
};
37 changes: 37 additions & 0 deletions test/e2e/tests/enterpriseNewsletter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2019 The Subscribe with Google Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

module.exports = {
'@tags': ['enterprise'],

'Enterprise Newsletter': (browser) => {
const basic = browser.page.enterpriseNewsletter();
basic
.navigate()
.pause(3000)
.assert.screenshotIdenticalToBaseline('html', 'enterprise-newsletter')
.viewNewsletter()
.assert.textContains(
'@newsletterHeader',
'Enterprise Contribution E2E Test Pub'
)
.assert.textContains('@consentMessage', 'I consent to this newsletter.')
.consentToNewsletter()
.optInAction()
.checkSignIn()
.end();
},
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8383e70

Please sign in to comment.