e2e) stabilize date view tests
All checks were successful
PR Checks / lint-test-and-docker-build (pull_request) Successful in 2m23s

This commit is contained in:
2026-02-24 20:11:17 +00:00
parent f8dcd3b2bf
commit 945737b6fd
6 changed files with 117 additions and 62 deletions

View File

@@ -10,7 +10,17 @@ import { TEST_USERS } from './test-users.js';
dotenvConfig({ path: resolve(process.cwd(), '.env.test'), override: true });
const DB_PATH = resolve(process.cwd(), 'trips.test.db');
function resolveDatabasePath(): string {
const rawUrl = process.env.DATABASE_URL;
if (rawUrl && rawUrl.startsWith('file:')) {
const rawPath = rawUrl.slice('file:'.length);
if (!rawPath) return resolve(process.cwd(), 'trips.test.db');
return rawPath.startsWith('/') ? rawPath : resolve(process.cwd(), rawPath);
}
return resolve(process.cwd(), 'trips.test.db');
}
const DB_PATH = resolveDatabasePath();
// Delete any existing test DB so we start clean each run
for (const ext of ['', '-shm', '-wal']) {
@@ -20,6 +30,7 @@ for (const ext of ['', '-shm', '-wal']) {
}
}
console.log(`[e2e] Using test database at ${DB_PATH}`);
const db = new BunSqlite(DB_PATH);
db.exec('PRAGMA foreign_keys = ON');
@@ -40,6 +51,7 @@ const dbWrapper = {
}
};
console.log('[e2e] Running migrations...');
const { runMigrations } = await import('../../src/lib/server/db/migrations.js');
runMigrations(dbWrapper);
console.log('[e2e] Migrations complete.');
@@ -53,6 +65,7 @@ async function hashPassword(password: string): Promise<string> {
});
}
console.log('[e2e] Creating test users...');
const regularId = randomUUID();
dbWrapper.run(
`INSERT INTO users (id, username, full_name, email, auth_source) VALUES (?, ?, ?, ?, ?)`,

View File

@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import { TEST_USERS } from './setup/test-users.js';
import { loginAsLocalUser, ensureSelfProfile } from './helpers/auth.js';
import { addPackingList, createTrip, openAddToTripMenuItem, uniqueSuffix } from './helpers/trip.js';
import { createTrip, openAddToTripMenuItem, uniqueSuffix } from './helpers/trip.js';
function formatDate(offsetDays: number): string {
const date = new Date();
@@ -37,7 +37,6 @@ test('day and week views filter itinerary items', async ({ page }) => {
const endDate = formatDate(9);
const dayOneActivity = `Museum visit ${suffix}`;
const dayEightActivity = `Harbor walk ${suffix}`;
const packingListName = `Carry-on ${suffix}`;
await loginAsLocalUser(page, TEST_USERS.regular.username, TEST_USERS.regular.password);
await ensureSelfProfile(page);
@@ -51,16 +50,13 @@ test('day and week views filter itinerary items', async ({ page }) => {
await addActivity(page, { name: dayOneActivity, startDate, startTime: '09:00' });
await addActivity(page, { name: dayEightActivity, startDate: formatDate(7), startTime: '11:00' });
await addPackingList(page, { name: packingListName, items: ['Sunscreen'] });
await page.reload();
await expect(page.getByText(dayOneActivity)).toBeVisible();
await expect(page.getByText(packingListName)).toBeVisible();
await expect(page.getByRole('button', { name: 'Today' })).toBeVisible();
await page.getByRole('button', { name: 'Today' }).click();
await page.getByRole('button', { name: 'Day' }).click();
await expect(page.getByText('Day 1')).toBeVisible();
await expect(page.getByText(dayOneActivity)).toBeVisible();
await expect(page.getByText(dayEightActivity)).toBeHidden();
await expect(page.getByText(packingListName)).toBeHidden();
await page.getByRole('button', { name: 'Week' }).click();
await expect(page.getByText('Week 1')).toBeVisible();