diff --git a/tests/folders.spec.ts b/tests/folders.spec.ts index b88c6f9..47035a2 100644 --- a/tests/folders.spec.ts +++ b/tests/folders.spec.ts @@ -7,6 +7,7 @@ import { dragAndDrop, expectDocumentListed, expectNoDocumentLink, + escapeRegExp, } from './helpers'; test.describe('Document folders and hint persistence', () => { @@ -16,7 +17,7 @@ test.describe('Document folders and hint persistence', () => { // Utility to get the draggable tile for a given filename (by link). const rowFor = (page: Page, fileName: string) => { - const link = page.getByRole('link', { name: new RegExp(fileName, 'i') }).first(); + const link = page.getByRole('link', { name: new RegExp(escapeRegExp(fileName), 'i') }).first(); // The drag source is the tile container ancestor, marked with data-doc-tile. return link.locator('xpath=ancestor::*[@data-doc-tile][1]'); }; diff --git a/tests/helpers.ts b/tests/helpers.ts index 617227a..9d280f7 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -4,7 +4,7 @@ import { createHash } from 'crypto'; const DIR = './tests/files/'; // Small util to safely use filenames inside regex patterns -function escapeRegExp(input: string) { +export function escapeRegExp(input: string) { return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); }