fix(i18n): localize generated labels without changing saved content

This commit is contained in:
cesnimda
2026-10-20 20:27:42 +02:00
parent d8c0187305
commit ab89b6984c
17 changed files with 1106 additions and 31 deletions
@@ -118,6 +118,24 @@ function renderPage(initialPath = '/') {
}
describe('CorrespondenceInboxPage', () => {
test('[P7-11 inbox] resumed draft fallback metadata follows locale without mutating stored prose or refetching', async () => {
const original = mockedApi.get.getMockImplementation();
mockedApi.get.mockImplementation((url: string, config?: any) => {
if (url === '/email/drafts') return Promise.resolve({ data: [savedComposeDraft({ jobApplicationId: 98 })] } as any);
if (url === '/email/providers') return Promise.resolve({ data: [{ provider: 'gmail', displayName: 'Gmail', connected: false, address: null, canRead: false, canSend: false }] } as any);
return original!(url, config);
});
renderPage();
fireEvent.click(await screen.findByRole('button', { name: /resume owned compose draft/i }));
fireEvent.change(composeField('emailInboxMessage'), { target: { value: 'My unsaved English message' } });
const reads = mockedApi.get.mock.calls.length;
await changeLanguage('nb');
expect(screen.getByText(`${copy('emailInboxJobNumber')} #98 · ${copy('emailInboxSavedDraft')}`)).toBeInTheDocument();
expect(composeField('emailInboxProvider')).toHaveValue(`Gmail · ${copy('emailInboxReconnectBeforeSending')}`);
expect(composeField('emailInboxMessage')).toHaveValue('My unsaved English message');
expect(composeField('emailInboxSubject')).toHaveValue('Owned compose draft');
expect(mockedApi.get).toHaveBeenCalledTimes(reads); expect(mockedApi.put).not.toHaveBeenCalled(); expect(mockedApi.post).not.toHaveBeenCalled();
});
beforeEach(() => {
window.localStorage.clear();
document.documentElement.lang = 'en';
@@ -176,11 +194,12 @@ describe('CorrespondenceInboxPage', () => {
renderPage();
expect(await screen.findByRole('heading', { name: /job email/i })).toBeInTheDocument();
expect(await screen.findByText(/1 items/i)).toBeInTheDocument();
expect(await screen.findByText("1 item", { exact: true })).toBeInTheDocument();
expect(await screen.findByText(/acme systems/i)).toBeInTheDocument();
expect(await screen.findByText(/backend engineer/i)).toBeInTheDocument();
expect(screen.getByText(/2 labels/i)).toBeInTheDocument();
expect(screen.getByText(/1 attachments/i)).toBeInTheDocument();
expect(screen.getByText("1 attachment", { exact: true })).toBeInTheDocument();
expect(screen.getByText("1 item", { exact: true })).toBeInTheDocument();
expect(screen.getByText(/Gmail: owner@gmail\.test · Read only; reconnect to enable send/i)).toBeInTheDocument();
expect(screen.getByText(/^Outlook: Not connected$/i)).toBeInTheDocument();
expect(screen.queryByText(/Outlook: Not connected.*Read only/i)).not.toBeInTheDocument();