user.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. 'use strict';
  2. const assert = require( 'assert' ),
  3. CreateAccountPage = require( '../pageobjects/createaccount.page' ),
  4. PreferencesPage = require( '../pageobjects/preferences.page' ),
  5. UserLoginPage = require( '../pageobjects/userlogin.page' );
  6. describe( 'User', function () {
  7. var password,
  8. username;
  9. before( function () {
  10. // disable VisualEditor welcome dialog
  11. UserLoginPage.open();
  12. browser.localStorage( 'POST', { key: 've-beta-welcome-dialog', value: '1' } );
  13. } );
  14. beforeEach( function () {
  15. browser.deleteCookie();
  16. username = `User-${Math.random().toString()}`;
  17. password = Math.random().toString();
  18. } );
  19. it( 'should be able to create account', function () {
  20. // create
  21. CreateAccountPage.createAccount( username, password );
  22. // check
  23. assert.equal( CreateAccountPage.heading.getText(), `Welcome, ${username}!` );
  24. } );
  25. it( 'should be able to log in', function () {
  26. // create
  27. browser.call( function () {
  28. return CreateAccountPage.apiCreateAccount( username, password );
  29. } );
  30. // log in
  31. UserLoginPage.login( username, password );
  32. // check
  33. assert.equal( UserLoginPage.userPage.getText(), username );
  34. } );
  35. it( 'should be able to change preferences', function () {
  36. var realName = Math.random().toString();
  37. // create
  38. browser.call( function () {
  39. return CreateAccountPage.apiCreateAccount( username, password );
  40. } );
  41. // log in
  42. UserLoginPage.login( username, password );
  43. // change
  44. PreferencesPage.changeRealName( realName );
  45. // check
  46. assert.equal( PreferencesPage.realName.getValue(), realName );
  47. } );
  48. } );