test: adapt local regressions to Vitest 5 and verify date fallback

This commit is contained in:
Codex
2026-10-19 20:43:27 +03:00
parent 32b55555b5
commit 9533e7c67a
5 changed files with 41 additions and 3 deletions
@@ -90,6 +90,7 @@ describe('MemoriesLane', () => {
await advance();
expect(link.querySelector('img')?.src).toContain('asset-2025-0');
expect(getAllByRole('link')[1].querySelector('img')?.src).toContain('asset-2024-2');
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
expect(getByRole('button', { name: 'pause_memories' })).toHaveAttribute('aria-pressed', 'false');
});
+2 -3
View File
@@ -19,9 +19,8 @@ describe('i18n', () => {
// verify it loads the right file
const module: { default?: unknown } = await item.loader();
const translations = JSON.stringify(module.default, null, 2).trim();
const content = readFileSync(`../i18n/${filename}`).toString().trim();
expect(translations === content, `${item.name} did not load ${filename}`).toEqual(true);
const content = JSON.parse(readFileSync(`../i18n/${filename}`, 'utf8'));
expect(module.default, `${item.name} did not load ${filename}`).toEqual(content);
});
}
});
@@ -9,6 +9,7 @@ describe('event subscriptions across navigation', () => {
for (let page = 0; page < 3; page++) {
await user.click(screen.getByRole('button', { name: 'Next page' }));
await user.click(screen.getByRole('button', { name: 'Update' }));
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
expect(screen.getByTestId('received')).toHaveTextContent('1');
}
});
@@ -17,12 +18,16 @@ describe('event subscriptions across navigation', () => {
const user = userEvent.setup();
render(EventNavigation);
const update = screen.getByRole('button', { name: 'Update' });
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
expect(update).toBeEnabled();
await user.click(screen.getByRole('button', { name: 'Toggle subscriber' }));
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
expect(update).toBeDisabled();
await user.click(screen.getByRole('button', { name: 'Toggle subscriber' }));
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
expect(update).toBeEnabled();
await user.click(update);
// @ts-expect-error pending a type fix: https://github.com/testing-library/jest-dom/pull/742/changes
expect(screen.getByTestId('received')).toHaveTextContent('1');
});
});
+6
View File
@@ -1,6 +1,8 @@
import { AssetVisibility } from '@immich/sdk';
import { init, register, waitLocale } from 'svelte-i18n';
import { get } from 'svelte/store';
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
import { locale } from '$lib/stores/preferences.store';
import { getAltText } from '$lib/utils/thumbnail-util';
interface Person {
@@ -13,12 +15,16 @@ const threePeople: Person[] = [{ name: 'person1' }, { name: 'person2' }, { name:
const fourPeople: Person[] = [{ name: 'person1' }, { name: 'person2' }, { name: 'person3' }, { name: 'person4' }];
describe('getAltText', () => {
const originalLocale = get(locale);
beforeAll(async () => {
locale.set('en-US');
await init({ fallbackLocale: 'en-US' });
register('en-US', () => import('$i18n/en.json'));
await waitLocale('en-US');
});
afterAll(() => locale.set(originalLocale));
it.each`
isVideo | city | country | people | expected
${false} | ${undefined} | ${'country'} | ${undefined} | ${'Image taken on January 1, 2024'}