High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
test(e2e): fix flakiness: optimize resetDatabase with TRUNCATE and fix selectDay selector scoping (#26776)
Min Idzelis422111d26e0c
diff --git a/e2e/src/ui/specs/timeline/utils.ts b/e2e/src/ui/specs/timeline/utils.tsindex d3e4e5f7ec..b7003295cf 100644--- a/e2e/src/ui/specs/timeline/utils.ts+++ b/e2e/src/ui/specs/timeline/utils.ts@@ -215,8 +215,9 @@ export const pageUtils = {await page.getByText('Confirm').click();},async selectDay(page: Page, day: string) {- await page.getByTitle(day).hover();- await page.locator('[data-group] .w-8').click();+ const section = page.getByTitle(day).locator('xpath=ancestor::section[@data-group]');+ await section.hover();+ await section.locator('.w-8').click();},async pauseTestDebug() {console.log('NOTE: pausing test indefinately for debug');diff --git a/e2e/src/utils.ts b/e2e/src/utils.tsindex 7307f87854..a5567f0778 100644--- a/e2e/src/utils.ts+++ b/e2e/src/utils.ts@@ -177,40 +177,51 @@ export const utils = {},resetDatabase: async (tables?: string[]) => {- try {- client = await utils.connectDatabase();-- tables = tables || [- // TODO e2e test for deleting a stack, since it is quite complex- 'stack',- 'library',- 'shared_link',- 'person',- 'album',- 'asset',- 'asset_face',- 'activity',- 'api_key',- 'session',- 'user',- 'system_metadata',- 'tag',- ];-- const sql: string[] = [];-- for (const table of tables) {- if (table === 'system_metadata') {- sql.push(`DELETE FROM "system_metadata" where "key" NOT IN ('reverse-geocoding-state', 'system-flags');`);- } else {- sql.push(`DELETE FROM "${table}" CASCADE;`);+ client = await utils.connectDatabase();++ tables = tables || [+ // TODO e2e test for deleting a stack, since it is quite complex+ 'stack',+ 'library',+ 'shared_link',+ 'person',+ 'album',+ 'asset',+ 'asset_face',+ 'activity',+ 'api_key',+ 'session',+ 'user',+ 'system_metadata',+ 'tag',+ ];++ const truncateTables = tables.filter((table) => table !== 'system_metadata');+ const sql: string[] = [];++ if (truncateTables.length > 0) {+ sql.push(`TRUNCATE "${truncateTables.join('", "')}" CASCADE;`);+ }++ if (tables.includes('system_metadata')) {+ sql.push(`DELETE FROM "system_metadata" where "key" NOT IN ('reverse-geocoding-state', 'system-flags');`);+ }++ const query = sql.join('\n');+ const maxRetries = 3;++ for (let attempt = 1; attempt <= maxRetries; attempt++) {+ try {+ await client.query(query);+ return;+ } catch (error: any) {+ if (error?.code === '40P01' && attempt < maxRetries) {+ await new Promise((resolve) => setTimeout(resolve, 250 * attempt));+ continue;}+ console.error('Failed to reset database', error);+ throw error;}-- await client.query(sql.join('\n'));- } catch (error) {- console.error('Failed to reset database', error);- throw error;}},