From 4ece10b5af43338c5dcf793763a60cb26e8cda5c Mon Sep 17 00:00:00 2001 From: graciousgrey Date: Thu, 21 Sep 2023 20:00:33 +0200 Subject: [PATCH] Tests: Improve acceptance tests --- frontend/testcaferc.json | 1 + .../acceptance-auth/settings/general.js | 8 +++---- .../photos-archive-private.js | 2 +- .../acceptance/acceptance-public/places.js | 23 +++++++++++++------ .../tests/acceptance/page-model/places.js | 3 +++ 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/frontend/testcaferc.json b/frontend/testcaferc.json index b1d6a7ad3..0404fa858 100644 --- a/frontend/testcaferc.json +++ b/frontend/testcaferc.json @@ -3,6 +3,7 @@ "quarantineMode": false, "selectorTimeout": 5000, "hostname": "localhost", + "disableNativeAutomation": "true", "screenshots": { "path": "tests/acceptance/screenshots", "takeOnFails": true diff --git a/frontend/tests/acceptance/acceptance-auth/settings/general.js b/frontend/tests/acceptance/acceptance-auth/settings/general.js index 3c66b03ee..5d6a5cb83 100644 --- a/frontend/tests/acceptance/acceptance-auth/settings/general.js +++ b/frontend/tests/acceptance/acceptance-auth/settings/general.js @@ -30,14 +30,14 @@ test.meta("testID", "settings-general-001").meta({ type: "short", mode: "auth" } "Common: Disable delete", async (t) => { await menu.openPage("archive"); - await toolbar.checkToolbarActionAvailability("sweep", true); + await toolbar.checkToolbarActionAvailability("delete-all", true); await photo.triggerHoverAction("nth", 0, "select"); await contextmenu.checkContextMenuActionAvailability("delete", true); await contextmenu.clearSelection(); await menu.openPage("settings"); await t.click(settings.deleteCheckbox); await menu.openPage("archive"); - await toolbar.checkToolbarActionAvailability("sweep", false); + await toolbar.checkToolbarActionAvailability("delete-all", false); await photo.triggerHoverAction("nth", 0, "select"); @@ -304,7 +304,7 @@ test.meta("testID", "settings-general-005").meta({ type: "short", mode: "auth" } await photo.checkPhotoVisibility("pqnah1k2frui6p63", false); await t.navigateTo("/library/archive"); - await toolbar.checkToolbarActionAvailability("sweep", true); + await toolbar.checkToolbarActionAvailability("delete-all", true); await menu.openPage("settings"); await t @@ -345,7 +345,7 @@ test.meta("testID", "settings-general-005").meta({ type: "short", mode: "auth" } await photo.checkPhotoVisibility("pqnah1k2frui6p63", true); await t.navigateTo("/library/archive"); - await toolbar.checkToolbarActionAvailability("sweep", false); + await toolbar.checkToolbarActionAvailability("delete-all", false); await menu.openPage("settings"); await t diff --git a/frontend/tests/acceptance/acceptance-public/photos-archive-private.js b/frontend/tests/acceptance/acceptance-public/photos-archive-private.js index cc48abba0..f04dde19c 100644 --- a/frontend/tests/acceptance/acceptance-public/photos-archive-private.js +++ b/frontend/tests/acceptance/acceptance-public/photos-archive-private.js @@ -538,7 +538,7 @@ test.meta("testID", "photos-archive-private-005").meta({ type: "short", mode: "p "Common: Check delete all dialog", async (t) => { await menu.openPage("archive"); - await toolbar.triggerToolbarAction("sweep"); + await toolbar.triggerToolbarAction("delete-all"); await t .expect( Selector("div").withText("Are you sure you want to delete all archived pictures?").visible diff --git a/frontend/tests/acceptance/acceptance-public/places.js b/frontend/tests/acceptance/acceptance-public/places.js index 8b249d18e..ccbf3fa94 100644 --- a/frontend/tests/acceptance/acceptance-public/places.js +++ b/frontend/tests/acceptance/acceptance-public/places.js @@ -4,6 +4,7 @@ import testcafeconfig from "../../testcafeconfig.json"; import Menu from "../page-model/menu"; import Places from "../page-model/places"; import Photo from "../page-model/photo"; +import Toolbar from "../page-model/toolbar"; const getLocation = ClientFunction(() => document.location.href); @@ -12,6 +13,7 @@ fixture`Search and open photo from places`.page`${testcafeconfig.url}`; const menu = new Menu(); const places = new Places(); const photo = new Photo(); +const toolbar = new Toolbar(); test.meta("testID", "places-001").meta({ mode: "public" })("Common: Test places", async (t) => { await menu.openPage("places"); @@ -39,11 +41,12 @@ test.meta("testID", "places-001").meta({ mode: "public" })("Common: Test places" const clusterCountAll = await Selector("div.cluster-marker").count; await places.search("canada"); - await t.wait(8000); - await t.click(Selector("button.maplibregl-ctrl-zoom-out")); - await t.click(Selector("button.maplibregl-ctrl-zoom-out")); - await t.click(Selector("button.maplibregl-ctrl-zoom-out")); - await t.wait(8000); + + await t + .click(places.zoomOut) + .click(places.zoomOut) + .click(places.zoomOut) + .click(places.zoomOut); const clusterCountCanada = await Selector("div.cluster-marker").count; @@ -54,7 +57,13 @@ test.meta("testID", "places-001").meta({ mode: "public" })("Common: Test places" await t.expect(await photo.getPhotoCount("all")).eql(2); await t.expect(Selector('div[title="Cape / Bowen Island / 2019"]').visible).ok(); - await t.click(Selector('div[title="Cape / Bowen Island / 2019"]')); + await t.click(places.openClusterInSearch); - await t.expect(Selector("#photo-viewer").visible).ok(); + await t.expect(Selector('div[title="Cape / Bowen Island / 2019"]').visible).ok(); + await t.expect(await photo.getPhotoCount("all")).eql(2); + await t.expect(toolbar.search1.value).eql("canada"); + + await t.click(places.clearLocation); + await t.expect(await photo.getPhotoCount("all")).gte(2); + await t.expect(toolbar.search1.value).eql(""); }); diff --git a/frontend/tests/acceptance/page-model/places.js b/frontend/tests/acceptance/page-model/places.js index 6f73db888..e1aaecfe6 100644 --- a/frontend/tests/acceptance/page-model/places.js +++ b/frontend/tests/acceptance/page-model/places.js @@ -3,6 +3,9 @@ import { Selector, t } from "testcafe"; export default class Page { constructor() { this.placesSearch = Selector('input[aria-label="Search"]'); + this.openClusterInSearch = Selector("button.action-browse"); + this.clearLocation = Selector("button.action-clear-location"); + this.zoomOut = Selector("button.maplibregl-ctrl-zoom-out"); } async search(term) {