Add acceptance test for login (#150)
This commit is contained in:
parent
58771500e3
commit
711c34b3dc
2 changed files with 50 additions and 0 deletions
39
frontend/tests/acceptance/authentication.js
Normal file
39
frontend/tests/acceptance/authentication.js
Normal 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()
|
||||
});
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue