Skip to content

Commit c115c76

Browse files
committed
test: Add test to ensure teachers can delete rubrics
1 parent 1fab4c2 commit c115c76

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

e2e/rubrics/CreateRubric.spec.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,50 @@ test.describe.serial("Rubrics creation workflow", () => {
9090
await expect(
9191
rubricRow.getByRole("link", { name: `Edit ${rubricName}`, exact: true })
9292
).toBeVisible();
93+
await expect(
94+
rubricRow.getByRole("button", {
95+
name: `Delete ${rubricName}`,
96+
exact: true
97+
})
98+
).toBeVisible();
99+
});
100+
101+
test("Teachers can delete rubrics", async ({ page }) => {
102+
// Login as the teacher
103+
await page.goto("/login");
104+
await page.getByLabel("Email").fill(teacherEmail);
105+
await page.getByLabel("Password").fill(teacherPassword);
106+
await page.getByRole("button", { name: "Submit" }).click();
107+
108+
// Go to the rubrics page
109+
await page.getByRole("link", { name: "Rubrics", exact: true }).click();
110+
await page.waitForURL(/\/rubrics$/);
111+
112+
// Delete the rubric
113+
await page
114+
.getByRole("button", { name: `Delete ${rubricName}`, exact: true })
115+
.click();
116+
117+
// Assert the confirmation dialog is open
118+
const confirmationModalText =
119+
"Are you sure you want to delete this rubric?";
120+
await expect(
121+
page.getByText(confirmationModalText, { exact: true })
122+
).toBeVisible();
123+
124+
// Confirm the deletion
125+
await page.getByRole("button", { name: "Proceed", exact: true }).click();
126+
127+
// Assert the alert is shown
128+
await expect(page.getByText("The rubric has been deleted")).toBeVisible();
129+
130+
// Assert the rubric is not shown in the table
131+
const rubricRow = page.getByRole("row", {
132+
name: /Data structures rubric/i
133+
});
134+
await expect(rubricRow).not.toBeVisible();
135+
136+
// Assert the empty state is shown
137+
await expect(page.getByText("No results.")).toBeVisible();
93138
});
94139
});

src/screens/rubrics-list/components/RubricsTable.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export const RubricsTable = ({ isLoading, rubrics }: rubricsTableProps) => {
6969
rubrics.map((rubric) => (
7070
<TableRow key={rubric.uuid}>
7171
<TableCell className="line-clamp-1">{rubric.name}</TableCell>
72-
<TableCell>
73-
<div className="flex flex-wrap gap-4">
72+
<TableCell className="w-min">
73+
<div className="flex max-w-sm flex-wrap gap-4">
7474
<Link
7575
to={`/rubrics/${rubric.uuid}`}
7676
aria-label={`Edit ${rubric.name}`}
@@ -81,6 +81,7 @@ export const RubricsTable = ({ isLoading, rubrics }: rubricsTableProps) => {
8181
</Link>
8282
<Button
8383
variant="destructive"
84+
aria-label={`Delete ${rubric.name}`}
8485
onClick={() => {
8586
setDeleteRubricDialogState((prevState) => ({
8687
...prevState,

0 commit comments

Comments
 (0)