Flag overnight blocks in the v2 schedule API
This commit is contained in:
@@ -86,7 +86,7 @@ describe('GET /api/v2/schedule auth', () => {
|
||||
});
|
||||
|
||||
describe('GET /api/v2/schedule success', () => {
|
||||
it('returns only proclamation IDs even when the key is inactive', async () => {
|
||||
it('returns only proclamation IDs, marking an overnight block, even when the key is inactive', async () => {
|
||||
licenseKeyFindUnique.mockResolvedValue({
|
||||
key: KEY,
|
||||
userId: 'user-1',
|
||||
@@ -97,8 +97,8 @@ describe('GET /api/v2/schedule success', () => {
|
||||
blockFindMany.mockResolvedValue([
|
||||
{
|
||||
id: 'block-1',
|
||||
startMinutes: 360,
|
||||
endMinutes: 480,
|
||||
startMinutes: 21 * 60,
|
||||
endMinutes: 9 * 60,
|
||||
proclamations: [{ proclamation: { id: 'p1' } }, { proclamation: { id: 'p2' } }]
|
||||
}
|
||||
]);
|
||||
@@ -111,10 +111,12 @@ describe('GET /api/v2/schedule success', () => {
|
||||
blocks: [
|
||||
{
|
||||
id: 'block-1',
|
||||
startTime: '06:00',
|
||||
startMinutes: 360,
|
||||
endTime: '08:00',
|
||||
endMinutes: 480,
|
||||
startTime: '21:00',
|
||||
startMinutes: 1260,
|
||||
endTime: '09:00',
|
||||
endMinutes: 540,
|
||||
overnight: true,
|
||||
durationMinutes: 720,
|
||||
proclamationIds: ['p1', 'p2']
|
||||
}
|
||||
]
|
||||
@@ -134,9 +136,20 @@ describe('GET /api/v2/schedule success', () => {
|
||||
]);
|
||||
|
||||
const response = await call({ email: 'jane@example.com', licenseKey: KEY });
|
||||
const body = (await response.json()) as { blocks: { proclamationIds: string[] }[] };
|
||||
const body = (await response.json()) as {
|
||||
blocks: { proclamationIds: string[]; overnight: boolean; durationMinutes: number }[];
|
||||
};
|
||||
|
||||
expect(body.blocks[0].proclamationIds).toEqual(['p1']);
|
||||
expect(body.blocks[0]).toEqual({
|
||||
id: 'block-1',
|
||||
startTime: '00:00',
|
||||
startMinutes: 0,
|
||||
endTime: '01:00',
|
||||
endMinutes: 60,
|
||||
overnight: false,
|
||||
durationMinutes: 60,
|
||||
proclamationIds: ['p1']
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts the legacy `key` query alias and an email-only license', async () => {
|
||||
|
||||
Reference in New Issue
Block a user