photoprism/frontend/tests/acceptance/folders.js

161 lines
5.2 KiB
JavaScript
Raw Normal View History

2021-01-27 14:39:28 +01:00
import { Selector } from "testcafe";
import testcafeconfig from "./testcafeconfig";
2022-04-15 15:46:25 +02: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 14:39:28 +01:00
fixture`Test folders`.page`${testcafeconfig.url}`;
2022-04-15 15:46:25 +02:00
const menu = new Menu();
const album = new Album();
const toolbar = new Toolbar();
const contextmenu = new ContextMenu();
const photo = new Photo();
2021-01-27 14:39:28 +01:00
const page = new Page();
2022-04-15 15:46:25 +02:00
const albumdialog = new AlbumDialog();
test.meta("testID", "folders-001").meta({ type: "smoke" })("View folders", async (t) => {
await menu.openPage("folders");
2021-01-27 14:39:28 +01:00
await t
2022-04-15 15:46:25 +02:00
.expect(Selector("a").withText("BotanicalGarden").visible)
.ok()
.expect(Selector("a").withText("Kanada").visible)
.ok()
.expect(Selector("a").withText("KorsikaAdventure").visible)
.ok();
});
test.meta("testID", "folders-002")("Update folder details", async (t) => {
await menu.openPage("folders");
await toolbar.search("Kanada");
const AlbumUid = await album.getNthAlbumUid("all", 0);
await t.expect(page.cardTitle.nth(0).innerText).contains("Kanada");
await t.click(page.cardTitle.nth(0));
await t
.expect(albumdialog.title.value)
2021-01-27 14:39:28 +01:00
.eql("Kanada")
2022-04-15 15:46:25 +02:00
.expect(albumdialog.location.value)
2021-01-27 14:39:28 +01:00
.eql("")
2022-04-15 15:46:25 +02:00
.expect(albumdialog.description.value)
2021-01-27 14:39:28 +01:00
.eql("")
2022-04-15 15:46:25 +02:00
.expect(albumdialog.category.value)
.eql("");
await t
.typeText(albumdialog.title, "MyFolder", { replace: true })
.typeText(albumdialog.location, "USA", { replace: true })
.typeText(albumdialog.description, "Last holiday")
.typeText(albumdialog.category, "Mountains")
2021-01-27 14:39:28 +01:00
.pressKey("enter")
2022-04-15 15:46:25 +02:00
.click(albumdialog.dialogSave);
await t
.expect(page.cardTitle.nth(0).innerText)
2021-01-27 14:39:28 +01:00
.contains("MyFolder")
2022-04-15 15:46:25 +02:00
.expect(page.cardDescription.nth(0).innerText)
2021-01-27 14:39:28 +01:00
.contains("Last holiday")
.expect(Selector("div.caption").nth(1).innerText)
.contains("Mountains")
.expect(Selector("div.caption").nth(2).innerText)
2022-04-15 15:46:25 +02:00
.contains("USA");
await album.openNthAlbum(0);
2021-01-27 14:39:28 +01:00
await t
2022-04-15 15:46:25 +02:00
.expect(toolbar.toolbarDescription.nth(0).innerText)
2021-01-27 14:39:28 +01:00
.contains("Last holiday")
2022-04-15 15:46:25 +02:00
.expect(toolbar.toolbarTitle.nth(0).innerText)
.contains("MyFolder");
await menu.openPage("folders");
2021-01-27 14:39:28 +01:00
if (t.browser.platform === "mobile") {
2022-04-15 15:46:25 +02:00
await toolbar.search("category:Mountains");
2021-01-27 14:39:28 +01:00
} else {
2022-04-15 15:46:25 +02:00
await toolbar.setFilter("category", "Mountains");
2021-01-27 14:39:28 +01:00
}
2022-04-15 15:46:25 +02:00
await t.expect(page.cardTitle.nth(0).innerText).contains("MyFolder");
await album.openAlbumWithUid(AlbumUid);
await toolbar.triggerToolbarAction("edit");
2021-01-27 14:39:28 +01:00
await t
2022-04-15 15:46:25 +02:00
.expect(albumdialog.description.value)
2021-01-27 14:39:28 +01:00
.eql("Last holiday")
2022-04-15 15:46:25 +02:00
.expect(albumdialog.category.value)
2021-01-27 14:39:28 +01:00
.eql("Mountains")
2022-04-15 15:46:25 +02:00
.expect(albumdialog.location.value)
.eql("USA");
await t
.typeText(albumdialog.title, "Kanada", { replace: true })
.click(albumdialog.category)
2021-01-27 14:39:28 +01:00
.pressKey("ctrl+a delete")
.pressKey("enter")
2022-04-15 15:46:25 +02:00
.click(albumdialog.description)
2021-01-27 14:39:28 +01:00
.pressKey("ctrl+a delete")
.pressKey("enter")
2022-04-15 15:46:25 +02:00
.click(albumdialog.location)
2021-01-27 14:39:28 +01:00
.pressKey("ctrl+a delete")
.pressKey("enter")
2022-04-15 15:46:25 +02:00
.click(albumdialog.dialogSave);
await menu.openPage("folders");
await toolbar.search("Kanada");
2021-01-27 14:39:28 +01:00
await t
2022-04-15 15:46:25 +02:00
.expect(page.cardTitle.nth(0).innerText)
2021-01-27 14:39:28 +01:00
.contains("Kanada")
2022-04-15 15:46:25 +02:00
.expect(page.cardDescription.nth(0).innerText)
2021-01-27 14:39:28 +01:00
.notContains("We went to ski")
.expect(Selector("div.caption").nth(0).innerText)
.notContains("USA");
});
test.meta("testID", "folders-003")("Create, Edit, delete sharing link", async (t) => {
2021-01-28 08:26:21 +01:00
await page.testCreateEditDeleteSharingLink("folders");
2021-01-27 14:39:28 +01:00
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "folders-004")("Create/delete album-clone from folder", async (t) => {
await menu.openPage("albums");
const AlbumCount = await album.getAlbumCount("all");
await menu.openPage("folders");
const ThirdFolderUid = await album.getNthAlbumUid("all", 2);
await album.openAlbumWithUid(ThirdFolderUid);
const PhotoCountInFolder = await photo.getPhotoCount("all");
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
await menu.openPage("folders");
await album.selectAlbumFromUID(ThirdFolderUid);
await contextmenu.triggerContextMenuAction("clone", "NotYetExistingAlbumForFolder");
await menu.openPage("albums");
const AlbumCountAfterCreation = await album.getAlbumCount("all");
await t.expect(AlbumCountAfterCreation).eql(AlbumCount + 1);
await toolbar.search("NotYetExistingAlbumForFolder");
const AlbumUid = await album.getNthAlbumUid("all", 0);
await album.openAlbumWithUid(AlbumUid);
const PhotoCountInAlbum = await photo.getPhotoCount("all");
await t.expect(PhotoCountInAlbum).eql(PhotoCountInFolder);
await photo.checkPhotoVisibility(FirstPhotoUid, 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 14:39:28 +01:00
2022-04-15 15:46:25 +02:00
await menu.openPage("folders");
await album.openAlbumWithUid(ThirdFolderUid);
await photo.checkPhotoVisibility(FirstPhotoUid, true);
2021-01-27 14:39:28 +01:00
});