TagSpaces is an offline, open source, document manager with tagging support
chore: added e2e test for the calendar and folderviz perspectives
Ilian Sapundshieve2e7a78103b6
diff --git a/tests/e2e/location.helpers.js b/tests/e2e/location.helpers.jsindex 75584526e..aee10c52a 100644--- a/tests/e2e/location.helpers.js+++ b/tests/e2e/location.helpers.js@@ -19,6 +19,7 @@ export async function createS3Location(locationName,isDefault = false,fullTextIndexing = false,+ isReadOnly = false,) {const lastLocationTID = await getPwLocationTid(-1);// Check if location not exist (from extconfig.js)@@ -28,16 +29,31 @@ export async function createS3Location(await clickOn('[data-tid=locationTypeTID]');await clickOn('[data-tid=cloudLocationTID]');- await setInputValue('[data-tid=locationName] input', locationName || 'Test Location' + new Date().getTime(),);- await setInputValue('[data-tid=locationPath] input', locationPath);+ await setInputValue('[data-tid=locationName] input', locationName || 'Test Location' + new Date().getTime(),);+ await setInputValue('[data-tid=locationPath] input', locationPath);await setInputValue('[data-tid=accessKeyId] input', 'test');- await setInputValue('[data-tid=secretAccessKey] input', 'test');- await setInputValue('[data-tid=bucketName] input', 'supported-filestypes');- await setInputValue('[data-tid=endpointURL] input', 'http://localhost:4569');-- if (isDefault) {+ await setInputValue('[data-tid=secretAccessKey] input', 'test');+ await setInputValue('[data-tid=bucketName] input', 'supported-filestypes');+ await setInputValue('[data-tid=endpointURL] input', 'http://localhost:4569');++ // Expand the Advanced accordion if either isDefault or isReadOnly+ // needs it. (isDefault itself lives in the always-expanded first+ // accordion — the original code still clicked Advanced here, so we+ // preserve that behavior for existing callers.) changeReadOnlyMode+ // is inside the Advanced accordion and MUI animates the expansion,+ // so wait for its input to become visible before checking.+ if (isDefault || isReadOnly) {await clickOn('[data-tid=switchAdvancedModeTID]');- await global.client.check('[data-tid=locationIsDefault] input');+ if (isDefault) {+ await global.client.check('[data-tid=locationIsDefault] input');+ }+ if (isReadOnly) {+ await global.client.waitForSelector(+ '[data-tid=changeReadOnlyMode] input',+ { state: 'visible', timeout: 5000 },+ );+ await global.client.check('[data-tid=changeReadOnlyMode] input');+ }}if (fullTextIndexing) {await global.client.check('[data-tid=changeFullTextIndex] input');diff --git a/tests/e2e/perspective-calendar.pw.e2e.js b/tests/e2e/perspective-calendar.pw.e2e.jsnew file mode 100644index 000000000..6caacbbd8--- /dev/null+++ b/tests/e2e/perspective-calendar.pw.e2e.js@@ -0,0 +1,129 @@+/*+ * Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.+ */+import { test, expect } from './fixtures';+import {+ createS3Location,+ defaultLocationName,+} from './location.helpers';+import {+ clickOn,+ expectElementExist,+ getGridFileSelector,+} from './general.helpers';+import { startTestingApp, stopApp } from './hook';+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';++const readOnlyLocationName = 'readonly-calendar-s3';++test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {+ if (isS3) {+ await startTestingApp({ isWeb, isS3, webServerPort, testInfo });+ await closeWelcomePlaywright();+ } else {+ await startTestingApp(+ { isWeb, isS3, webServerPort, testInfo },+ 'extconfig.js',+ );+ }+});++test.afterAll(async () => {+ await stopApp();+});++test.afterEach(async () => {+ await clearDataStorage();+});++test.describe('TST53 - Perspective Calendar', () => {+ test.describe('writable location', () => {+ test.beforeEach(async ({ isS3 }) => {+ // Calendar is Pro-only and only exercised against S3 here.+ test.skip(!isS3, 'Calendar e2e tests are S3-only for now');+ await createS3Location('', defaultLocationName, true);+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ await expectElementExist(+ getGridFileSelector('empty_folder'),+ true,+ 15000,+ );+ await clickOn('[data-tid=openCalendarPerspective]');+ // Calendar's toolbar currently reuses the FolderViz toolbar tid —+ // see calendar/MainToolbar.tsx. This test guards that the toolbar+ // mounts at all when the perspective opens.+ await expectElementExist(+ '[data-tid=perspectiveFolderVizToolbar]',+ true,+ 10000,+ );+ });++ test('TST5301 - toolbar renders with the calendar view switches [s3,electron,_pro]', async () => {+ await expectElementExist(+ '[data-tid=perspectiveCalendarSwitchToYearsView]',+ true,+ 4000,+ );+ await expectElementExist(+ '[data-tid=perspectiveCalendarSwitchToMonthView]',+ true,+ 4000,+ );+ const indexButton = global.client.locator(+ '[data-tid=perspectiveCalendarIndexLocation]',+ );+ await expect(indexButton).toBeEnabled();+ });+ });++ test.describe('read-only location', () => {+ test.beforeEach(async ({ isS3 }) => {+ test.skip(!isS3, 'Calendar e2e tests are S3-only for now');+ // The preceding writable-location describe leaves the app in the+ // Calendar perspective with the default location open. When the first+ // readonly test then creates its location via the dialog, the+ // post-confirm navigation to the new location leaves the main content+ // blank and the new location's sidebar TID isn't discoverable in time.+ // Reload to guarantee a clean slate — same fix as FolderViz e2e.+ await global.client.reload();+ await closeWelcomePlaywright();+ await createS3Location('', readOnlyLocationName, true, false, true);+ await clickOn('[data-tid=location_' + readOnlyLocationName + ']');+ await expectElementExist(+ getGridFileSelector('empty_folder'),+ true,+ 15000,+ );+ await clickOn('[data-tid=openCalendarPerspective]');+ await expectElementExist(+ '[data-tid=perspectiveFolderVizToolbar]',+ true,+ 10000,+ );+ });++ test('TST5310 - index refresh button is disabled on readonly [s3,electron,_pro]', async () => {+ // Regression guard for the Calendar MainToolbar fix: the index+ // refresh button should be greyed out on readonly locations.+ const indexButton = global.client.locator(+ '[data-tid=perspectiveCalendarIndexLocation]',+ );+ await expect(indexButton).toBeDisabled();+ });++ test('TST5311 - switching calendar views does NOT show "read only Location" toast [s3,electron,_pro]', async () => {+ // Regression guard for the saveSettings-on-readonly fix in+ // PerspectiveSettingsContextProvider — switching calendar views+ // should NOT attempt a disk write and must not surface an error.+ await clickOn('[data-tid=perspectiveCalendarSwitchToYearsView]');+ await clickOn('[data-tid=perspectiveCalendarSwitchToMonthView]');+ await global.client.waitForTimeout(1000);+ const readOnlyToast = global.client.getByText(+ 'read only Location',+ { exact: false },+ );+ await expect(readOnlyToast).toHaveCount(0);+ });+ });+});diff --git a/tests/e2e/perspective-folderviz.pw.e2e.js b/tests/e2e/perspective-folderviz.pw.e2e.jsnew file mode 100644index 000000000..3d052e215--- /dev/null+++ b/tests/e2e/perspective-folderviz.pw.e2e.js@@ -0,0 +1,185 @@+/*+ * Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.+ */+import { test, expect } from './fixtures';+import {+ createS3Location,+ defaultLocationName,+} from './location.helpers';+import {+ clickOn,+ expectElementExist,+ getGridFileSelector,+} from './general.helpers';+import { startTestingApp, stopApp } from './hook';+import { clearDataStorage, closeWelcomePlaywright } from './welcome.helpers';++const readOnlyLocationName = 'readonly-folderviz-s3';++test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {+ if (isS3) {+ await startTestingApp({ isWeb, isS3, webServerPort, testInfo });+ await closeWelcomePlaywright();+ } else {+ await startTestingApp(+ { isWeb, isS3, webServerPort, testInfo },+ 'extconfig.js',+ );+ }+});++test.afterAll(async () => {+ await stopApp();+});++test.afterEach(async () => {+ await clearDataStorage();+});++test.describe('TST52 - Perspective FolderViz', () => {+ test.describe('writable location', () => {+ test.beforeEach(async ({ isS3 }) => {+ // FolderViz is Pro-only and today only exercised against S3 in tests.+ test.skip(!isS3, 'FolderViz e2e tests are S3-only for now');+ await createS3Location('', defaultLocationName, true);+ await clickOn('[data-tid=location_' + defaultLocationName + ']');+ await expectElementExist(+ getGridFileSelector('empty_folder'),+ true,+ 15000,+ );+ await clickOn('[data-tid=openFolderVizPerspective]');+ await expectElementExist(+ '[data-tid=perspectiveFolderVizToolbar]',+ true,+ 10000,+ );+ });++ test('TST5201 - toolbar renders with all viz switches [s3,electron,_pro]', async () => {+ // Every viz-switch button is present, plus the index-refresh button+ // is ENABLED (writable location).+ await expectElementExist(+ '[data-tid=perspectiveFolderVizSwitchToRadialHorizontalTree]',+ true,+ 4000,+ );+ await expectElementExist(+ '[data-tid=perspectiveFolderVizSwitchToRadialTreeViz]',+ true,+ 4000,+ );+ await expectElementExist(+ '[data-tid=perspectiveFolderVizSwitchToTagsGraph]',+ true,+ 4000,+ );+ await expectElementExist(+ '[data-tid=perspectiveFolderVizSwitchToLinkGraph]',+ true,+ 4000,+ );+ await expectElementExist(+ '[data-tid=perspectiveFolderVizSwitchToRadialTreemap]',+ true,+ 4000,+ );+ const indexButton = global.client.locator(+ '[data-tid=perspectiveFolderVizUpdateLocationIndex]',+ );+ await expect(indexButton).toBeEnabled();+ });++ test('TST5202 - switching viz types does not raise an error toast [s3,electron,_pro]', async () => {+ // Regression guard for the saveSettings write-on-viz-switch path.+ // On a writable location nothing should surface as an error.+ await clickOn(+ '[data-tid=perspectiveFolderVizSwitchToRadialTreeViz]',+ );+ await clickOn('[data-tid=perspectiveFolderVizSwitchToRadialTreemap]');+ await clickOn(+ '[data-tid=perspectiveFolderVizSwitchToRadialHorizontalTree]',+ );+ // No "read only Location" toast on a writable location.+ const readOnlyToast = global.client.getByText(+ 'read only Location',+ { exact: false },+ );+ await expect(readOnlyToast).toHaveCount(0);+ });+ });++ test.describe('read-only location', () => {+ test.beforeEach(async ({ isS3 }) => {+ test.skip(!isS3, 'FolderViz e2e tests are S3-only for now');+ // The preceding writable-location describe leaves the app in FolderViz+ // perspective with the default location open. When the first read-only+ // test then creates its location via the dialog, the post-confirm+ // navigation to the new location leaves the main content blank+ // (fresh readonly + Pro side effects of opening a location that was+ // just dispatched to the store). Reload to guarantee a clean slate.+ await global.client.reload();+ await closeWelcomePlaywright();+ // Fresh name so createS3Location actually runs (its guard skips+ // creation when the last known location matches by TID).+ await createS3Location('', readOnlyLocationName, true, false, true);+ await clickOn('[data-tid=location_' + readOnlyLocationName + ']');+ await expectElementExist(+ getGridFileSelector('empty_folder'),+ true,+ 15000,+ );+ await clickOn('[data-tid=openFolderVizPerspective]');+ await expectElementExist(+ '[data-tid=perspectiveFolderVizToolbar]',+ true,+ 10000,+ );+ });++ test('TST5210 - index refresh button is disabled on readonly [s3,electron,_pro]', async () => {+ // Regression guard for the toolbar-disable fix in FolderViz+ // MainToolbar — the "Refresh Location Index" button should be+ // greyed out on readonly locations because a re-index can't persist.+ const indexButton = global.client.locator(+ '[data-tid=perspectiveFolderVizUpdateLocationIndex]',+ );+ await expect(indexButton).toBeDisabled();+ });++ test('TST5211 - switching viz types does NOT show "read only Location" toast [s3,electron,_pro]', async () => {+ // Regression guard for the saveSettings-on-readonly fix in+ // PerspectiveSettingsContextProvider: switching the viz type+ // updates in-memory settings and no longer attempts a disk write,+ // so no error toast should surface.+ await clickOn(+ '[data-tid=perspectiveFolderVizSwitchToRadialTreeViz]',+ );+ await clickOn('[data-tid=perspectiveFolderVizSwitchToRadialTreemap]');+ await clickOn('[data-tid=perspectiveFolderVizSwitchToTagsGraph]');+ // Give any toast a chance to surface, then assert it did not.+ await global.client.waitForTimeout(1000);+ const readOnlyToast = global.client.getByText(+ 'read only Location',+ { exact: false },+ );+ await expect(readOnlyToast).toHaveCount(0);+ });++ test('TST5212 - links graph viz does NOT prompt to re-index on readonly [s3,electron,_pro]', async () => {+ // Regression guard for the MainToolbar `needsLinksGraphIndex` fix:+ // on readonly, switching to links graph used to show a confirm+ // dialog asking to index the location (which would then fail).+ await clickOn('[data-tid=perspectiveFolderVizSwitchToLinkGraph]');+ await global.client.waitForTimeout(1000);+ // The confirm dialog's dedicated confirm button would be+ // "confirmLinksGraphIndexTID" — asserting absence is the cleanest+ // check that the dialog did not appear.+ await expectElementExist(+ '[data-tid=confirmLinksGraphIndexTID]',+ false,+ 500,+ );+ });+ });+});