v2.0.test.js•1.66 kB
const { test, expect } = require('@playwright/test');
test.describe('v2.0 Static UI', () => {
test('loads index.html with title and lists', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle('TPC Server');
await expect(page.locator('h1')).toContainText('TPC Server');
await expect(page.locator('#plans-list')).toBeVisible();
await expect(page.locator('#thoughts-list')).toBeVisible();
// Wait for async load to complete
await page.waitForSelector('#plans-list li[data-plan-id]');
await page.waitForSelector('#thoughts-list li[data-thought-id]');
// Since DB has migrated data, expect at least one item in each list
await expect(page.locator('#plans-list li')).toHaveCount(10);
await expect(page.locator('#thoughts-list li')).toHaveCount(6);
});
test('serves /tpc.db binary file', async ({ request }) => {
const response = await request.get('/tpc.db');
expect(response.status()).toBe(200);
expect(response.headers()['content-type']).toContain('application/octet-stream');
expect(response.body()).not.toBeNull();
});
test('handles empty lists if no data', async ({ page }) => {
// This test assumes we can run with clean DB, but for now, skip or note
// For v2.0, since data exists, focus on presence
await page.goto('/');
const plansList = page.locator('#plans-list li');
const thoughtsList = page.locator('#thoughts-list li');
// Verify no error messages if data present
await expect(plansList.first()).not.toContainText('Error loading data');
await expect(thoughtsList.first()).not.toContainText('Error loading data');
});
});