test: do not use indexedDB in cypress environment due to chrome bug (#13709)

This commit is contained in:
anatawa12 2024-04-14 08:08:26 +09:00 committed by GitHub
parent 5c7c44c9eb
commit 48a7679b8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -30,9 +30,13 @@ Cypress.Commands.add('visitHome', () => {
}) })
Cypress.Commands.add('resetState', () => { 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 => { cy.window().then(win => {
win.indexedDB.deleteDatabase('keyval-store'); win.indexedDB.deleteDatabase('keyval-store');
}); });
*/
cy.request('POST', '/api/reset-db', {}).as('reset'); cy.request('POST', '/api/reset-db', {}).as('reset');
cy.get('@reset').its('status').should('equal', 204); cy.get('@reset').its('status').should('equal', 204);
cy.reload(true); cy.reload(true);

View File

@ -15,6 +15,16 @@ const fallbackName = (key: string) => `idbfallback::${key}`;
let idbAvailable = typeof window !== 'undefined' ? !!(window.indexedDB && window.indexedDB.open) : true; 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) { if (idbAvailable) {
await iset('idb-test', 'test') await iset('idb-test', 'test')
.catch(err => { .catch(err => {