photoprism/frontend/tests/acceptance/albums.js

209 lines
7.2 KiB
JavaScript
Raw Normal View History

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 PhotoViewer from "../page-model/photoviewer";
import Page from "../page-model/page";
import AlbumDialog from "../page-model/dialog-album";
2020-06-01 17:04:47 +02:00
fixture`Test albums`.page`${testcafeconfig.url}`;
2020-06-01 17:04:47 +02:00
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();
const photoviewer = new PhotoViewer();
2020-06-01 17:04:47 +02:00
const page = new Page();
2022-04-15 15:46:25 +02:00
const albumdialog = new AlbumDialog();
2020-06-01 17:04:47 +02:00
2021-08-13 21:35:43 +02:00
test.meta("testID", "authentication-000")(
"Time to start instance (will be marked as unstable)",
async (t) => {
await t.wait(5000);
}
);
2022-04-15 15:46:25 +02:00
test.meta("testID", "albums-001").meta({ type: "smoke" })(
"Create/delete album on /albums",
async (t) => {
await menu.openPage("albums");
const AlbumCount = await album.getAlbumCount("all");
await toolbar.triggerToolbarAction("add");
const AlbumCountAfterCreate = await album.getAlbumCount("all");
const NewAlbumUid = await album.getNthAlbumUid("all", 0);
2022-04-15 15:46:25 +02:00
await t.expect(AlbumCountAfterCreate).eql(AlbumCount + 1);
await album.selectAlbumFromUID(NewAlbumUid);
await contextmenu.triggerContextMenuAction("delete", "");
const AlbumCountAfterDelete = await album.getAlbumCount("all");
await t.expect(AlbumCountAfterDelete).eql(AlbumCountAfterCreate - 1);
2021-01-26 16:36:39 +01:00
}
2022-04-15 15:46:25 +02:00
);
test.meta("testID", "albums-002").meta({ type: "smoke" })(
"Create/delete album during add to album",
async (t) => {
await menu.openPage("albums");
const AlbumCount = await album.getAlbumCount("all");
await menu.openPage("browse");
await toolbar.search("photo:true");
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
const SecondPhotoUid = await photo.getNthPhotoUid("image", 1);
await photo.selectPhotoFromUID(SecondPhotoUid);
await photo.selectPhotoFromUID(FirstPhotoUid);
await contextmenu.triggerContextMenuAction("album", "NotYetExistingAlbum");
await menu.openPage("albums");
const AlbumCountAfterCreation = await album.getAlbumCount("all");
await t.expect(AlbumCountAfterCreation).eql(AlbumCount + 1);
await toolbar.search("NotYetExistingAlbum");
const AlbumUid = await album.getNthAlbumUid("all", 0);
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-26 16:36:39 +01:00
}
2022-04-15 15:46:25 +02:00
);
test.meta("testID", "albums-003").meta({ type: "smoke" })("Update album details", async (t) => {
await menu.openPage("albums");
await toolbar.search("Holiday");
const AlbumUid = await album.getNthAlbumUid("all", 0);
await t.expect(page.cardTitle.nth(0).innerText).contains("Holiday");
await t.click(page.cardTitle.nth(0)).typeText(albumdialog.title, "Animals", { replace: true });
await t.expect(albumdialog.description.value).eql("").expect(albumdialog.category.value).eql("");
await t
2022-04-15 15:46:25 +02:00
.typeText(albumdialog.description, "All my animals")
.typeText(albumdialog.category, "Pets")
.pressKey("enter")
.click(albumdialog.dialogSave);
await t.expect(page.cardTitle.nth(0).innerText).contains("Animals");
await album.openAlbumWithUid(AlbumUid);
await toolbar.triggerToolbarAction("edit");
await t.typeText(albumdialog.title, "Holiday", { replace: true });
await t
.expect(albumdialog.description.value)
.eql("All my animals")
2022-04-15 15:46:25 +02:00
.expect(albumdialog.category.value)
.eql("Pets");
await t
.click(albumdialog.description)
.pressKey("ctrl+a delete")
.pressKey("enter")
2022-04-15 15:46:25 +02:00
.click(albumdialog.category)
.pressKey("ctrl+a delete")
.pressKey("enter")
2022-04-15 15:46:25 +02:00
.click(albumdialog.dialogSave);
await menu.openPage("albums");
await t
.expect(Selector("div").withText("Holiday").visible)
.ok()
.expect(Selector("div").withText("Animals").exists)
.notOk();
2020-06-01 17:04:47 +02:00
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "albums-004").meta({ type: "smoke" })(
"Add/Remove Photos to/from album",
async (t) => {
await menu.openPage("albums");
await toolbar.search("Holiday");
const AlbumUid = await album.getNthAlbumUid("all", 0);
await album.openAlbumWithUid(AlbumUid);
const PhotoCount = await photo.getPhotoCount("all");
await menu.openPage("browse");
await toolbar.search("photo:true");
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
const SecondPhotoUid = await photo.getNthPhotoUid("image", 1);
await photo.selectPhotoFromUID(SecondPhotoUid);
await photoviewer.openPhotoViewer("uid", FirstPhotoUid);
await photoviewer.triggerPhotoViewerAction("select");
await photoviewer.triggerPhotoViewerAction("close");
await contextmenu.triggerContextMenuAction("album", "Holiday");
await menu.openPage("albums");
await album.openAlbumWithUid(AlbumUid);
const PhotoCountAfterAdd = await photo.getPhotoCount("all");
2020-06-04 15:38:46 +02:00
2022-04-15 15:46:25 +02:00
await t.expect(PhotoCountAfterAdd).eql(PhotoCount + 2);
await photo.selectPhotoFromUID(FirstPhotoUid);
await photo.selectPhotoFromUID(SecondPhotoUid);
await contextmenu.triggerContextMenuAction("remove", "");
const PhotoCountAfterRemove = await photo.getPhotoCount("all");
await t.expect(PhotoCountAfterRemove).eql(PhotoCountAfterAdd - 2);
}
);
test.meta("testID", "albums-005")("Use album search and filters", async (t) => {
await menu.openPage("albums");
if (t.browser.platform === "mobile") {
await toolbar.search("category:Family");
} else {
await toolbar.setFilter("category", "Family");
}
await t.expect(page.cardTitle.nth(0).innerText).contains("Christmas");
const AlbumCount = await album.getAlbumCount("all");
await t.expect(AlbumCount).eql(1);
if (t.browser.platform === "mobile") {
} else {
await toolbar.setFilter("category", "All Categories");
}
await toolbar.search("Holiday");
await t.expect(page.cardTitle.nth(0).innerText).contains("Holiday");
const AlbumCount2 = await album.getAlbumCount("all");
await t.expect(AlbumCount2).eql(1);
2020-06-04 15:38:46 +02:00
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "albums-006")("Test album autocomplete", async (t) => {
await toolbar.search("photo:true");
const FirstPhotoUid = await photo.getNthPhotoUid("image", 0);
await photo.selectPhotoFromUID(FirstPhotoUid);
await contextmenu.openContextMenu();
await t.click(Selector("button.action-album")).click(Selector(".input-album input"));
await t
2022-04-15 15:46:25 +02:00
.expect(page.selectOption.withText("Holiday").visible)
.ok()
2022-04-15 15:46:25 +02:00
.expect(page.selectOption.withText("Christmas").visible)
.ok();
2022-04-15 15:46:25 +02:00
await t.typeText(Selector(".input-album input"), "C", { replace: true });
await t
2022-04-15 15:46:25 +02:00
.expect(page.selectOption.withText("Holiday").visible)
.notOk()
.expect(page.selectOption.withText("Christmas").visible)
.ok()
2022-04-15 15:46:25 +02:00
.expect(page.selectOption.withText("C").visible)
.ok();
});
2022-04-15 15:46:25 +02:00
test.meta("testID", "albums-007").meta({ type: "smoke" })(
"Create, Edit, delete sharing link",
async (t) => {
await page.testCreateEditDeleteSharingLink("albums");
}
);