/** * @feature Locations * @see e2e/features/pages/locations.feature */ import { describe, test } from 'vitest'; import { setupBrowser } from '../../support/browser'; import { waitForAppReady, seedItems } from '../../support/seed'; import { buildItemAtLocation } from '../../support/item-factory'; import { expectVisible, expectText } from '../../support/expect'; const { getPage } = setupBrowser(); describe('Locations', () => { test('location tree shows default locations', async () => { const page = getPage(); await page.goto('/locations'); await waitForAppReady(page); await expectText(page.getByRole('heading', { level: 1 }), 'Places'); await expectVisible(page.getByText('Home')); }); test('placeholder shown when no location selected', async () => { const page = getPage(); await page.goto('/locations'); await waitForAppReady(page); await expectVisible(page.getByText('Select a location to view items')); }); test('selecting a location shows its items', async () => { const page = getPage(); const item = buildItemAtLocation('kueche', { name: 'Blender' }); await page.goto('/'); await waitForAppReady(page); await seedItems(page, [item]); await page.goto('/locations'); await waitForAppReady(page); // Expand Erdgeschoss (click toggle, not the location name) to reveal Küche await page.locator('.select-none').filter({ hasText: 'Erdgeschoss' }).getByLabel('Expand').click(); await page.getByText('Küche').click(); await expectVisible(page.getByText('Blender')); }); test('empty location shows placeholder', async () => { const page = getPage(); await page.goto('/locations'); await waitForAppReady(page); // Expand Keller (click toggle, not the location name) to reveal Werkstatt await page.locator('.select-none').filter({ hasText: 'Keller' }).getByLabel('Expand').click(); await page.getByText('Werkstatt').click(); await expectVisible(page.getByText('No items here')); }); });