photoprism/frontend/tests/acceptance/states.js

149 lines
5.1 KiB
JavaScript
Raw Normal View History

2021-01-27 10:10:16 +00:00
import { Selector } from "testcafe";
import testcafeconfig from "./testcafeconfig";
2022-04-15 13:46:25 +00:00
import Menu from "../page-model/menu";
import Album from "../page-model/album";
import Toolbar from "../page-model/toolbar";
import ContextMenu from "../page-model/context-menu";
import Photo from "../page-model/photo";
import Page from "../page-model/page";
import AlbumDialog from "../page-model/dialog-album";
2021-01-27 10:10:16 +00:00
fixture`Test states`.page`${testcafeconfig.url}`;
2022-04-15 13:46:25 +00:00
const menu = new Menu();
const album = new Album();
const toolbar = new Toolbar();
const contextmenu = new ContextMenu();
const photo = new Photo();
2021-01-27 10:10:16 +00:00
const page = new Page();
2022-04-15 13:46:25 +00:00
const albumdialog = new AlbumDialog();
test.meta("testID", "states-001")("Update state details", async (t) => {
await menu.openPage("states");
await toolbar.search("Canada");
const AlbumUid = await album.getNthAlbumUid("all", 0);
await t.expect(page.cardTitle.nth(0).innerText).contains("British Columbia");
await t.click(page.cardTitle.nth(0));
2021-01-27 10:10:16 +00:00
await t
2022-04-15 13:46:25 +00:00
.expect(albumdialog.title.value)
.eql("British Columbia")
2022-04-15 13:46:25 +00:00
.expect(albumdialog.location.value)
.eql("Canada")
2022-04-15 13:46:25 +00:00
.expect(albumdialog.description.value)
2021-01-27 10:10:16 +00:00
.eql("")
2022-04-15 13:46:25 +00:00
.expect(albumdialog.category.value)
.eql("");
await t
.typeText(albumdialog.title, "Wonderland", { replace: true })
.typeText(albumdialog.location, "Earth", { replace: true })
.typeText(albumdialog.description, "We love earth")
.typeText(albumdialog.category, "Mountains")
2021-01-27 10:10:16 +00:00
.pressKey("enter")
2022-04-15 13:46:25 +00:00
.click(albumdialog.dialogSave);
await t
.expect(page.cardTitle.nth(0).innerText)
2021-01-27 10:10:16 +00:00
.contains("Wonderland")
2022-04-15 13:46:25 +00:00
.expect(page.cardDescription.nth(0).innerText)
2021-01-27 10:10:16 +00:00
.contains("We love earth")
.expect(Selector("div.caption").nth(1).innerText)
.contains("Mountains")
.expect(Selector("div.caption").nth(2).innerText)
2022-04-15 13:46:25 +00:00
.contains("Earth");
await album.openNthAlbum(0);
await t.expect(toolbar.toolbarTitle.innerText).contains("Wonderland");
await t.expect(toolbar.toolbarDescription.innerText).contains("We love earth");
await menu.openPage("states");
2021-01-27 10:10:16 +00:00
if (t.browser.platform === "mobile") {
2022-04-15 13:46:25 +00:00
await toolbar.search("category:Mountains");
2021-01-27 10:10:16 +00:00
} else {
2022-04-15 13:46:25 +00:00
await toolbar.setFilter("category", "Mountains");
2021-01-27 10:10:16 +00:00
}
2022-04-15 13:46:25 +00:00
await t.expect(page.cardTitle.nth(0).innerText).contains("Wonderland");
await album.openAlbumWithUid(AlbumUid);
await toolbar.triggerToolbarAction("edit");
2021-01-27 10:10:16 +00:00
await t
2022-04-15 13:46:25 +00:00
.expect(albumdialog.description.value)
2021-01-27 10:10:16 +00:00
.eql("We love earth")
2022-04-15 13:46:25 +00:00
.expect(albumdialog.category.value)
2021-01-27 10:10:16 +00:00
.eql("Mountains")
2022-04-15 13:46:25 +00:00
.expect(albumdialog.location.value)
.eql("Earth");
await t
.typeText(albumdialog.title, "British Columbia / Canada", { replace: true })
.click(albumdialog.category)
2021-01-27 10:10:16 +00:00
.pressKey("ctrl+a delete")
.pressKey("enter")
2022-04-15 13:46:25 +00:00
.click(albumdialog.description)
2021-01-27 10:10:16 +00:00
.pressKey("ctrl+a delete")
.pressKey("enter")
2022-04-15 13:46:25 +00:00
.typeText(albumdialog.location, "Canada", { replace: true })
.click(albumdialog.dialogSave);
await menu.openPage("states");
await toolbar.search("Canada");
2021-01-27 10:10:16 +00:00
await t
2022-04-15 13:46:25 +00:00
.expect(page.cardTitle.nth(0).innerText)
2021-01-27 10:10:16 +00:00
.contains("British Columbia / Canada")
2022-04-15 13:46:25 +00:00
.expect(page.cardDescription.innerText)
2021-01-27 10:10:16 +00:00
.notContains("We love earth")
.expect(Selector("div.caption").nth(0).innerText)
.notContains("Earth");
});
2022-04-15 13:46:25 +00:00
test.meta("testID", "states-002")("Create, Edit, delete sharing link for state", async (t) => {
await page.testCreateEditDeleteSharingLink("states");
2021-01-27 10:10:16 +00:00
});
2022-04-15 13:46:25 +00:00
test.meta("testID", "states-003")("Create/delete album-clone from state", async (t) => {
await menu.openPage("albums");
const AlbumCount = await album.getAlbumCount("all");
await menu.openPage("states");
await toolbar.search("Canada");
const FirstStateUid = await album.getNthAlbumUid("all", 0);
await album.openAlbumWithUid(FirstStateUid);
const PhotoCountInState = await photo.getPhotoCount("all");
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
const SecondPhotoUid = await photo.getNthPhotoUid("image", 1);
await menu.openPage("states");
await album.selectAlbumFromUID(FirstStateUid);
await contextmenu.triggerContextMenuAction("clone", "NotYetExistingAlbumForState");
await menu.openPage("albums");
const AlbumCountAfterCreation = await album.getAlbumCount("all");
2021-01-28 07:26:21 +00:00
2022-04-15 13:46:25 +00:00
await t.expect(AlbumCountAfterCreation).eql(AlbumCount + 1);
2021-01-27 10:10:16 +00:00
2022-04-15 13:46:25 +00:00
await toolbar.search("NotYetExistingAlbumForState");
const AlbumUid = await album.getNthAlbumUid("all", 0);
await album.openAlbumWithUid(AlbumUid);
const PhotoCountInAlbum = await photo.getPhotoCount("all");
await t.expect(PhotoCountInAlbum).eql(PhotoCountInState);
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(SecondPhotoUid, true);
await menu.openPage("albums");
await album.selectAlbumFromUID(AlbumUid);
await contextmenu.triggerContextMenuAction("delete", "");
await menu.openPage("albums");
const AlbumCountAfterDelete = await album.getAlbumCount("all");
await t.expect(AlbumCountAfterDelete).eql(AlbumCount);
2021-01-27 10:10:16 +00:00
2022-04-15 13:46:25 +00:00
await menu.openPage("states");
await album.openAlbumWithUid(FirstStateUid);
await photo.checkPhotoVisibility(FirstPhotoUid, true);
await photo.checkPhotoVisibility(SecondPhotoUid, true);
2021-01-27 10:10:16 +00:00
});