Files
eleith 94c1aa95b9
ci/woodpecker/pr/config Pipeline was successful
ci/woodpecker/pr/hledger Pipeline was successful
ci/woodpecker/pr/jobs Pipeline was successful
ci/woodpecker/pr/snapshots Pipeline was successful
ci/woodpecker/pr/web Pipeline was successful
ci/woodpecker/pr/worker Pipeline was successful
feat(web): add period-aware financial pages and branded navigation
2026-11-06 15:24:37 -08:00

74 lines
3.1 KiB
TypeScript

import { expect, test } from '@playwright/test';
import { prepared, readPreparationTimestamp } from './overview-fixture';
test('Holdings runs fresh investment reports without replacing saved reports', async ({ page }) => {
await prepared(page);
await page.goto('/settings');
const savedAt = await readPreparationTimestamp(page);
await page.goto('/');
const requests: string[] = [];
page.on('request', (request) => {
if (request.method() === 'POST' && new URL(request.url()).pathname === '/holdings') {
requests.push(request.url());
}
});
await page
.getByRole('complementary', { name: 'Accounts', exact: true })
.getByRole('link', { name: 'Investments', exact: true })
.click();
await page
.locator('main')
.getByRole('link', { name: /^Brokerage\b/ })
.click();
await page.locator('main').getByRole('link', { name: 'Holdings', exact: true }).click();
await expect(page.getByLabel('As of', { exact: true })).toHaveValue('2026-04-16');
const account = page.getByLabel('Account', { exact: true });
await account.selectOption('');
await expect(account.locator('option:checked')).toHaveText('All investment accounts');
await expect(account.locator('option')).toHaveText([
'All investment accounts',
'Brokerage (assets:investments:brokerage)',
'assets:investments:retirement'
]);
await expect(page.getByRole('region', { name: 'Holdings result', exact: true })).toHaveCount(0);
expect(requests).toHaveLength(0);
await page.getByRole('button', { name: 'View holdings', exact: true }).click();
const brokerage = page.getByRole('table', { name: 'Holdings for Brokerage', exact: true });
const position = brokerage.getByRole('row').filter({ hasText: 'VTI' });
await expect(position.getByRole('cell', { name: '13.00', exact: true })).toBeVisible();
await expect(
page.getByRole('table', { name: 'Holdings for assets:investments:retirement', exact: true })
).toBeVisible();
await expect(page.getByRole('region', { name: 'Everyday checking', exact: true })).toHaveCount(0);
const stamp = page
.getByRole('region', { name: 'Holdings result', exact: true })
.locator('p')
.filter({ hasText: /^Prepared at / })
.locator('time');
await expect(stamp).toHaveAttribute('datetime', /.+/);
const firstRunAt = (await stamp.getAttribute('datetime'))!;
await page.getByRole('button', { name: 'View holdings', exact: true }).click();
await expect(stamp).not.toHaveAttribute('datetime', firstRunAt);
expect(requests).toHaveLength(2);
await page
.getByRole('complementary', { name: 'Accounts', exact: true })
.getByRole('link', { name: 'Investments', exact: true })
.click();
await page
.locator('main')
.getByRole('link', { name: /^Brokerage\b/ })
.click();
await page.locator('main').getByRole('link', { name: 'Holdings', exact: true }).click();
await expect(account.locator('option:checked')).toHaveText(
'Brokerage (assets:investments:brokerage)'
);
await expect(page.getByRole('region', { name: 'Holdings result', exact: true })).toHaveCount(0);
expect(requests).toHaveLength(2);
await page.goto('/settings');
expect(await readPreparationTimestamp(page)).toBe(savedAt);
});