Add acceptance test for login (#150)

This commit is contained in:
Theresa Gresch 2019-11-21 18:56:11 +01:00 committed by Michael Mayer
parent 58771500e3
commit 711c34b3dc
2 changed files with 50 additions and 0 deletions

View file

@ -0,0 +1,39 @@
import { Selector } from 'testcafe';
import testcafeconfig from './testcafeconfig';
import Page from "./page-model";
fixture`Test login and logout`
.page`${testcafeconfig.url}`;
const page = new Page();
test('Login', async t => {
await page.openNav();
await t
.expect(Selector('a[href="/library"]').exists, {timeout: 5000}).notOk()
.expect(Selector('a[href="/settings"]').exists, {timeout: 5000}).notOk()
.click(Selector('a[href="/login"]'));
await page.login('photoprism');
await page.openNav();
await t
.expect(Selector('a[href="/library"]').exists, {timeout: 5000}).ok()
.expect(Selector('a[href="/settings"]').exists, {timeout: 5000}).ok()
.expect(Selector('a[href="/login"]').exists, {timeout: 5000}).notOk();
}),
test('Logout', async t => {
await page.openNav();
await t
.click(Selector('a[href="/login"]'));
await page.login('photoprism');
await page.openNav();
await t
.expect(Selector('a[href="/library"]').exists, {timeout: 5000}).ok()
.expect(Selector('a[href="/settings"]').exists, {timeout: 5000}).ok()
.expect(Selector('a[href="/login"]').exists, {timeout: 5000}).notOk()
await page.logout();
await page.openNav();
await t
.expect(Selector('a[href="/library"]').exists, {timeout: 5000}).notOk()
.expect(Selector('a[href="/settings"]').exists, {timeout: 5000}).notOk()
.expect(Selector('a[href="/login"]').exists, {timeout: 5000}).ok()
});

View file

@ -82,4 +82,15 @@ export default class Page {
const countSelectedInt = (Number.isInteger(parseInt(countSelected))) ? parseInt(countSelected) : 0;
return countSelectedInt;
}
async login(password) {
await t
.typeText(Selector('input[type="password"]'), password)
.pressKey('enter');
}
async logout() {
await t
.click(Selector('div.p-navigation-logout'));
}
}