photoprism/frontend/tests/acceptance-private/authentication.js

141 lines
4.2 KiB
JavaScript
Raw Normal View History

2021-08-13 19:17:40 +00:00
import { Selector } from "testcafe";
import testcafeconfig from "../acceptance/testcafeconfig";
2022-04-15 10:33:27 +00:00
import Page from "../page-model/page";
import Account from "../page-model/account";
import Settings from "../page-model/settings";
import Menu from "../page-model/menu";
2021-08-13 19:17:40 +00:00
fixture`Test authentication`.page`${testcafeconfig.url}`;
const page = new Page();
2022-04-15 10:33:27 +00:00
const account = new Account();
const menu = new Menu();
const settings = new Settings();
2021-08-13 19:17:40 +00:00
2022-04-15 10:33:27 +00:00
test.meta("testID", "authentication-001").meta({ type: "smoke" })("Login and Logout", async (t) => {
2021-08-13 19:17:40 +00:00
await t.navigateTo("/browse");
2022-04-15 10:33:27 +00:00
2021-08-13 19:17:40 +00:00
await t
2022-04-15 10:33:27 +00:00
.expect(page.nameInput.visible)
2021-08-13 19:17:40 +00:00
.ok()
.expect(Selector(".input-search input").visible)
.notOk();
2022-04-15 10:33:27 +00:00
await t.typeText(page.nameInput, "admin", { replace: true });
await t.expect(page.loginAction.hasAttribute("disabled", "disabled")).ok();
await t.typeText(page.passwordInput, "photoprism", { replace: true });
await t.expect(page.passwordInput.hasAttribute("type", "password")).ok();
await t.click(page.togglePasswordMode);
await t.expect(page.passwordInput.hasAttribute("type", "text")).ok();
await t.click(page.togglePasswordMode);
await t.expect(page.passwordInput.hasAttribute("type", "password")).ok();
await t.click(page.loginAction);
await t.expect(Selector(".input-search input", { timeout: 7000 }).visible).ok();
await page.logout();
2021-08-13 19:17:40 +00:00
await t
2022-04-15 10:33:27 +00:00
.expect(page.nameInput.visible)
2021-08-13 19:17:40 +00:00
.ok()
.expect(Selector(".input-search input").visible)
.notOk();
2022-04-15 10:33:27 +00:00
await t.navigateTo("/settings");
2021-08-13 19:17:40 +00:00
await t
2022-04-15 10:33:27 +00:00
.expect(page.nameInput.visible)
2021-08-13 19:17:40 +00:00
.ok()
.expect(Selector(".input-search input").visible)
.notOk();
});
2022-04-15 10:33:27 +00:00
test.meta("testID", "authentication-002").meta({ type: "smoke" })(
"Login with wrong credentials",
async (t) => {
await page.login("wrong", "photoprism");
await t.navigateTo("/favorites");
await t
.expect(page.nameInput.visible)
.ok()
.expect(Selector(".input-search input").visible)
.notOk();
await page.login("admin", "abcdefg");
await t.navigateTo("/archive");
await t
.expect(page.nameInput.visible)
.ok()
.expect(Selector(".input-search input").visible)
.notOk();
}
);
test.meta("testID", "authentication-003").meta({ type: "smoke" })("Change password", async (t) => {
await t.navigateTo("/browse");
2021-08-13 19:17:40 +00:00
await page.login("admin", "photoprism");
2022-04-15 10:33:27 +00:00
await t.expect(Selector(".input-search input", { timeout: 15000 }).visible).ok();
await menu.openPage("settings");
2021-08-13 19:17:40 +00:00
await t
2022-04-15 10:33:27 +00:00
.click(settings.accountTab)
.typeText(account.currentPassword, "wrong", { replace: true })
.typeText(account.newPassword, "photoprism", { replace: true });
await t.expect(account.confirm.hasAttribute("disabled", "disabled")).ok();
await t.typeText(account.retypePassword, "photoprism", { replace: true });
await t.expect(account.confirm.hasAttribute("disabled", "disabled")).notOk();
await t
.click(account.confirm)
.typeText(account.currentPassword, "photoprism", { replace: true })
.typeText(account.newPassword, "photoprism123", { replace: true });
await t.expect(account.confirm.hasAttribute("disabled", "disabled")).ok();
await t.typeText(account.retypePassword, "photoprism123", { replace: true });
await t.expect(account.confirm.hasAttribute("disabled", "disabled")).notOk();
await t.click(account.confirm);
await page.logout();
if (t.browser.platform === "mobile") {
await t.wait(7000);
}
2021-08-13 19:17:40 +00:00
await page.login("admin", "photoprism");
2022-04-15 10:33:27 +00:00
await t.navigateTo("/archive");
2021-08-13 19:17:40 +00:00
await t
2022-04-15 10:33:27 +00:00
.expect(page.nameInput.visible)
2021-08-13 19:17:40 +00:00
.ok()
.expect(Selector(".input-search input").visible)
.notOk();
2022-04-15 10:33:27 +00:00
2021-08-13 19:17:40 +00:00
await page.login("admin", "photoprism123");
await t.expect(Selector(".input-search input").visible).ok();
2022-04-15 10:33:27 +00:00
await menu.openPage("settings");
2021-08-13 19:17:40 +00:00
await t
2022-04-15 10:33:27 +00:00
.click(settings.accountTab)
.typeText(account.currentPassword, "photoprism123", { replace: true })
.typeText(account.newPassword, "photoprism", { replace: true })
.typeText(account.retypePassword, "photoprism", { replace: true })
.click(account.confirm);
await page.logout();
2021-08-13 19:17:40 +00:00
await page.login("admin", "photoprism");
2022-04-15 10:33:27 +00:00
2021-08-13 19:17:40 +00:00
await t.expect(Selector(".input-search input").visible).ok();
2022-04-15 10:33:27 +00:00
await page.logout();
2021-08-13 19:17:40 +00:00
});