Skip to content

Commit

Permalink
test: do not use indexedDB in cypress environment due to chrome bug (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 authored Apr 13, 2024
1 parent 5c7c44c commit 48a7679
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions packages/frontend/src/scripts/idb-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 48a7679

Please sign in to comment.