mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
E2E had been red on main since 2026-08-08. The last green run was 2026-07-27,
and the failing test filled a hardcoded date one day later:
await page.getByTestId('tx-date').fill('2026-07-28')
The transactions page opens on the current calendar month (defaultPeriod), and
the demo seed runs through the current month (backend/database.js seeds
`new Date().getMonth() + 1` months of the current year). While "today" was in
July the created row sat inside the visible period. Once the calendar reached
August the row was dated into a month the page no longer showed, so it was
filtered out entirely rather than merely paged past. The date now comes from
the clock, and the row is located by search rather than by position — the
seeded month holds 50-70 rows against a 50-row page.
That same boundary made both pagination assertions a coin flip; they now widen
the period to All time, where the seed spans years. Those two are hardening
rather than a fix — they pass either way against the seed used to verify.
Pill lookups are scoped to the transactions page, since visited pages stay
mounted and a bare test-id also matches the dashboard's period bar.
Verified against the real E2E stack, seeded exactly as the workflow does: 38
passed with these changes; reverting them reproduces the CI failure.
Note for later: e2e.yml runs the full suite only on push to main and just the
@smoke subset on pull requests, which is why no PR gate caught this.
139 lines
5.9 KiB
TypeScript
139 lines
5.9 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { login, navigateToRoute } from './test-helpers'
|
|
|
|
// Cross-page UI smoke checks. Every assertion targets a stable data-test-id (see tests/README.md)
|
|
// and is meaningful — the previous version was almost entirely `expect(count).toBeGreaterThanOrEqual(0)`
|
|
// no-ops that passed no matter what rendered.
|
|
|
|
test.describe('UI Components', () => {
|
|
test('Dashboard widgets are visible', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'dashboard')
|
|
await expect(page.getByTestId('dashboard-metrics')).toBeVisible({ timeout: 15000 })
|
|
// The redesigned dashboard tucks the classic charts behind a "Show more" toggle.
|
|
await page.getByTestId('dashboard-show-more').click()
|
|
await expect(page.getByTestId('dashboard-charts')).toBeVisible()
|
|
})
|
|
|
|
test('Transaction table renders correctly', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'transactions')
|
|
await expect(page.getByTestId('transactions-table')).toBeVisible({ timeout: 10000 })
|
|
expect(await page.getByTestId('transactions-row').count()).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('Pagination renders for the seeded transaction volume', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'transactions')
|
|
// The page opens on the current calendar month, where the seed puts 50-70 rows against a
|
|
// 50-row page — right on the boundary, so pagination appeared or not by luck of the draw.
|
|
// Widen to all time first: the seed spans many years, so >1 page is certain. Scoped to this
|
|
// page: visited pages stay mounted, so a bare test-id also matches the dashboard's period bar.
|
|
await page.getByTestId('page-transactions').getByTestId('period-pill-all').click()
|
|
await expect(page.getByTestId('transactions-pagination').first()).toBeVisible({
|
|
timeout: 10000,
|
|
})
|
|
})
|
|
|
|
test('Filter bar is visible', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'transactions')
|
|
await expect(page.getByTestId('filter-bar')).toBeVisible({ timeout: 10000 })
|
|
})
|
|
|
|
test('Modal opens and closes correctly', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'accounts')
|
|
|
|
await page.getByTestId('add-account-btn').click()
|
|
await expect(page.getByTestId('add-account-modal')).toBeVisible({ timeout: 5000 })
|
|
|
|
// Close via the Cancel action and confirm it's gone.
|
|
const cancel = page.getByTestId('add-account-modal').getByRole('button', { name: /cancel/i })
|
|
if (await cancel.isVisible().catch(() => false)) {
|
|
await cancel.click()
|
|
await expect(page.getByTestId('add-account-modal')).toBeHidden({ timeout: 3000 })
|
|
}
|
|
})
|
|
|
|
test('Category tabs switch active state', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'categories')
|
|
|
|
// Wait for the tab row to render before interacting (the categories page loads its data first).
|
|
await expect(page.getByTestId('tab-all')).toBeVisible({ timeout: 10000 })
|
|
const expenseTab = page.getByTestId('tab-expense')
|
|
await expenseTab.click()
|
|
await expect(expenseTab).toHaveClass(/active/i, { timeout: 5000 })
|
|
})
|
|
|
|
test('Bill cards display', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'bills')
|
|
await expect(page.getByTestId('bill-card').first()).toBeVisible({ timeout: 10000 })
|
|
})
|
|
|
|
test('Account cards display', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'accounts')
|
|
await expect(page.getByTestId('account-card').first()).toBeVisible({ timeout: 10000 })
|
|
})
|
|
|
|
test('Search input is present', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'transactions')
|
|
await expect(page.getByTestId('transactions-search')).toBeVisible({ timeout: 10000 })
|
|
})
|
|
|
|
test('Budgets allocation action is present', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'budgets')
|
|
await expect(page.getByTestId('budgets-add-allocation-btn')).toBeVisible({ timeout: 10000 })
|
|
})
|
|
|
|
test('Account form inputs render in the add modal', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'accounts')
|
|
await page.getByTestId('add-account-btn').click()
|
|
const modal = page.getByTestId('add-account-modal')
|
|
await expect(modal).toBeVisible({ timeout: 5000 })
|
|
expect(await modal.locator('input, select').count()).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('Sidebar navigation links are wired up', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'dashboard')
|
|
await expect(page.getByTestId('nav-link-dashboard')).toBeAttached()
|
|
await expect(page.getByTestId('nav-link-transactions')).toBeAttached()
|
|
await expect(page.getByTestId('nav-link-accounts')).toBeAttached()
|
|
})
|
|
|
|
test('Goal progress cards render', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'goals')
|
|
await expect(page.getByTestId('goals-grid')).toBeVisible({ timeout: 10000 })
|
|
await expect(page.getByTestId('goal-card').first()).toBeVisible()
|
|
})
|
|
|
|
test('Dashboard chart region renders', async ({ page }) => {
|
|
await login(page)
|
|
await navigateToRoute(page, 'dashboard')
|
|
// Charts live below the "Show more" toggle in the redesigned dashboard.
|
|
await page.getByTestId('dashboard-show-more').click({ timeout: 15000 })
|
|
await expect(page.getByTestId('dashboard-charts')).toBeVisible({ timeout: 15000 })
|
|
})
|
|
|
|
test('Responsive layout adjusts across breakpoints', async ({ page }) => {
|
|
await login(page)
|
|
await page.setViewportSize({ width: 1920, height: 1080 })
|
|
await navigateToRoute(page, 'dashboard')
|
|
await expect(page.getByTestId('dashboard-header')).toBeVisible({ timeout: 15000 })
|
|
|
|
await page.setViewportSize({ width: 768, height: 1024 })
|
|
await expect(page.getByTestId('dashboard-header')).toBeVisible()
|
|
|
|
await page.setViewportSize({ width: 375, height: 667 })
|
|
await expect(page.getByTestId('dashboard-header')).toBeVisible()
|
|
})
|
|
})
|