spec: show birthdays until a week out

This commit is contained in:
Robert Perce 2026-04-05 12:05:13 -05:00
parent 79a054ab40
commit 974bdcac34
3 changed files with 26 additions and 3 deletions

View file

@ -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"); await expect(page.title()).toContain("Test Testerson");
}); });

View file

@ -43,3 +43,26 @@ test('sidebar is sorted alphabetically', async ({ page }) => {
await expect(page.getByRole('navigation')).toHaveText(/Alfa\s*Golf\s*Zulu/); 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);
});

View file

@ -57,7 +57,7 @@ fn birthdays_section(
div id="birthdays" { div id="birthdays" {
h2 { "Birthdays" } h2 { "Birthdays" }
#birthday-sections { #birthday-sections {
.datelist { .datelist #upcoming {
h3 { "upcoming" } h3 { "upcoming" }
@for contact in &upcoming_birthdays[0..std::cmp::min(3, upcoming_birthdays.len())] { @for contact in &upcoming_birthdays[0..std::cmp::min(3, upcoming_birthdays.len())] {
a href=(format!("/contact/{}", contact.contact_id)) { a href=(format!("/contact/{}", contact.contact_id)) {
@ -68,7 +68,7 @@ fn birthdays_section(
} }
} }
} }
.datelist { .datelist #recent {
h3 { "recent" } h3 { "recent" }
@for contact in &prev_birthdays[0..std::cmp::min(3, prev_birthdays.len())] { @for contact in &prev_birthdays[0..std::cmp::min(3, prev_birthdays.len())] {
a href=(format!("/contact/{}", contact.contact_id)) { a href=(format!("/contact/{}", contact.contact_id)) {