|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +describe('The login view', function () { |
| 4 | + var page; |
| 5 | + var mainPage; |
| 6 | + |
| 7 | + beforeEach(function () { |
| 8 | + browser.get('http://localhost:3000/'); |
| 9 | + page = require('./login.po'); |
| 10 | + mainPage = require('./main.po'); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should display the correct form heading', function() { |
| 14 | + expect(page.loginHeader.getText()).toBe('ADMIN APP LOGIN'); |
| 15 | + //expect(page.imgEl.getAttribute('src')).toMatch(/assets\/images\/yeoman.png$/); |
| 16 | + //expect(page.imgEl.getAttribute('alt')).toBe('I\'m Yeoman'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('login should fail for wrong credentials', function () { |
| 20 | + //expect(page.thumbnailEls.count()).toBeGreaterThan(5); |
| 21 | + page.usernameInput.sendKeys('wrong'); |
| 22 | + page.passwordInput.sendKeys('wrong'); |
| 23 | + page.loginButton.click(); |
| 24 | + expect(page.alerts.count()).toBe(1); |
| 25 | + expect(page.alerts.get(0).getText()).toBe('Wrong username or password.'); |
| 26 | + }); |
| 27 | + |
| 28 | + it('login should succeed for correct credentials', function () { |
| 29 | + //expect(page.thumbnailEls.count()).toBeGreaterThan(5); |
| 30 | + page.usernameInput.sendKeys('amy_admin'); |
| 31 | + page.passwordInput.sendKeys('topcoder1'); |
| 32 | + page.loginButton.click(); |
| 33 | + expect(mainPage.isUserLoggedIn.isDisplayed()).toBeTruthy(); |
| 34 | + expect(mainPage.loggedInUser.getText()).toBe('amy_admin'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('logout should work after login', function () { |
| 38 | + //expect(page.thumbnailEls.count()).toBeGreaterThan(5); |
| 39 | + page.usernameInput.sendKeys('amy_admin'); |
| 40 | + page.passwordInput.sendKeys('topcoder1'); |
| 41 | + page.loginButton.click(); |
| 42 | + expect(mainPage.isUserLoggedIn.isDisplayed()).toBeTruthy(); |
| 43 | + expect(mainPage.loggedInUser.getText()).toBe('amy_admin'); |
| 44 | + mainPage.logout.click(); |
| 45 | + expect(page.loginHeader.getText()).toBe('ADMIN APP LOGIN'); |
| 46 | + }); |
| 47 | + |
| 48 | +}); |
0 commit comments