mirror of
https://github.com/immich-app/immich.git
synced 2025-03-01 15:11:21 +01:00
chore(web): use development lang for tests (#10025)
This commit is contained in:
parent
3e118793de
commit
d5f3d98dfc
6 changed files with 7 additions and 24 deletions
|
@ -2,7 +2,6 @@ import { sdkMock } from '$lib/__mocks__/sdk.mock';
|
||||||
import { albumFactory } from '@test-data';
|
import { albumFactory } from '@test-data';
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import { fireEvent, render, waitFor, type RenderResult } from '@testing-library/svelte';
|
import { fireEvent, render, waitFor, type RenderResult } from '@testing-library/svelte';
|
||||||
import { init, register, waitLocale } from 'svelte-i18n';
|
|
||||||
import AlbumCard from '../album-card.svelte';
|
import AlbumCard from '../album-card.svelte';
|
||||||
|
|
||||||
const onShowContextMenu = vi.fn();
|
const onShowContextMenu = vi.fn();
|
||||||
|
@ -10,12 +9,6 @@ const onShowContextMenu = vi.fn();
|
||||||
describe('AlbumCard component', () => {
|
describe('AlbumCard component', () => {
|
||||||
let sut: RenderResult<AlbumCard>;
|
let sut: RenderResult<AlbumCard>;
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
await init({ fallbackLocale: 'en-US' });
|
|
||||||
register('en-US', () => import('$lib/i18n/en.json'));
|
|
||||||
await waitLocale('en-US');
|
|
||||||
});
|
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
{
|
{
|
||||||
album: albumFactory.build({ albumThumbnailAssetId: null, shared: false, assetCount: 0 }),
|
album: albumFactory.build({ albumThumbnailAssetId: null, shared: false, assetCount: 0 }),
|
||||||
|
@ -43,7 +36,7 @@ describe('AlbumCard component', () => {
|
||||||
const albumImgElement = sut.getByTestId('album-image');
|
const albumImgElement = sut.getByTestId('album-image');
|
||||||
const albumNameElement = sut.getByTestId('album-name');
|
const albumNameElement = sut.getByTestId('album-name');
|
||||||
const albumDetailsElement = sut.getByTestId('album-details');
|
const albumDetailsElement = sut.getByTestId('album-details');
|
||||||
const detailsText = `${count} items` + (shared ? ' . Shared' : '');
|
const detailsText = `${count} items` + (shared ? ' . shared' : '');
|
||||||
|
|
||||||
expect(albumImgElement).toHaveAttribute('src');
|
expect(albumImgElement).toHaveAttribute('src');
|
||||||
expect(albumImgElement).toHaveAttribute('alt', album.albumName);
|
expect(albumImgElement).toHaveAttribute('alt', album.albumName);
|
||||||
|
|
|
@ -1,14 +1,9 @@
|
||||||
import AlbumDescription from '$lib/components/album-page/album-description.svelte';
|
import AlbumDescription from '$lib/components/album-page/album-description.svelte';
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import { render, screen } from '@testing-library/svelte';
|
import { render, screen } from '@testing-library/svelte';
|
||||||
import { init } from 'svelte-i18n';
|
|
||||||
import { describe } from 'vitest';
|
import { describe } from 'vitest';
|
||||||
|
|
||||||
describe('AlbumDescription component', () => {
|
describe('AlbumDescription component', () => {
|
||||||
beforeAll(async () => {
|
|
||||||
await init({ fallbackLocale: 'en-US' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('shows an AutogrowTextarea component when isOwned is true', () => {
|
it('shows an AutogrowTextarea component when isOwned is true', () => {
|
||||||
render(AlbumDescription, { isOwned: true, id: '', description: '' });
|
render(AlbumDescription, { isOwned: true, id: '', description: '' });
|
||||||
const autogrowTextarea = screen.getByTestId('autogrow-textarea');
|
const autogrowTextarea = screen.getByTestId('autogrow-textarea');
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import { cleanup, render, type RenderResult } from '@testing-library/svelte';
|
import { cleanup, render, type RenderResult } from '@testing-library/svelte';
|
||||||
import { init } from 'svelte-i18n';
|
|
||||||
import { NotificationType } from '../notification';
|
import { NotificationType } from '../notification';
|
||||||
import NotificationCard from '../notification-card.svelte';
|
import NotificationCard from '../notification-card.svelte';
|
||||||
|
|
||||||
describe('NotificationCard component', () => {
|
describe('NotificationCard component', () => {
|
||||||
let sut: RenderResult<NotificationCard>;
|
let sut: RenderResult<NotificationCard>;
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
await init({ fallbackLocale: 'en-US' });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('disposes timeout if already removed from the DOM', () => {
|
it('disposes timeout if already removed from the DOM', () => {
|
||||||
vi.spyOn(window, 'clearTimeout');
|
vi.spyOn(window, 'clearTimeout');
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
import { render, waitFor, type RenderResult } from '@testing-library/svelte';
|
import { render, waitFor, type RenderResult } from '@testing-library/svelte';
|
||||||
import { init } from 'svelte-i18n';
|
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
import { NotificationType, notificationController } from '../notification';
|
import { NotificationType, notificationController } from '../notification';
|
||||||
import NotificationList from '../notification-list.svelte';
|
import NotificationList from '../notification-list.svelte';
|
||||||
|
@ -12,8 +11,7 @@ function _getNotificationListElement(sut: RenderResult<NotificationList>): HTMLA
|
||||||
describe('NotificationList component', () => {
|
describe('NotificationList component', () => {
|
||||||
const sut: RenderResult<NotificationList> = render(NotificationList);
|
const sut: RenderResult<NotificationList> = render(NotificationList);
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(() => {
|
||||||
await init({ fallbackLocale: 'en-US' });
|
|
||||||
// https://testing-library.com/docs/svelte-testing-library/faq#why-arent-transition-events-running
|
// https://testing-library.com/docs/svelte-testing-library/faq#why-arent-transition-events-running
|
||||||
vi.stubGlobal('requestAnimationFrame', (fn: FrameRequestCallback) => {
|
vi.stubGlobal('requestAnimationFrame', (fn: FrameRequestCallback) => {
|
||||||
setTimeout(() => fn(Date.now()), 16);
|
setTimeout(() => fn(Date.now()), 16);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import messages from '$lib/i18n/en.json';
|
import messages from '$lib/i18n/en.json';
|
||||||
import { exec as execCallback } from 'node:child_process';
|
import { exec as execCallback } from 'node:child_process';
|
||||||
import { promisify } from 'node:util';
|
import { promisify } from 'node:util';
|
||||||
import { init } from 'svelte-i18n';
|
|
||||||
|
|
||||||
type Messages = { [key: string]: string | Messages };
|
type Messages = { [key: string]: string | Messages };
|
||||||
|
|
||||||
|
@ -23,8 +22,6 @@ function setEmptyMessages(messages: Messages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('i18n', () => {
|
describe('i18n', () => {
|
||||||
beforeEach(() => init({ fallbackLocale: 'dev' }));
|
|
||||||
|
|
||||||
test('no missing messages', async () => {
|
test('no missing messages', async () => {
|
||||||
const { stdout } = await exec('npx svelte-i18n extract -c svelte.config.js "src/**/*"');
|
const { stdout } = await exec('npx svelte-i18n extract -c svelte.config.js "src/**/*"');
|
||||||
const extractedMessages: Messages = JSON.parse(stdout);
|
const extractedMessages: Messages = JSON.parse(stdout);
|
||||||
|
|
|
@ -1 +1,6 @@
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
|
import { init } from 'svelte-i18n';
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await init({ fallbackLocale: 'dev' });
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue