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();
|
await advance();
|
||||||
expect(link.querySelector('img')?.src).toContain('asset-2025-0');
|
expect(link.querySelector('img')?.src).toContain('asset-2025-0');
|
||||||
expect(getAllByRole('link')[1].querySelector('img')?.src).toContain('asset-2024-2');
|
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');
|
expect(getByRole('button', { name: 'pause_memories' })).toHaveAttribute('aria-pressed', 'false');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ describe('i18n', () => {
|
|||||||
|
|
||||||
// verify it loads the right file
|
// verify it loads the right file
|
||||||
const module: { default?: unknown } = await item.loader();
|
const module: { default?: unknown } = await item.loader();
|
||||||
const translations = JSON.stringify(module.default, null, 2).trim();
|
const content = JSON.parse(readFileSync(`../i18n/${filename}`, 'utf8'));
|
||||||
const content = readFileSync(`../i18n/${filename}`).toString().trim();
|
expect(module.default, `${item.name} did not load ${filename}`).toEqual(content);
|
||||||
expect(translations === content, `${item.name} did not load ${filename}`).toEqual(true);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ describe('event subscriptions across navigation', () => {
|
|||||||
for (let page = 0; page < 3; page++) {
|
for (let page = 0; page < 3; page++) {
|
||||||
await user.click(screen.getByRole('button', { name: 'Next page' }));
|
await user.click(screen.getByRole('button', { name: 'Next page' }));
|
||||||
await user.click(screen.getByRole('button', { name: 'Update' }));
|
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');
|
expect(screen.getByTestId('received')).toHaveTextContent('1');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -17,12 +18,16 @@ describe('event subscriptions across navigation', () => {
|
|||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
render(EventNavigation);
|
render(EventNavigation);
|
||||||
const update = screen.getByRole('button', { name: 'Update' });
|
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();
|
expect(update).toBeEnabled();
|
||||||
await user.click(screen.getByRole('button', { name: 'Toggle subscriber' }));
|
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();
|
expect(update).toBeDisabled();
|
||||||
await user.click(screen.getByRole('button', { name: 'Toggle subscriber' }));
|
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();
|
expect(update).toBeEnabled();
|
||||||
await user.click(update);
|
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');
|
expect(screen.getByTestId('received')).toHaveTextContent('1');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { AssetVisibility } from '@immich/sdk';
|
import { AssetVisibility } from '@immich/sdk';
|
||||||
import { init, register, waitLocale } from 'svelte-i18n';
|
import { init, register, waitLocale } from 'svelte-i18n';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
import type { TimelineAsset } from '$lib/managers/timeline-manager/types';
|
||||||
|
import { locale } from '$lib/stores/preferences.store';
|
||||||
import { getAltText } from '$lib/utils/thumbnail-util';
|
import { getAltText } from '$lib/utils/thumbnail-util';
|
||||||
|
|
||||||
interface Person {
|
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' }];
|
const fourPeople: Person[] = [{ name: 'person1' }, { name: 'person2' }, { name: 'person3' }, { name: 'person4' }];
|
||||||
|
|
||||||
describe('getAltText', () => {
|
describe('getAltText', () => {
|
||||||
|
const originalLocale = get(locale);
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
locale.set('en-US');
|
||||||
await init({ fallbackLocale: 'en-US' });
|
await init({ fallbackLocale: 'en-US' });
|
||||||
register('en-US', () => import('$i18n/en.json'));
|
register('en-US', () => import('$i18n/en.json'));
|
||||||
await waitLocale('en-US');
|
await waitLocale('en-US');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterAll(() => locale.set(originalLocale));
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
isVideo | city | country | people | expected
|
isVideo | city | country | people | expected
|
||||||
${false} | ${undefined} | ${'country'} | ${undefined} | ${'Image taken on January 1, 2024'}
|
${false} | ${undefined} | ${'country'} | ${undefined} | ${'Image taken on January 1, 2024'}
|
||||||
|
|||||||
Reference in New Issue
Block a user