|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var config = protractor.getInstance().params; |
| 4 | +var UserModel = require(config.serverConfig.root + '/server/api/user/user.model'); |
| 5 | + |
| 6 | +describe('Signup View', function() { |
| 7 | + var page; |
| 8 | + |
| 9 | + var loadPage = function() { |
| 10 | + browser.get('/signup'); |
| 11 | + page = require('./signup.po'); |
| 12 | + }; |
| 13 | + |
| 14 | + var testUser = { |
| 15 | + name: 'Test User', |
| 16 | + email: 'test@test.com', |
| 17 | + password: 'test' |
| 18 | + }; |
| 19 | + |
| 20 | + beforeEach(function() { |
| 21 | + loadPage(); |
| 22 | + }); |
| 23 | + |
| 24 | + it('should include signup form with correct inputs and submit button', function() { |
| 25 | + expect(page.form.name.getAttribute('type')).toBe('text'); |
| 26 | + expect(page.form.name.getAttribute('name')).toBe('name'); |
| 27 | + expect(page.form.email.getAttribute('type')).toBe('email'); |
| 28 | + expect(page.form.email.getAttribute('name')).toBe('email'); |
| 29 | + expect(page.form.password.getAttribute('type')).toBe('password'); |
| 30 | + expect(page.form.password.getAttribute('name')).toBe('password'); |
| 31 | + expect(page.form.submit.getAttribute('type')).toBe('submit'); |
| 32 | + expect(page.form.submit.getText()).toBe('Sign up'); |
| 33 | + }); |
| 34 | + |
| 35 | + describe('with local auth', function() { |
| 36 | + |
| 37 | + it('should signup a new user, log them in, and redirecting to "/"', function(done) { |
| 38 | + UserModel.remove(function() { |
| 39 | + page.signup(testUser); |
| 40 | + |
| 41 | + var navbar = require('../../components/navbar/navbar.po'); |
| 42 | + |
| 43 | + expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/'); |
| 44 | + expect(navbar.navbarAccountGreeting.getText()).toBe('Hello ' + testUser.name); |
| 45 | + |
| 46 | + done(); |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + it('should indicate signup failures', function() { |
| 51 | + page.signup(testUser); |
| 52 | + |
| 53 | + expect(browser.getLocationAbsUrl()).toBe(config.baseUrl + '/signup'); |
| 54 | + expect(page.form.email.getAttribute('class')).toContain('ng-invalid-mongoose'); |
| 55 | + |
| 56 | + var helpBlock = page.form.element(by.css('.form-group.has-error .help-block.ng-binding')); |
| 57 | + expect(helpBlock.getText()).toBe('The specified email address is already in use.'); |
| 58 | + }); |
| 59 | + |
| 60 | + }); |
| 61 | +}); |
0 commit comments