From 2c0fdf89d6253b6be9bbdcfd07c2cf09aac1b145 Mon Sep 17 00:00:00 2001 From: theresa Date: Fri, 21 Jan 2022 17:55:27 +0100 Subject: [PATCH] Tests: Update page-models --- frontend/tests/page-model/album.js | 3 +- frontend/tests/page-model/dialog-share.js | 14 +++ frontend/tests/page-model/library.js | 10 +++ frontend/tests/page-model/menu.js | 10 ++- frontend/tests/page-model/navigate.js | 21 ++--- frontend/tests/page-model/originals.js | 5 ++ frontend/tests/page-model/page.js | 104 +++++++++++++++++++++- frontend/tests/page-model/photo-edit.js | 40 +++++++-- frontend/tests/page-model/photo-views.js | 9 +- frontend/tests/page-model/photo.js | 8 +- frontend/tests/page-model/photoviewer.js | 13 +-- frontend/tests/page-model/settings.js | 23 +++++ 12 files changed, 222 insertions(+), 38 deletions(-) create mode 100644 frontend/tests/page-model/dialog-share.js create mode 100644 frontend/tests/page-model/library.js create mode 100644 frontend/tests/page-model/settings.js diff --git a/frontend/tests/page-model/album.js b/frontend/tests/page-model/album.js index 24b3c6613..8595303db 100644 --- a/frontend/tests/page-model/album.js +++ b/frontend/tests/page-model/album.js @@ -44,7 +44,7 @@ export default class Page { } async openNthAlbum(nth) { - await t.click(Selector("a.is-album").nth(nth)).expect(Selector("div.is-photo").visible).ok(); + await t.click(Selector("a.is-album").nth(nth)); } async openAlbumWithUid(uid) { @@ -64,7 +64,6 @@ export default class Page { async triggerHoverAction(mode, uidOrNth, action) { if (mode === "uid") { await t.hover(Selector("a.uid-" + uidOrNth)); - Selector("a.uid-" + uidOrNth + " .input-" + action); await t.click(Selector("a.uid-" + uidOrNth + " .input-" + action)); } if (mode === "nth") { diff --git a/frontend/tests/page-model/dialog-share.js b/frontend/tests/page-model/dialog-share.js new file mode 100644 index 000000000..dde3acda2 --- /dev/null +++ b/frontend/tests/page-model/dialog-share.js @@ -0,0 +1,14 @@ +import { Selector, t } from "testcafe"; + +export default class Page { + constructor() { + this.dialogClose = Selector("button.action-close", { timeout: 15000 }); + this.dialogSave = Selector("button.action-save", { timeout: 15000 }); + this.addLink = Selector(".action-add-link", { timeout: 15000 }); + this.deleteLink = Selector(".action-delete", { timeout: 15000 }); + this.expandLink = Selector("div.v-expansion-panel__header__icon", { timeout: 15000 }); + this.linkUrl = Selector("div.input-url input", { timeout: 15000 }); + this.linkSecretInput = Selector(".input-secret input", { timeout: 15000 }); + this.linkExpireInput = Selector(".input-expires input", { timeout: 15000 }); + } +} diff --git a/frontend/tests/page-model/library.js b/frontend/tests/page-model/library.js new file mode 100644 index 000000000..e729bb60c --- /dev/null +++ b/frontend/tests/page-model/library.js @@ -0,0 +1,10 @@ +import { Selector, t } from "testcafe"; + +export default class Page { + constructor() { + this.openImportFolderSelect = Selector(".input-import-folder input", { timeout: 15000 }); + this.import = Selector(".action-import"); + this.indexFolderSelect = Selector(".input-index-folder input", { timeout: 15000 }); + this.index = Selector(".action-index"); + } +} diff --git a/frontend/tests/page-model/menu.js b/frontend/tests/page-model/menu.js index 2bb8bdc90..22ec6367f 100644 --- a/frontend/tests/page-model/menu.js +++ b/frontend/tests/page-model/menu.js @@ -21,7 +21,9 @@ export default class Page { (page === "review") | (page === "archive") ) { - await t.click(Selector("div.nav-browse + div")); + if (!(await Selector("div.v-list__group--active div.nav-browse").visible)) { + await t.click(Selector("div.nav-browse + div")); + } } else if (page === "live") { if (!(await Selector("div.v-list__group--active div.nav-video").visible)) { await t.click(Selector("div.nav-video + div")); @@ -34,7 +36,7 @@ export default class Page { if (!(await Selector("div.v-list__group--active div.nav-library").visible)) { await t.click(Selector("div.nav-library + div")); } - } else if ((page === "abouts") | (page === "feedback") | (page === "license")) { + } else if ((page === "about") | (page === "feedback") | (page === "license")) { if (!(await Selector("div.v-list__group--active div.nav-settings").visible)) { await t.click(Selector("div.nav-settings + div")); } @@ -52,7 +54,9 @@ export default class Page { (page === "review") | (page === "archive") ) { - await t.click(Selector("div.nav-browse + div")); + if (!(await Selector("div.v-list__group--active div.nav-browse").visible)) { + await t.click(Selector("div.nav-browse + div")); + } } else if (page === "live") { if (await Selector(".nav-video").visible) { if (!(await Selector("div.v-list__group--active div.nav-video").visible)) { diff --git a/frontend/tests/page-model/navigate.js b/frontend/tests/page-model/navigate.js index b0d9e3d79..65ec1dd9c 100644 --- a/frontend/tests/page-model/navigate.js +++ b/frontend/tests/page-model/navigate.js @@ -15,33 +15,28 @@ export default class Page { this.search1 = Selector("div.input-search input", { timeout: 15000 }); } - //login - - //logout + //login Selectors //review card actions //open tab - // album with uid visible - - // open album with uid + //edit single fields / check disabled, selectors for single fields? + // check edit form values // get all current edit form values // set edit form values //?dialogs? - //checkboxen settings ? - - // selectors for index/import/logs/ ? input folder edit dialog - //edit dialog disabled --funcionalities - //edit dialog close, next, previous - // edit dialog clear, reject face etc // update album --functionalities //selectors card view album location/ subject count / label count + //remove album type from trigger context menu action - //selectors edit dialogs label etc //sharing + //update all tests with new selectors + + //refactor admin/ member tests --> for each resource (photo, video, subject, label, albums , states) check context menu action/fullscreen actions/edit dialog/ + } diff --git a/frontend/tests/page-model/originals.js b/frontend/tests/page-model/originals.js index 6766eb0f4..d40ea011f 100644 --- a/frontend/tests/page-model/originals.js +++ b/frontend/tests/page-model/originals.js @@ -23,6 +23,11 @@ export default class Page { return FolderCount; } + async getFileCount() { + const FileCount = await Selector("div.is-file", { timeout: 5000 }).count; + return FileCount; + } + async selectFolderFromUID(uid) { await t .hover(Selector("div.is-folder").withAttribute("data-uid", uid)) diff --git a/frontend/tests/page-model/page.js b/frontend/tests/page-model/page.js index f947bfeaf..7f6815d15 100644 --- a/frontend/tests/page-model/page.js +++ b/frontend/tests/page-model/page.js @@ -1,14 +1,112 @@ import { Selector, t } from "testcafe"; +import { RequestLogger } from "testcafe"; +import Menu from "./menu"; +import Album from "./album"; +import Toolbar from "./toolbar"; +import ContextMenu from "./context-menu"; +import Photo from "./photo"; +import PhotoViewer from "./photoviewer"; +import ShareDialog from "./dialog-share"; + +const logger = RequestLogger(/http:\/\/localhost:2343\/api\/v1\/*/, { + logResponseHeaders: true, + logResponseBody: true, +}); + +const menu = new Menu(); +const album = new Album(); +const toolbar = new Toolbar(); +const contextmenu = new ContextMenu(); +const photo = new Photo(); +const photoviewer = new PhotoViewer(); +const sharedialog = new ShareDialog(); export default class Page { constructor() { this.selectOption = Selector("div.v-list__tile__title", { timeout: 15000 }); this.cardTitle = Selector("button.action-title-edit"); this.cardDescription = Selector('div[title="Description"]'); + this.cardLocation = Selector("button.action-location"); + } + async login(username, password) { + await t + .typeText(Selector(".input-name input"), username, { replace: true, timeout: 5000 }) + .typeText(Selector(".input-password input"), password, { replace: true }) + .click(Selector(".action-confirm")); + } - //album location - //photo title button.action-title-edit - // photo decsription + async logout() { + await t.click(Selector("div.nav-logout")); + } + + async validateDownloadRequest(request, filename, extension) { + const downloadedFileName = request.headers["content-disposition"]; + await t + .expect(request.statusCode === 200) + .ok() + .expect(downloadedFileName) + .contains(filename) + .expect(downloadedFileName) + .contains(extension); + await logger.clear(); + } + + async testCreateEditDeleteSharingLink(type) { + await menu.openPage(type); + const FirstAlbum = await album.getNthAlbumUid("all", 0); + await album.triggerHoverAction("uid", FirstAlbum, "select"); + //await this.selectFromUID(FirstAlbum); + await contextmenu.checkContextMenuCount("1"); + await contextmenu.triggerContextMenuAction("share", "", ""); + await t.click(sharedialog.expandLink.nth(0)); + const InitialUrl = await sharedialog.linkUrl.innerText; + const InitialSecret = await sharedialog.linkSecretInput.value; + //const InitialUrl = await Selector(".action-url").innerText; + // const InitialSecret = await Selector(".input-secret input").value; + const InitialExpire = await Selector("div.v-select__selections").innerText; + await t + .expect(InitialUrl) + .notContains("secretfortesting") + .expect(InitialExpire) + .contains("Never") + .typeText(sharedialog.linkSecretInput, "secretForTesting", { replace: true }) + .click(sharedialog.linkExpireInput) + .click(Selector("div").withText("After 1 day").parent('div[role="listitem"]')) + .click(sharedialog.dialogSave) + .click(sharedialog.dialogClose); + await contextmenu.clearSelection(); + await album.openAlbumWithUid(FirstAlbum); + await toolbar.triggerToolbarAction("share", ""); + await t.click(sharedialog.expandLink.nth(0)); + const UrlAfterChange = await sharedialog.linkUrl.innerText; + const ExpireAfterChange = await Selector("div.v-select__selections").innerText; + await t + .expect(UrlAfterChange) + .contains("secretfortesting") + .expect(ExpireAfterChange) + .contains("After 1 day") + .typeText(sharedialog.linkSecretInput, InitialSecret, { replace: true }) + .click(sharedialog.linkExpireInput) + .click(Selector("div").withText("Never").parent('div[role="listitem"]')) + .click(sharedialog.dialogSave) + .click(sharedialog.expandLink); + const LinkCount = await Selector(".action-url").count; + await t.click(sharedialog.addLink); + const LinkCountAfterAdd = await Selector(".action-url").count; + await t + .expect(LinkCountAfterAdd) + .eql(LinkCount + 1) + .click(sharedialog.expandLink) + .click(sharedialog.deleteLink); + const LinkCountAfterDelete = await Selector(".action-url").count; + await t + .expect(LinkCountAfterDelete) + .eql(LinkCountAfterAdd - 1) + .click(sharedialog.dialogClose); + await menu.openPage(type); + await toolbar.triggerToolbarAction("reload", ""); + await album.triggerHoverAction("uid", FirstAlbum, "share"); + await t.click(sharedialog.expandLink).click(sharedialog.deleteLink); } } diff --git a/frontend/tests/page-model/photo-edit.js b/frontend/tests/page-model/photo-edit.js index 1b0560eee..c93aff06e 100644 --- a/frontend/tests/page-model/photo-edit.js +++ b/frontend/tests/page-model/photo-edit.js @@ -1,9 +1,41 @@ import { Selector, t } from "testcafe"; export default class Page { - constructor() {} + constructor() { + this.dialogClose = Selector("div.v-dialog button.action-close", { timeout: 15000 }); + this.dialogNext = Selector("div.v-dialog button.action-next", { timeout: 15000 }); + this.dialogPrevious = Selector("div.v-dialog button.action-previous", { timeout: 15000 }); + + this.detailsDone = Selector(".p-form-photo-details-meta button.action-done", { timeout: 15000 }); + this.detailsApprove = Selector(".p-form-photo-details-meta button.action-approve", { timeout: 15000 }); + this.detailsClose = Selector(".p-form-photo-details-meta button.action-close", { timeout: 15000 }); + this.detailsApply = Selector(".p-form-photo-details-meta button.action-apply", { timeout: 15000 }); + + this.rejectName = Selector("div.input-name div.v-input__icon--clear", { timeout: 15000 }); + this.removeMarker = Selector("button.input-reject", { timeout: 15000 }); + this.undoRemoveMarker = Selector("button.action-undo", { timeout: 15000 }); + this.inputName = Selector("div.input-name input", { timeout: 15000 }); + + this.addLabel = Selector("button.p-photo-label-add", { timeout: 15000 }); + this.removeLabel = Selector("button.action-remove", { timeout: 15000 }) + this.activateLabel = Selector(".action-on", { timeout: 15000 }); + this.deleteLabel = Selector(".action-delete", { timeout: 15000 }); + this.inputLabelName = Selector(".input-label input", { timeout: 15000 }); + this.openInlineEdit = Selector("div.p-inline-edit", { timeout: 15000 }); + this.inputLabelRename = Selector(".input-rename input", { timeout: 15000 }); + + this.downloadFile = Selector("button.action-download", { timeout: 15000 }); + this.unstackFile = Selector(".action-unstack", { timeout: 15000 }); + this.deleteFile = Selector(".action-delete", { timeout: 15000 }); + this.makeFilePrimary = Selector(".action-primary", { timeout: 15000 }); + this.toggleExpandFile = Selector("li.v-expansion-panel__container", { timeout: 15000 }); + } + + async getFileCount() { + const FileCount = await Selector("li.v-expansion-panel__container", { timeout: 5000 }).count; + return FileCount; + } - // turn switch of --photo --edit async turnSwitchOff(type) { await t .click("#tab-info") @@ -51,7 +83,6 @@ export default class Page { month, year, localTime, - utcTime, timezone, country, altitude, @@ -89,9 +120,6 @@ export default class Page { if (localTime !== "") { await t.expect(Selector(".input-local-time input").value).eql(localTime); } - if (utcTime !== "") { - await t.expect(Selector(".input-utc-time input").value).eql(utcTime); - } if (altitude !== "") { await t.expect(Selector(".input-altitude input").value).eql(altitude); } diff --git a/frontend/tests/page-model/photo-views.js b/frontend/tests/page-model/photo-views.js index 3c3596ca5..cc59fd39c 100644 --- a/frontend/tests/page-model/photo-views.js +++ b/frontend/tests/page-model/photo-views.js @@ -70,8 +70,13 @@ export default class Page { } } - async triggerListViewActions(nth, action) { - await t.click(Selector(`td button.input-` + action).nth(nth)); + async triggerListViewActions(mode, uidOrnth, action) { + if (mode === "nth") { + await t.click(Selector(`td button.input-` + action).nth(uidOrnth)); + } else if (mode === "uid") { + await t.click(Selector(`td button.input-` + action).withAttribute("data-uid", uidOrnth)); + } + } async checkListViewActionAvailability(action, disabled) { diff --git a/frontend/tests/page-model/photo.js b/frontend/tests/page-model/photo.js index a81f3ee80..3c5f8a083 100644 --- a/frontend/tests/page-model/photo.js +++ b/frontend/tests/page-model/photo.js @@ -17,10 +17,10 @@ export default class Page { async getPhotoCount(type) { if (type === "all") { - const PhotoCount = await Selector("div.is-photo", { timeout: 5000 }).count; + const PhotoCount = await Selector("div.is-photo", { timeout: 2000 }).count; return PhotoCount; } else { - const PhotoCount = await Selector("div.type-" + type, { timeout: 5000 }).count; + const PhotoCount = await Selector("div.type-" + type, { timeout: 2000 }).count; return PhotoCount; } } @@ -45,9 +45,9 @@ export default class Page { async checkPhotoVisibility(uid, visible) { if (visible) { - await t.expect(Selector("div.is-photo").withAttribute("data-uid", uid).visible).ok(); + await t.expect(Selector("div.is-photo").withAttribute("data-uid", uid).exists).ok(); } else { - await t.expect(Selector("div.is-photo").withAttribute("data-uid", uid).visible).notOk(); + await t.expect(Selector("div.is-photo").withAttribute("data-uid", uid).exists).notOk(); } } } diff --git a/frontend/tests/page-model/photoviewer.js b/frontend/tests/page-model/photoviewer.js index ba96f6d9c..c94cd80ba 100644 --- a/frontend/tests/page-model/photoviewer.js +++ b/frontend/tests/page-model/photoviewer.js @@ -30,15 +30,18 @@ export default class Page { async checkPhotoViewerActionAvailability(action, visible) { if (visible) { - await t.expect(Selector("div.pswp__top-bar button.action-" + action).visible).ok(); + await t.expect(Selector("button.pswp__button.action-" + action).visible).ok(); } else { - await t.expect(Selector("div.pswp__top-bar button.action-" + action).visible).notOk(); + await t.expect(Selector("button.pswp__button.action-" + action).visible).notOk(); } } - //trigger fullscreen menu action (edit/like/close) --fullscreen async triggerPhotoViewerAction(action) { - await t.click(Selector("div.pswp__top-bar button.action-" + action)); + await t.click(Selector("button.pswp__button.action-" + action)); + if (action === "close") { + if (await Selector("button.pswp__button.action-" + action).visible) { + await t.click(Selector("button.pswp__button.action-" + action)); + } + } } - } diff --git a/frontend/tests/page-model/settings.js b/frontend/tests/page-model/settings.js new file mode 100644 index 000000000..bb44fa48c --- /dev/null +++ b/frontend/tests/page-model/settings.js @@ -0,0 +1,23 @@ +import { Selector, t } from "testcafe"; + +export default class Page { + constructor() { + this.languageInput = Selector(".input-language input", { timeout: 5000 }); + this.uploadCheckbox = Selector(".input-upload input", { timeout: 5000 }); + this.downloadCheckbox = Selector(".input-download input", { timeout: 5000 }); + this.importCheckbox = Selector(".input-import input", { timeout: 5000 }); + this.archiveCheckbox = Selector(".input-archive input", { timeout: 5000 }); + this.editCheckbox = Selector(".input-edit input", { timeout: 5000 }); + this.filesCheckbox = Selector(".input-files input", { timeout: 5000 }); + this.momentsCheckbox = Selector(".input-moments input", { timeout: 5000 }); + this.labelsCheckbox = Selector(".input-labels input", { timeout: 5000 }); + this.logsCheckbox = Selector(".input-logs input", { timeout: 5000 }); + this.shareCheckbox = Selector(".input-share input", { timeout: 5000 }); + this.placesCheckbox = Selector(".input-places input", { timeout: 5000 }); + this.privateCheckbox = Selector(".input-private input", { timeout: 5000 }); + this.peopleCheckbox = Selector(".input-people input", { timeout: 5000 }); + this.deleteCheckbox = Selector(".input-delete input", { timeout: 5000 }); + + this.reviewCheckbox = Selector(".input-review input", { timeout: 5000 }); + } +}