spec: show birthdays until a week out
This commit is contained in:
parent
4f141b01c3
commit
c12975926d
4 changed files with 65 additions and 44 deletions
|
|
@ -2,44 +2,82 @@ import { test, expect } from '@playwright/test';
|
|||
import { login, verifyCreateUser, todate } from './util';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await login(page);
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('can log out', async ({ page }) => {
|
||||
await page.getByText("Logout").click();
|
||||
await expect(page.getByLabel("Username")).toBeVisible();
|
||||
await page.getByText("Logout").click();
|
||||
await expect(page.getByLabel("Username")).toBeVisible();
|
||||
});
|
||||
|
||||
test('has no contacts', async ({ page }) => {
|
||||
await expect(page.getByRole("navigation").getByRole("link")).toHaveCount(0);
|
||||
await expect(page.getByRole("navigation").getByRole("link")).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('can add contacts', async ({ page }) => {
|
||||
await verifyCreateUser(page, { names: ['John Contact'] });
|
||||
await verifyCreateUser(page, { names: ['Jack Contact'] });
|
||||
await expect(page.getByRole("navigation").getByRole("link")).toHaveCount(2);
|
||||
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 verifyCreateUser(page, { names: ['John Contact'] });
|
||||
await page.getByRole('link', { name: 'Mascarpone' }).click();
|
||||
await verifyCreateUser(page, { names: ['John Contact'] });
|
||||
await page.getByRole('link', { name: 'Mascarpone' }).click();
|
||||
|
||||
await expect(page.locator('#freshness')).toContainText('John Contactnever');
|
||||
await expect(page.locator('#freshness')).toContainText('John Contactnever');
|
||||
});
|
||||
|
||||
test('shows the date for fresh contacts', async ({ 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()}`);
|
||||
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 verifyCreateUser(page, { names: ['Zulu'] });
|
||||
await verifyCreateUser(page, { names: ['Alfa'] });
|
||||
await verifyCreateUser(page, { names: ['Golf'] });
|
||||
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/);
|
||||
await expect(page.getByRole('navigation')).toHaveText(/Alfa\s*Golf\s*Zulu/);
|
||||
});
|
||||
|
||||
test('upcoming and recent show at least one birthday a week away', async ({ page }) => {
|
||||
const monthday = d => d.toISOString().split("T")[0].replace(/^\d{4}-/, '');
|
||||
const today = monthday(new Date());
|
||||
const yesterday = monthday((() => {
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 1);
|
||||
return date;
|
||||
})());
|
||||
const tomorrow = monthday((() => {
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() + 1);
|
||||
return date;
|
||||
})());
|
||||
const aMonthAgo = monthday((() => {
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() - 28);
|
||||
return date;
|
||||
})());
|
||||
const inAMonth = monthday((() => {
|
||||
let date = new Date();
|
||||
date.setDate(date.getDate() + 28);
|
||||
return date;
|
||||
})());
|
||||
await verifyCreateUser(page, { names: ['Alfa'], birthday: today });
|
||||
await verifyCreateUser(page, { names: ['Beta'], birthday: yesterday });
|
||||
await verifyCreateUser(page, { names: ['Echo'], birthday: today });
|
||||
await verifyCreateUser(page, { names: ['Golf'], birthday: yesterday });
|
||||
await verifyCreateUser(page, { names: ['Lima'], birthday: tomorrow });
|
||||
await verifyCreateUser(page, { names: ['Mike'], birthday: yesterday });
|
||||
await verifyCreateUser(page, { names: ['Xray'], birthday: inAMonth });
|
||||
await verifyCreateUser(page, { names: ['Zulu'], birthday: aMonthAgo });
|
||||
|
||||
await page.goto('/');
|
||||
|
||||
await expect(page.locator('#upcoming').getByRole('link')).toHaveCount(4);
|
||||
await expect(page.locator('#recent').getByRole('link')).toHaveCount(4);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue