Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds new e2e test for Newsletter for swg-basic #3593

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/e2e/commands/checkSignIn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 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.
*/

/**
* @fileoverview Switch to Google account sign in window and check that it prompts
* the user to sign in.
*/

const constants = require('../constants');

module.exports.command = function () {
return this.pause(2000)
.switchToTab('Google account sign in')
.assert.urlContains(constants.google.accountsDomain);
};
1 change: 1 addition & 0 deletions test/e2e/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

module.exports = {
google: {
accountsDomain: 'accounts.google.com',
domain: 'google.com',
},
setup: {
Expand Down
File renamed without changes.
67 changes: 67 additions & 0 deletions test/e2e/pages/basicNewsletter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @fileoverview Description of this file.
*/
/**
* 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 first article with contribution on scenic.
*/
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,
'/demos/public/newsletter.html',
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',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
'@tags': ['basic'],

'Show button': (browser) => {
const basic = browser.page.basic();
const basic = browser.page.basicContribution();
basic
.navigate()
.waitForElementPresent('@swgBasicButton', 'Found button')
Expand Down
39 changes: 39 additions & 0 deletions test/e2e/tests/basicNewsletter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* 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': ['basic'],

'Show button': (browser) => {
const basic = browser.page.basicNewsletter();
basic
.navigate()
.waitForElementPresent('@swgDialog', 'Found SwG dialog')
.waitForElementVisible('@swgDialog')
.pause(3000)
.assert.screenshotIdenticalToBaseline('html', 'basic-newsletter')
.viewNewsletter()
.assert.textContains('@newsletterHeader', 'Swgjs Newsletter Demo')
.assert.textContains(
'@consentMessage',
'Please sign up for my newsletter!'
)
.consentToNewsletter()
.optInAction()
.checkSignIn()
.end();
},
};
Loading