TagSpaces is an offline, open source, document manager with tagging support
fix: improving e2e tests
Ilian Sapundshievbdc8ee228021
diff --git a/tests/e2e/fulltext-lite-pro.pw.e2e.js b/tests/e2e/fulltext-lite-pro.pw.e2e.jsindex 1668f40c7..6cf1c4670 100644--- a/tests/e2e/fulltext-lite-pro.pw.e2e.js+++ b/tests/e2e/fulltext-lite-pro.pw.e2e.js@@ -11,7 +11,10 @@** Search vocabulary (taken from the existing testdata files):* - "Lorem" — present in sample.txt- * - "yahoo" — present in sample.md (link to yahoo.com)+ * - "embedding" — present in sample.md prose (headings). NOTE: it must be+ * body/heading text, not a link URL — extractMarkdownText() indexes only+ * marked "text" tokens and drops link/emphasis/code tokens, so a term+ * that lives only inside a markdown link href is never in the index.* - "Klasirane" — present ONLY in sample.pdf (extracted via pdfjs)*/import { expect, test } from './fixtures';@@ -32,7 +35,7 @@ import { searchEngine } from './search.helpers';import { clearDataStorage } from './welcome.helpers';const pdfSearchTerm = 'Klasirane';-const mdSearchTerm = 'yahoo';+const mdSearchTerm = 'embedding';const txtSearchTerm = 'Lorem';test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {diff --git a/tests/e2e/hook.js b/tests/e2e/hook.jsindex 521a7fe36..1a257b062 100644--- a/tests/e2e/hook.js+++ b/tests/e2e/hook.js@@ -334,12 +334,6 @@ export async function testDataRefresh(isS3, testDataDir) {//console.log('testDataDir:'+testDataDir);await refreshS3testData(testDataDir);} else {- await fse.rm(testDataDir, {- recursive: true,- force: true,- maxRetries: 5, // retry on EBUSY/EMFILE/ENFILE- retryDelay: 100, // optional back‑off in ms- });const src = pathLib.join(__dirname,'..',@@ -347,16 +341,39 @@ export async function testDataRefresh(isS3, testDataDir) {'file-structure','supported-filestypes',);- // Use Node's native recursive copy (not fs-extra's), since fs-extra's- // copy() does a non-recursive fs.mkdir(dest) per directory and races with- // the running Electron app's indexer recreating the .ts metafolder between- // our rm and copy — producing intermittent EEXIST mkdir '.ts' failures.- // fs.cp with { recursive: true, force: true } is idempotent w.r.t. existing- // destination dirs and overwrites files, so the race is harmless.- await fs.promises.cp(src, testDataDir, {- recursive: true,- force: true,- });+ // The running Electron app's indexer/watcher keeps recreating directories+ // (testDataDir or its .ts metafolder) between our rm and copy. Node's+ // fs.cp is NOT actually race-safe here: its internal recursive mkdir+ // throws EEXIST/ENOTEMPTY when a destination dir reappears mid-copy+ // (despite { force: true }, which only governs file overwrite). When the+ // app is actively indexing, this fails every Playwright retry too — so we+ // retry the whole rm+cp sequence (a fresh rm re-closes the race window)+ // and only rethrow once attempts are exhausted.+ const transientCodes = ['EEXIST', 'ENOTEMPTY', 'EBUSY', 'EPERM'];+ const maxAttempts = 6;+ for (let attempt = 1; ; attempt++) {+ try {+ await fse.rm(testDataDir, {+ recursive: true,+ force: true,+ maxRetries: 5, // retry on EBUSY/EMFILE/ENFILE+ retryDelay: 100, // optional back‑off in ms+ });+ await fs.promises.cp(src, testDataDir, {+ recursive: true,+ force: true,+ });+ break;+ } catch (err) {+ if (+ attempt >= maxAttempts ||+ !transientCodes.includes(err && err.code)+ ) {+ throw err;+ }+ await new Promise((resolve) => setTimeout(resolve, 150 * attempt));+ }+ }}}diff --git a/tests/e2e/viewer-audiovideo.pw.e2e.js b/tests/e2e/viewer-audiovideo.pw.e2e.jsindex 2b9b746f9..2ca4f667d 100644--- a/tests/e2e/viewer-audiovideo.pw.e2e.js+++ b/tests/e2e/viewer-audiovideo.pw.e2e.js@@ -50,17 +50,16 @@ test.describe('TST59 - Media player', () => {await expectMediaPlay(false);});- test('TST5902 - Play ogv file [web,s3,electron]', async ({- isWin,- isWeb,- }) => {- if (!isWin) {- await openContextEntryMenu(- getGridFileSelector('sample.ogv'),- 'fileMenuOpenFile',- );- await expectMediaPlay(!isWeb);- }+ test('TST5902 - Play webm file [web,s3,electron]', async ({ isWeb }) => {+ // Smoke-test the media-player extension with WebM (VP8/VP9): it is+ // royalty-free and decodable by stock Chromium/Electron on every+ // platform. Theora/OGV was dropped from Chromium in M124, so an .ogv+ // file yields video.duration = NaN here and can no longer be played.+ await openContextEntryMenu(+ getGridFileSelector('sample.webm'),+ 'fileMenuOpenFile',+ );+ await expectMediaPlay(!isWeb);});test('TST5903 - Open and close about dialog [web,s3,electron]', async () => {