50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
|
|
import { test, expect } from '@playwright/test';
|
||
|
|
import { login, verifyCreateUser, todate } from './util';
|
||
|
|
|
||
|
|
test('can log out', async ({ page }) => {
|
||
|
|
await login(page);
|
||
|
|
|
||
|
|
await page.getByText("Logout").click();
|
||
|
|
await expect(page.getByLabel("Username")).toBeVisible();
|
||
|
|
});
|
||
|
|
|
||
|
|
test('has no contacts', async ({ page }) => {
|
||
|
|
await login(page);
|
||
|
|
|
||
|
|
await expect(page.getByRole("navigation").getByRole("link")).toHaveCount(0);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('can add contacts', async ({ page }) => {
|
||
|
|
await login(page);
|
||
|
|
await verifyCreateUser(page, { names: ['John Contact'] });
|
||
|
|
await verifyCreateUser(page, { names: ['Jack Contact'] });
|
||
|
|
await expect(page.getByRole("navigation").getByRole("link")).toHaveCount(2);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('shows "never" for unfreshened contacts', async ({ page }) => {
|
||
|
|
await login(page);
|
||
|
|
await verifyCreateUser(page, { names: ['John Contact'] });
|
||
|
|
await page.getByRole('link', { name: 'Mascarpone' }).click();
|
||
|
|
|
||
|
|
await expect(page.locator('#freshness')).toContainText('John Contactnever');
|
||
|
|
});
|
||
|
|
|
||
|
|
test('shows the date for fresh contacts', async ({ page }) => {
|
||
|
|
await login(page);
|
||
|
|
await verifyCreateUser(page, { names: ['John Contact'] });
|
||
|
|
await page.getByRole('link', { name: /edit/i }).click();
|
||
|
|
await page.getByRole('button', { name: /fresh/i }).click();
|
||
|
|
await page.getByRole('button', { name: /save/i }).click();
|
||
|
|
await page.getByRole('link', { name: 'Mascarpone' }).click();
|
||
|
|
await expect(page.locator('#freshness')).toContainText(`John Contact${todate()}`);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('sidebar is sorted alphabetically', async ({ page }) => {
|
||
|
|
await login(page);
|
||
|
|
await verifyCreateUser(page, { names: ['Zulu'] });
|
||
|
|
await verifyCreateUser(page, { names: ['Alfa'] });
|
||
|
|
await verifyCreateUser(page, { names: ['Golf'] });
|
||
|
|
|
||
|
|
await expect(page.getByRole('navigation')).toHaveText(/Alfa\s*Golf\s*Zulu/);
|
||
|
|
});
|