Skip to content

Commit

Permalink
test: fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogier-blip committed Jan 29, 2020
1 parent 13560fb commit 34be4c7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 35 deletions.
11 changes: 6 additions & 5 deletions e2e/src/1.login.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('montepoeli login', () => {
it('should fail login into montepouli', async () => {
await page.navigateToBase();

expect(await browser.getCurrentUrl()).toContain('/login');
await expect(await browser.getCurrentUrl()).toContain('/login');

await page.getLoginField().sendKeys('protractor');

Expand All @@ -22,17 +22,18 @@ describe('montepoeli login', () => {
await page.getSubmitButton().click();

await helper.sleep();
const loginFailedWarning = await page.getLoginFailedWarning().getText();

expect(await page.getLoginFailedWarning().getText()).toEqual('Wrong username or password.');
await expect(loginFailedWarning).toEqual('Wrong username or password.');

expect(await browser.getCurrentUrl()).toContain('/login');
await expect(await browser.getCurrentUrl()).toContain('/login');

helper.expectThreeErrorsInConsole(browser);
});

it('should login to montepouli', async () => {
await page.navigateToBase();
expect(await browser.getCurrentUrl()).toContain('/login');
await expect(await browser.getCurrentUrl()).toContain('/login');

await page.getLoginField().sendKeys('protractor');

Expand All @@ -42,7 +43,7 @@ describe('montepoeli login', () => {

await browser.waitForAngular();

expect(await browser.getCurrentUrl()).toContain('/home');
await expect(await browser.getCurrentUrl()).toContain('/home');

helper.expectNoErrorsInConsole(browser);
});
Expand Down
14 changes: 7 additions & 7 deletions e2e/src/2.add-game.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Add a game', () => {

await browser.waitForAngular();

expect(await browser.getCurrentUrl()).toContain('/home');
await expect(await browser.getCurrentUrl()).toContain('/home');

await page.getAddGameButton().click();

Expand All @@ -25,28 +25,28 @@ describe('Add a game', () => {
await page.getProtractorUser().click();

await browser.waitForAngular();
expect(await page.getWhiteDropDownField().getText()).toEqual('protractor');
await expect(await page.getWhiteDropDownField().getText()).toEqual('protractor');

await page.getWinnerDropDownList().click();

await page.getWhiteOption().click();

await browser.waitForAngular();
expect(await page.getWinnerDropDownField().getText()).toEqual('White');
await expect(await page.getWinnerDropDownField().getText()).toEqual('White');

await page.getBlackDropDownList().click();

await page.getProtractorUser1().click();

await browser.waitForAngular();
expect(await page.getBlackDropDownField().getText()).toEqual('protractor1');
await expect(await page.getBlackDropDownField().getText()).toEqual('protractor1');

await page.getSaveButton().click();

await browser.waitForAngular();
expect(await page.getTableWhiteUserForLastAddedGame().getText()).toEqual('protractor');
expect(await page.getTableWinnerUserForLastAddedGame('white').getText()).toEqual('White');
expect(await page.getTableBlackUserForLastAddedGame().getText()).toEqual('protractor1');
await expect(await page.getTableWhiteUserForLastAddedGame().getText()).toEqual('protractor');
await expect(await page.getTableWinnerUserForLastAddedGame('white').getText()).toEqual('White');
await expect(await page.getTableBlackUserForLastAddedGame().getText()).toEqual('protractor1');

});

Expand Down
4 changes: 2 additions & 2 deletions e2e/src/3.switching-tabs.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ describe('Tab navigation', () => {
await page.getNavBarRulesTab().click();

await browser.waitForAngular();
expect(await page.getRulesView()).toBeTruthy();
await expect(await page.getRulesView()).toBeTruthy();

await page.getNavBarGamesTab().click();

await browser.waitForAngular();
expect(await page.getGamesView()).toBeTruthy();
await expect(await page.getGamesView()).toBeTruthy();
});

afterEach(() => helper.expectNoErrorsInConsole(browser));
Expand Down
6 changes: 3 additions & 3 deletions e2e/src/4.logout.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ describe('montepoeli', () => {
it('should logout from montepouli', async () => {
await page.navigateToBase();

expect(await browser.getCurrentUrl()).toContain('/home');
await expect(await browser.getCurrentUrl()).toContain('/home');

await page.getUserSettings().click();
await page.getLogout().click();

await browser.waitForAngular();

expect(await browser.getCurrentUrl()).toContain('/login');
await expect(await browser.getCurrentUrl()).toContain('/login');

await page.navigateToHome();

expect(await browser.getCurrentUrl()).toContain('/login');
await expect(await browser.getCurrentUrl()).toContain('/login');

helper.expectNoErrorsInConsole(browser);
});
Expand Down
4 changes: 2 additions & 2 deletions e2e/src/5.login-mobile.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('montepoeli login', () => {

it('should login to montepouli', async () => {
await page.navigateToBase();
expect(await browser.getCurrentUrl()).toContain('/login');
await expect(await browser.getCurrentUrl()).toContain('/login');

await page.getLoginField().sendKeys('protractor');

Expand All @@ -26,7 +26,7 @@ describe('montepoeli login', () => {
await page.getSubmitButton().click();

await browser.waitForAngular();
expect(await browser.getCurrentUrl()).toContain('/home');
await expect(await browser.getCurrentUrl()).toContain('/home');

helper.expectNoErrorsInConsole(browser);
});
Expand Down
18 changes: 9 additions & 9 deletions e2e/src/6.mobile-screen-tests.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ describe('Mobile screen tests', () => {

await helper.longSleep();

expect(await page.getRulesView()).toBeTruthy();
await expect(await page.getRulesView()).toBeTruthy();

expect(await page.getMobileNavButtonGames()).toBeTruthy();
expect(await page.getMobileAddGameButton().getCssValue('opacity')).toEqual('0');
expect(await page.getMobileAddGameButton().getCssValue('pointer-events')).toEqual('none');
expect(await page.getMobileNavButtonRules()).toBeTruthy();
await expect(await page.getMobileNavButtonGames()).toBeTruthy();
await expect(await page.getMobileAddGameButton().getCssValue('opacity')).toEqual('0');
await expect(await page.getMobileAddGameButton().getCssValue('pointer-events')).toEqual('none');
await expect(await page.getMobileNavButtonRules()).toBeTruthy();

await helper.sleep();

await page.getMobileNavButtonGames().click();

await helper.longSleep();

expect(await page.getGamesView()).toBeTruthy();
await expect(await page.getGamesView()).toBeTruthy();

expect(await page.getMobileNavButtonGames()).toBeTruthy();
expect(await page.getMobileAddGameButton().getCssValue('opacity')).toEqual('1');
expect(await page.getMobileNavButtonRules()).toBeTruthy();
await expect(await page.getMobileNavButtonGames()).toBeTruthy();
await expect(await page.getMobileAddGameButton().getCssValue('opacity')).toEqual('1');
await expect(await page.getMobileNavButtonRules()).toBeTruthy();
});

afterEach(() => {
Expand Down
15 changes: 8 additions & 7 deletions e2e/src/7.add-game-mobile.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Add a game', () => {

await browser.waitForAngular();

expect(browser.getCurrentUrl()).toContain('/home');
await expect(await browser.getCurrentUrl()).toContain('/home');

// TODO: refactor adding a user with the pop up to a method

Expand All @@ -31,28 +31,29 @@ describe('Add a game', () => {
await page.getProtractorUser().click();

await browser.waitForAngular();
expect(await page.getWhiteDropDownField().getText()).toEqual('protractor');

await expect(await page.getWhiteDropDownField().getText()).toEqual('protractor');

await page.getWinnerDropDownList().click();

await page.getBlackOption().click();

await browser.waitForAngular();
expect(await page.getWinnerDropDownField().getText()).toEqual('Black');
await expect(await page.getWinnerDropDownField().getText()).toEqual('Black');

await page.getBlackDropDownList().click();

await page.getProtractorUser1().click();

await browser.waitForAngular();
expect(await page.getBlackDropDownField().getText()).toEqual('protractor1');
await expect(await page.getBlackDropDownField().getText()).toEqual('protractor1');

await page.getSaveButton().click();

await browser.waitForAngular();
expect(await page.getTableWhiteUserForLastAddedGame().getText()).toEqual('protractor');
expect(await page.getTableWinnerUserForLastAddedGame('black').getText()).toEqual('Black');
expect(await page.getTableBlackUserForLastAddedGame().getText()).toEqual('protractor1');
await expect(await page.getTableWhiteUserForLastAddedGame().getText()).toEqual('protractor');
await expect(await page.getTableWinnerUserForLastAddedGame('black').getText()).toEqual('Black');
await expect(await page.getTableBlackUserForLastAddedGame().getText()).toEqual('protractor1');

});

Expand Down

0 comments on commit 34be4c7

Please sign in to comment.