From 48a7679b8a8b3df80d7f90ac6f4a852f47a8df22 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 14 Apr 2024 08:08:26 +0900 Subject: [PATCH] test: do not use indexedDB in cypress environment due to chrome bug (#13709) --- cypress/support/commands.ts | 4 ++++ packages/frontend/src/scripts/idb-proxy.ts | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index c2d92e1663..281f2e6ccd 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -30,9 +30,13 @@ Cypress.Commands.add('visitHome', () => { }) Cypress.Commands.add('resetState', () => { + // iframe.contentWindow.indexedDB.deleteDatabase() がchromeのバグで使用できないため、indexedDBを無効化している。 + // see https://github.com/misskey-dev/misskey/issues/13605#issuecomment-2053652123 + /* cy.window().then(win => { win.indexedDB.deleteDatabase('keyval-store'); }); + */ cy.request('POST', '/api/reset-db', {}).as('reset'); cy.get('@reset').its('status').should('equal', 204); cy.reload(true); diff --git a/packages/frontend/src/scripts/idb-proxy.ts b/packages/frontend/src/scripts/idb-proxy.ts index 1ca0990ba9..6b511f2a5f 100644 --- a/packages/frontend/src/scripts/idb-proxy.ts +++ b/packages/frontend/src/scripts/idb-proxy.ts @@ -15,6 +15,16 @@ const fallbackName = (key: string) => `idbfallback::${key}`; let idbAvailable = typeof window !== 'undefined' ? !!(window.indexedDB && window.indexedDB.open) : true; +// iframe.contentWindow.indexedDB.deleteDatabase() がchromeのバグで使用できないため、indexedDBを無効化している。 +// バグが治って再度有効化するのであれば、cypressのコマンド内のコメントアウトを外すこと +// see https://github.com/misskey-dev/misskey/issues/13605#issuecomment-2053652123 +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-expect-error +if (window.Cypress) { + idbAvailable = false; + console.log('Cypress detected. It will use localStorage.'); +} + if (idbAvailable) { await iset('idb-test', 'test') .catch(err => {