Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions client/e2e/tests/30-shift-release.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,77 @@ test.describe("shift release embargo (#869)", () => {
.status()
).toBe(201);
});

test("closed window hides it; a shift-type window covers meetings too", async ({
request,
}) => {
const db = getPool();
await db.execute("DELETE FROM op_shift_release");
// all on-playa shifts: open since 2001, closed in 2002
await db.execute(
"INSERT INTO op_shift_release (embargo_from, release_at, close_at, announced_at) VALUES (?, '2001-01-01 09:00:00', '2002-01-01 09:00:00', NOW())",
[shiftDate]
);
// the meeting's own type: not open until 2099
await db.execute(
"INSERT INTO op_shift_release (embargo_from, shift_name_id, release_at, announced_at) VALUES (?, ?, '2099-12-31 09:00:00', NOW())",
[shiftDate, MEETING.shiftNameId]
);
const mine = await shifts(request, volunteer.shiftboardId);
expect(
mine.find((s) => s.id === FUTURE_SHIFT.shiftTimesId)
).toBeUndefined();
expect(mine.find((s) => s.id === MEETING.shiftTimesId)).toBeUndefined();
const admins = await shifts(request, ADMIN);
expect(admins.find((s) => s.id === FUTURE_SHIFT.shiftTimesId)).toBeTruthy();

const pre = await request.post(
`/api/shifts/${FUTURE_SHIFT.shiftTimesId}/volunteers/preflight`,
{
headers: as(volunteer.shiftboardId),
data: JSON.stringify({
shiftboardId: volunteer.shiftboardId,
timePositionId: FUTURE_SHIFT.timePositionId,
}),
}
);
const { blockers } = await pre.json();
expect(blockers.map((b: { code: string }) => b.code)).toContain(
"publish-closed"
);

const post = (body: object) =>
request.post("/api/shift-release", {
headers: as(ADMIN),
data: JSON.stringify(body),
});
expect(
(
await post({
closeAt: "2099-05-01T09:00",
embargoFrom: "2099-01-01",
releaseAt: "2099-06-01T09:00",
})
).status()
).toBe(400); // closes before it opens
expect(
(
await post({
closeAt: "2099-07-01T09:00",
embargoFrom: "2099-01-01",
releaseAt: "2099-06-01T09:00",
shiftNameId: MEETING.shiftNameId,
})
).status()
).toBe(201);
const rows = await (
await request.get("/api/shift-release", { headers: as(ADMIN) })
).json();
expect(rows).toContainEqual(
expect.objectContaining({
closeAt: "2099-07-01 09:00:00",
shiftName: MEETING.shiftName,
})
);
});
});
8 changes: 6 additions & 2 deletions client/src/app/dates/Dates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ import {
MenuItem,
MenuList,
Stack,
Typography,
useTheme,
} from "@mui/material";
import { useState } from "react";
import useSWR from "swr";
import { Hero } from "@/components/layout/Hero";
import Link from "next/link";

import { DatesDialogCreate } from "@/app/dates/DatesDialogCreate";
import { DatesDialogDelete } from "@/app/dates/DatesDialogDelete";
import { DatesDialogUpdate } from "@/app/dates/DatesDialogUpdate";
import { ShiftRelease } from "@/app/dates/ShiftRelease";
import { DataTable } from "@/components/general/DataTable";
import { ErrorPage } from "@/components/general/ErrorPage";
import { Loading } from "@/components/general/Loading";
Expand Down Expand Up @@ -233,7 +234,10 @@ export const Dates = () => {
dateList={data}
/>
</Box>
<ShiftRelease />
<Typography sx={{ mt: 4 }}>
When shifts open and close for sign-up is on{" "}
<Link href="/publishing">Publishing</Link>.
</Typography>
</Container>
</>
);
Expand Down
106 changes: 0 additions & 106 deletions client/src/app/dates/ShiftRelease.tsx

This file was deleted.

Loading
Loading