Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

chore(test): move withLogin test off of the control flow #5008

Merged
merged 2 commits into from
Nov 9, 2018
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
2 changes: 1 addition & 1 deletion scripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var passingTests = [
'node built/cli.js spec/onPreparePromiseConf.js',
'node built/cli.js spec/onPreparePromiseFileConf.js',
// 'node built/cli.js spec/mochaConf.js',
// 'node built/cli.js spec/withLoginConf.js',
'node built/cli.js spec/withLoginConf.js',
'node built/cli.js spec/suitesConf.js --suite okmany',
'node built/cli.js spec/suitesConf.js --suite okspec',
'node built/cli.js spec/suitesConf.js --suite okmany,okspec',
Expand Down
17 changes: 8 additions & 9 deletions spec/login/login_spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
var env = require('../environment.js');
const env = require('../environment.js');

describe('pages with login', function() {
it('should log in with a non-Angular page', function() {
browser.get(env.baseUrl + '/ng1/index.html');
describe('pages with login', () => {
it('should log in with a non-Angular page', async() => {
await browser.get(env.baseUrl + '/ng1/index.html');

var angularElement = element(by.model('username'));
expect(angularElement.getAttribute('value')).toEqual('Anon');
const angularElement = element(by.model('username'));
expect(await angularElement.getAttribute('value')).toEqual('Anon');

// Make sure the cookie is still set.
browser.manage().getCookie('testcookie').then(function(cookie) {
expect(cookie.value).toEqual('Jane-1234');
});
const cookie = await browser.manage().getCookie('testcookie');
expect(cookie.value).toEqual('Jane-1234');
});
});
18 changes: 9 additions & 9 deletions spec/withLoginConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var env = require('./environment.js');
// handle log-in using the onPrepare field.
exports.config = {
seleniumAddress: env.seleniumAddress,
SELENIUM_PROMISE_MANAGER: false,

framework: 'jasmine',

Expand All @@ -15,20 +16,19 @@ exports.config = {

baseUrl: env.baseUrl + '/ng1/',

onPrepare: function() {
browser.driver.get(env.baseUrl + '/ng1/login.html');
onPrepare: async() => {
await browser.driver.get(env.baseUrl + '/ng1/login.html');

browser.driver.findElement(by.id('username')).sendKeys('Jane');
browser.driver.findElement(by.id('password')).sendKeys('1234');
browser.driver.findElement(by.id('clickme')).click();
await browser.driver.findElement(by.id('username')).sendKeys('Jane');
await browser.driver.findElement(by.id('password')).sendKeys('1234');
await browser.driver.findElement(by.id('clickme')).click();

// Login takes some time, so wait until it's done.
// For the test app's login, we know it's done when it redirects to
// index.html.
return browser.driver.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return /index/.test(url);
});
return await browser.driver.wait(async() => {
const url = await browser.driver.getCurrentUrl();
return /index/.test(url);
}, 10000);
}
};