cspace-ui
Version:
CollectionSpace user interface for browsers
58 lines (53 loc) • 2.42 kB
JavaScript
;
var _LoginPage = _interopRequireDefault(require("./pageObjects/LoginPage"));
var _ProtectedPage = _interopRequireDefault(require("./pageObjects/ProtectedPage"));
var _SearchPage = _interopRequireDefault(require("./pageObjects/SearchPage"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
describe('login', function suite() {
describe('from the login page', () => {
const loginPage = new _LoginPage.default();
const protectedPage = new _ProtectedPage.default();
const searchPage = new _SearchPage.default();
beforeEach(() => {
if (!loginPage.isVisible()) {
loginPage.open();
}
});
afterEach(() => {
if (protectedPage.isVisible()) {
protectedPage.logout();
loginPage.becomesVisible();
}
});
context('when valid credentials are entered', function context() {
beforeEach(() => {
loginPage.setUsername(testParams.adminUser.username).setPassword(testParams.adminUser.password);
});
it('should open the search page when the submit button is clicked', () => {
loginPage.clickSubmitButton();
searchPage.becomesVisible().should.equal(true);
searchPage.isLoggedInAs(testParams.adminUser.screenName).should.equal(true);
});
it('should open the search page when enter is pressed on the username input', () => {
loginPage.enterUsernameInput();
searchPage.becomesVisible().should.equal(true);
searchPage.isLoggedInAs(testParams.adminUser.screenName).should.equal(true);
});
it('should open the search page when enter is pressed on the password input', () => {
loginPage.enterPasswordInput();
searchPage.becomesVisible().should.equal(true);
searchPage.isLoggedInAs(testParams.adminUser.screenName).should.equal(true);
});
});
context('when invalid credentials are entered', () => {
beforeEach(() => {
loginPage.setUsername(testParams.adminUser.username).setPassword("not ".concat(testParams.adminUser.password));
});
it('should stay on the login page and show an error message when the credentials are submitted', () => {
loginPage.submit();
searchPage.becomesVisible().should.equal(false);
loginPage.getNotificationText().should.contain('Incorrect username/password');
});
});
});
});