nicolium: do not run migrations in test env

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-03 12:07:57 +01:00
parent f6e05a278a
commit d847ac276c
2 changed files with 70 additions and 4 deletions

View File

@ -8,7 +8,7 @@
import localforage from 'localforage';
import trim from 'lodash/trim';
import { FE_SUBDIRECTORY } from '@/build-config';
import { FE_SUBDIRECTORY, NODE_ENV } from '@/build-config';
// synchronous localStorage migrations
@ -48,8 +48,12 @@ const migratePushNotificationSettings = () => {
}
};
migrateAuthStorage();
migratePushNotificationSettings();
const shouldMigrateLegacyData = NODE_ENV !== 'test';
if (shouldMigrateLegacyData) {
migrateAuthStorage();
migratePushNotificationSettings();
}
// async migrations
@ -90,6 +94,6 @@ const migrateIndexedDB = async () => {
}
};
const migrationComplete = migrateIndexedDB();
const migrationComplete = shouldMigrateLegacyData ? migrateIndexedDB() : Promise.resolve();
export { migrationComplete };

View File

@ -0,0 +1,62 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { IntlProvider } from 'react-intl';
import { describe, expect, it, vi } from 'vitest';
import Toast from '@/components/ui/toast';
import type { Toast as RHToast } from 'react-hot-toast';
vi.mock('@/components/ui/icon', () => ({
default: (props: { className?: string }) => (
<span data-testid='icon' className={props.className} />
),
}));
const createToast = (id: string): RHToast =>
({
id,
visible: true,
}) as RHToast;
describe('Toast accessibility', () => {
it('uses polite status live-region semantics for non-error toasts', () => {
render(
<IntlProvider locale='en'>
<Toast
t={createToast('success-toast')}
message='Settings saved.'
type='success'
summary='Your changes were synced.'
/>
</IntlProvider>,
);
const toast = screen.getByTestId('toast');
expect(toast).toHaveAttribute('role', 'status');
expect(toast).toHaveAttribute('aria-live', 'polite');
expect(toast).toHaveAttribute('aria-atomic', 'true');
expect(toast).toHaveAttribute(
'aria-describedby',
'toast-message-success-toast toast-summary-success-toast',
);
expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();
});
it('uses assertive alert semantics for error toasts', () => {
render(
<IntlProvider locale='en'>
<Toast t={createToast('error-toast')} message='Something went wrong.' type='error' />
</IntlProvider>,
);
const toast = screen.getByTestId('toast');
expect(toast).toHaveAttribute('role', 'alert');
expect(toast).toHaveAttribute('aria-live', 'assertive');
expect(toast).toHaveAttribute('aria-atomic', 'true');
expect(toast).toHaveAttribute('aria-describedby', 'toast-message-error-toast');
});
});