make sure e2e tests use the visible timer button only

This commit is contained in:
Gregor Vostrak
2026-02-12 17:43:04 +01:00
parent 0e63ecb520
commit 38457cae4d
5 changed files with 43 additions and 13 deletions

View File

@@ -31,15 +31,21 @@ async function selectCommand(page: Page, name: string) {
} }
async function assertTimerIsRunning(page: Page) { async function assertTimerIsRunning(page: Page) {
await expect(page.locator(TIMER_BUTTON_SELECTOR)).toHaveClass(/bg-red-400\/80/, { await expect(page.locator(TIMER_BUTTON_SELECTOR).and(page.locator(':visible'))).toHaveClass(
timeout: 10000, /bg-red-400\/80/,
}); {
timeout: 10000,
}
);
} }
async function assertTimerIsStopped(page: Page) { async function assertTimerIsStopped(page: Page) {
await expect(page.locator(TIMER_BUTTON_SELECTOR)).toHaveClass(/bg-accent-300\/70/, { await expect(page.locator(TIMER_BUTTON_SELECTOR).and(page.locator(':visible'))).toHaveClass(
timeout: 10000, /bg-accent-300\/70/,
}); {
timeout: 10000,
}
);
} }
test.describe('Command Palette', () => { test.describe('Command Palette', () => {

View File

@@ -25,7 +25,12 @@ test('test that dashboard loads with all expected sections', async ({ page }) =>
// Timer section (scoped to dashboard_timer to avoid matching sidebar timer) // Timer section (scoped to dashboard_timer to avoid matching sidebar timer)
await expect(page.getByTestId('time_entry_description')).toBeVisible(); await expect(page.getByTestId('time_entry_description')).toBeVisible();
await expect(page.getByTestId('dashboard_timer').getByTestId('timer_button')).toBeVisible(); await expect(
page
.getByTestId('dashboard_timer')
.getByTestId('timer_button')
.and(page.locator(':visible'))
).toBeVisible();
// Dashboard cards // Dashboard cards
await expect(page.getByText('Recent Time Entries', { exact: true })).toBeVisible(); await expect(page.getByText('Recent Time Entries', { exact: true })).toBeVisible();
@@ -104,7 +109,10 @@ test.describe('Employee Dashboard Restrictions', () => {
// Timer should be available // Timer should be available
await expect( await expect(
employee.page.getByTestId('dashboard_timer').getByTestId('timer_button') employee.page
.getByTestId('dashboard_timer')
.getByTestId('timer_button')
.and(employee.page.locator(':visible'))
).toBeVisible(); ).toBeVisible();
await expect(employee.page.getByTestId('time_entry_description')).toBeEditable(); await expect(employee.page.getByTestId('time_entry_description')).toBeEditable();
}); });

View File

@@ -1450,7 +1450,10 @@ test.describe('Employee Time Entry Isolation', () => {
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/time'); await employee.page.goto(PLAYWRIGHT_BASE_URL + '/time');
await expect( await expect(
employee.page.getByTestId('dashboard_timer').getByTestId('timer_button') employee.page
.getByTestId('dashboard_timer')
.getByTestId('timer_button')
.and(employee.page.locator(':visible'))
).toBeVisible({ timeout: 10000 }); ).toBeVisible({ timeout: 10000 });
// Employee's time entry IS visible // Employee's time entry IS visible

View File

@@ -354,7 +354,10 @@ test('test that timer started on dashboard is visible on time page', async ({ pa
// Timer should still be running (the timer button should be red/active) // Timer should still be running (the timer button should be red/active)
await expect( await expect(
page.locator('[data-testid="dashboard_timer"] [data-testid="timer_button"]') page
.getByTestId('dashboard_timer')
.getByTestId('timer_button')
.and(page.locator(':visible'))
).toHaveClass(/bg-red-400\/80/); ).toHaveClass(/bg-red-400\/80/);
// Stop the timer // Stop the timer

View File

@@ -2,12 +2,19 @@ import { expect } from '@playwright/test';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
export async function startOrStopTimerWithButton(page: Page) { export async function startOrStopTimerWithButton(page: Page) {
await page.locator('[data-testid="dashboard_timer"] [data-testid="timer_button"]').click(); await page
.getByTestId('dashboard_timer')
.getByTestId('timer_button')
.and(page.locator(':visible'))
.click();
} }
export async function assertThatTimerHasStarted(page: Page) { export async function assertThatTimerHasStarted(page: Page) {
await expect( await expect(
page.locator('[data-testid="dashboard_timer"] [data-testid="timer_button"]') page
.getByTestId('dashboard_timer')
.getByTestId('timer_button')
.and(page.locator(':visible'))
).toHaveClass(/bg-red-400\/80/); ).toHaveClass(/bg-red-400\/80/);
} }
@@ -34,7 +41,10 @@ export function newTimeEntryResponse(
export async function assertThatTimerIsStopped(page: Page) { export async function assertThatTimerIsStopped(page: Page) {
await expect( await expect(
page.locator('[data-testid="dashboard_timer"] [data-testid="timer_button"]') page
.getByTestId('dashboard_timer')
.getByTestId('timer_button')
.and(page.locator(':visible'))
).toHaveClass(/bg-accent-300\/70/); ).toHaveClass(/bg-accent-300\/70/);
} }