feat: enhance manage page with new styling and reminder functionality
Updated the manage page to improve layout and styling, introducing a grid-based design for better organization. Added functionality for managing reminder emails, allowing users to enable or disable reminders directly from the interface. Enhanced the JavaScript logic to support the new reminder management features and updated related tests to ensure proper functionality.
This commit is contained in:
1 parent
caaeded467
commit
724d5a68ae
7 files changed
+536
-119
No files matched your search
@@ -333,10 +333,8 @@ describe('manage-link party size', () => {
|
||||
const html = await viewed.text();
|
||||
expect(viewed.status).toBe(200);
|
||||
expect(html).toContain('How many people?');
|
||||
expect(html).toContain('This signup holds that many spots.');
|
||||
expect(html).toContain('You don't need to add their names.');
|
||||
expect(html).toContain('Change how many people are coming. The signup stays, and the name stays the same.');
|
||||
expect(html).toContain('Save the number of people');
|
||||
expect(html).toContain('Including you. This holds that many spots, and the name stays the same.');
|
||||
expect(html).toContain('>Save<');
|
||||
expect(partyOptions(html)).toEqual(['1', '2', '3', '4', '5', '6']);
|
||||
expect(html).toContain('<dd>4</dd>');
|
||||
expect(db.prepare('SELECT group_size, updated_at FROM signups').get()).toEqual({
|
||||
|
||||
+16
-3
@@ -176,10 +176,11 @@ describe('reminder mail', () => {
|
||||
const saved = reserveSignup(db, reservation(shiftId));
|
||||
expect(saved.ok && saved.manageToken).toBeTruthy();
|
||||
if (!saved.ok || !saved.manageToken) return;
|
||||
queueDueReminders(db, MAIL, SECRET, NOW);
|
||||
const page = await app.request(`/m/${saved.manageToken}`);
|
||||
const html = await page.text();
|
||||
const token = /name="reminder_token"[^>]*value="([^"]*)"/.exec(html)?.[1] ?? '';
|
||||
expect(html).toContain('Stop reminder emails');
|
||||
expect(html).toContain('data-reminder-toggle');
|
||||
|
||||
const stopped = await app.request(`/m/${saved.manageToken}/reminders`, {
|
||||
method: 'POST',
|
||||
@@ -188,10 +189,22 @@ describe('reminder mail', () => {
|
||||
});
|
||||
expect(stopped.status).toBe(303);
|
||||
expect(db.prepare(`SELECT reminders_off, status FROM signups`).get()).toEqual({ reminders_off: 1, status: 'confirmed' });
|
||||
expect(db.prepare(`SELECT status FROM outbox WHERE kind = 'reminder'`).get()).toEqual({ status: 'cancelled' });
|
||||
const after = await app.request(`/m/${saved.manageToken}`);
|
||||
const afterHtml = await after.text();
|
||||
expect(afterHtml).toContain('Reminder emails for this signup are off.');
|
||||
expect(afterHtml).not.toContain('name="reminder_token"');
|
||||
expect(afterHtml).toContain('name="reminder_token"');
|
||||
expect(afterHtml).not.toContain('checked');
|
||||
|
||||
const resumed = await app.request(`/m/${saved.manageToken}/reminders`, {
|
||||
method: 'POST',
|
||||
headers: { origin: ORIGIN, 'content-type': 'application/x-www-form-urlencoded' },
|
||||
body: new URLSearchParams({ reminder_token: token, reminders: 'on' }),
|
||||
});
|
||||
expect(resumed.status).toBe(303);
|
||||
expect(db.prepare(`SELECT reminders_off, status FROM signups`).get()).toEqual({ reminders_off: 0, status: 'confirmed' });
|
||||
expect(db.prepare(`SELECT status FROM outbox WHERE kind = 'reminder'`).get()).toEqual({ status: 'pending' });
|
||||
const resumedHtml = await (await app.request(`/m/${saved.manageToken}`)).text();
|
||||
expect(resumedHtml).toContain('checked');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user