Strengthen slice 1 localize coverage after notices and portraits drifted the shell.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-21 09:30:08 +03:00
co-authored by Cursor
parent c3d17cafc6
commit 5a0d75bce0
3 changed files with 89 additions and 9 deletions
+44 -8
View File
@@ -35,6 +35,29 @@ vi.mock('../net/api.ts', async (importOriginal) => {
const initial = getLocale();
function overviewPanel(root: HTMLElement, index: number): HTMLElement {
const overview = root.querySelectorAll(':scope > .manager')[0];
const panel = overview?.querySelectorAll(':scope > .panel')[index];
if (!(panel instanceof HTMLElement)) {
throw new Error('overview panel is missing');
}
return panel;
}
function mapTabs(root: HTMLElement): HTMLButtonElement[] {
return [...overviewPanel(root, 0).querySelectorAll<HTMLButtonElement>('.panel__tab')];
}
function locationBody(root: HTMLElement): HTMLElement {
const body = overviewPanel(root, 1).querySelector(':scope > .panel__body');
if (!(body instanceof HTMLElement)) {
throw new Error('location panel is missing');
}
return body;
}
function school(overrides: Partial<School> = {}): School {
return {
id: 1,
@@ -174,18 +197,31 @@ describe('GameScreen location tree', () => {
document.body.append(screen.element);
screen.show(school());
expect(screen.element.querySelector('.panel__section-title')?.textContent).toBe(t('locationItems'));
expect([...screen.element.querySelectorAll('.panel__empty')].map((node) => node.textContent)).toContain(
t('itemsEmpty'),
);
const location = locationBody(screen.element);
const titles = () => [...location.querySelectorAll('.panel__section-title')].map((node) => node.textContent);
const empties = () => [...location.querySelectorAll('.panel__empty')].map((node) => node.textContent);
const tabs = () => [...mapTabs(screen.element)].map((node) => node.textContent);
expect(tabs()).toEqual([t('mapTitle'), t('peopleTitle')]);
expect(titles()).toEqual([
t('locationItems'),
t('locationCharacters'),
t('locationActivities'),
t('locationPositions'),
]);
expect(empties()).toEqual([t('itemsEmpty'), t('charactersEmpty'), t('activitiesEmpty'), t('positionsEmpty')]);
setLocale('ru');
screen.localize();
expect(screen.element.querySelector('.panel__section-title')?.textContent).toBe(t('locationItems'));
expect([...screen.element.querySelectorAll('.panel__empty')].map((node) => node.textContent)).toContain(
t('itemsEmpty'),
);
expect(tabs()).toEqual([t('mapTitle'), t('peopleTitle')]);
expect(titles()).toEqual([
t('locationItems'),
t('locationCharacters'),
t('locationActivities'),
t('locationPositions'),
]);
expect(empties()).toEqual([t('itemsEmpty'), t('charactersEmpty'), t('activitiesEmpty'), t('positionsEmpty')]);
});
});