diff --git a/e2e/pages/contact.spec.ts b/e2e/pages/contact.spec.ts index dad20e5..f097089 100644 --- a/e2e/pages/contact.spec.ts +++ b/e2e/pages/contact.spec.ts @@ -49,7 +49,7 @@ test('bullet points in free text display well', async ({ page }) => { }); -twst('page title has contact primary name', async ({ page }) => { +test('page title has contact primary name', async ({ page }) => { await expect(page.title()).toContain("Test Testerson"); }); diff --git a/e2e/pages/home.spec.ts b/e2e/pages/home.spec.ts index 13b9fa1..61ee12a 100644 --- a/e2e/pages/home.spec.ts +++ b/e2e/pages/home.spec.ts @@ -43,3 +43,26 @@ test('sidebar is sorted alphabetically', async ({ page }) => { await expect(page.getByRole('navigation')).toHaveText(/Alfa\s*Golf\s*Zulu/); }); + +test('always shows 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 tomorrow = monthday((() => { + let date = new Date(); + date.setDate(date.getDate() + 1); + 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: tomorrow }); + await verifyCreateUser(page, { names: ['Echo'], birthday: today }); + await verifyCreateUser(page, { names: ['Golf'], birthday: tomorrow }); + await verifyCreateUser(page, { names: ['Zulu'], birthday: inAMonth }); + + await expect(page.locator('#upcoming').getByRole('link')).toHaveCount(5); + +}); diff --git a/src/web/home.rs b/src/web/home.rs index 36c2a31..3a9ad50 100644 --- a/src/web/home.rs +++ b/src/web/home.rs @@ -57,7 +57,7 @@ fn birthdays_section( div id="birthdays" { h2 { "Birthdays" } #birthday-sections { - .datelist { + .datelist #upcoming { h3 { "upcoming" } @for contact in &upcoming_birthdays[0..std::cmp::min(3, upcoming_birthdays.len())] { a href=(format!("/contact/{}", contact.contact_id)) { @@ -68,7 +68,7 @@ fn birthdays_section( } } } - .datelist { + .datelist #recent { h3 { "recent" } @for contact in &prev_birthdays[0..std::cmp::min(3, prev_birthdays.len())] { a href=(format!("/contact/{}", contact.contact_id)) {