test: adapt local regressions to Vitest 5 and verify date fallback
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:immich_mobile/extensions/datetime_extensions.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
void main() {
|
||||
final originalLocale = Intl.defaultLocale;
|
||||
setUpAll(initializeDateFormatting);
|
||||
tearDown(() => Intl.defaultLocale = originalLocale);
|
||||
|
||||
test('date and time helpers fall back for an unsupported locale', () {
|
||||
Intl.defaultLocale = 'mi';
|
||||
final date = DateTime(2023, 8, 28, 13, 45);
|
||||
expect(resolvedDateTimeLocale(), 'en_US');
|
||||
expect(date.formatDate(), 'Aug 28, 2023');
|
||||
expect(date.formatTime(alwaysUse24HourFormat: true), '13:45');
|
||||
expect(DateRangeFormatting.formatDateRange(date, DateTime(2023, 8, 29)), 'Aug 28 - Aug 29, 2023');
|
||||
});
|
||||
|
||||
test('supported Russian formatting is preserved', () {
|
||||
Intl.defaultLocale = 'ru';
|
||||
final date = DateTime(2023, 8, 28, 13, 45);
|
||||
expect(resolvedDateTimeLocale(), 'ru');
|
||||
expect(date.formatDate(), DateFormat.yMMMd('ru').format(date));
|
||||
expect(date.formatTime(alwaysUse24HourFormat: true), '13:45');
|
||||
});
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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'}
|
||||
|
||||
Reference in New Issue
Block a user