Merge branch 'review/slice-1-recheck'
This commit is contained in:
@@ -98,6 +98,82 @@ describe('GameScreen speed buttons', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('GameScreen location tree', () => {
|
||||
it('filters the location panel on the client when a tree node is clicked', () => {
|
||||
const screen = new GameScreen({
|
||||
onLeave: () => {},
|
||||
onSetRunning: () => {},
|
||||
onSetSpeed: () => {},
|
||||
onSkip: () => {},
|
||||
});
|
||||
document.body.append(screen.element);
|
||||
screen.show(school());
|
||||
screen.applyMap(1, [
|
||||
{
|
||||
kind: 0,
|
||||
id: 'yard',
|
||||
parentId: '',
|
||||
name: 'Двор',
|
||||
pupilSlots: 0,
|
||||
items: [],
|
||||
positions: [],
|
||||
},
|
||||
{
|
||||
kind: 3,
|
||||
id: 'office',
|
||||
parentId: 'yard',
|
||||
name: 'Кабинет',
|
||||
pupilSlots: 0,
|
||||
items: [{ name: 'Стул', count: 2 }],
|
||||
positions: ['Директор'],
|
||||
},
|
||||
]);
|
||||
|
||||
expect(screen.element.querySelector('.panel__name')?.textContent).toBe('Двор');
|
||||
const itemsSection = screen.element.querySelector('.panel__section');
|
||||
expect(itemsSection?.querySelector('.panel__empty')?.textContent).toBe(t('itemsEmpty'));
|
||||
|
||||
const office = [...screen.element.querySelectorAll<HTMLButtonElement>('.tree__button')].find(
|
||||
(button) => button.textContent === 'Кабинет',
|
||||
);
|
||||
expect(office).toBeTruthy();
|
||||
office?.click();
|
||||
|
||||
expect(screen.element.querySelector('.panel__name')?.textContent).toBe('Кабинет');
|
||||
expect(office?.classList.contains('tree__button--active')).toBe(true);
|
||||
const lists = [...screen.element.querySelectorAll('.panel__section .panel__list')].map(
|
||||
(list) => [...list.querySelectorAll('li')].map((item) => item.textContent ?? ''),
|
||||
);
|
||||
expect(lists.some((entries) => entries.includes('Стул ×2'))).toBe(true);
|
||||
expect(lists.some((entries) => entries.includes('Директор'))).toBe(true);
|
||||
});
|
||||
|
||||
it('relocalizes empty location sections when the language switches', () => {
|
||||
setLocale('en');
|
||||
const screen = new GameScreen({
|
||||
onLeave: () => {},
|
||||
onSetRunning: () => {},
|
||||
onSetSpeed: () => {},
|
||||
onSkip: () => {},
|
||||
});
|
||||
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'),
|
||||
);
|
||||
|
||||
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'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('GameScreen location talk', () => {
|
||||
it('shows talk partners from the directory on the location list, not from the frame', () => {
|
||||
setLocale('ru');
|
||||
|
||||
Reference in New Issue
Block a user