Merge pull request #257 from SELab-2/test/e2e

test: Basis en klassen E2E
This commit is contained in:
Tibo De Peuter 2025-05-16 23:05:10 +02:00 committed by GitHub
commit 17dd4a709e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 198 additions and 7 deletions

View file

@ -0,0 +1,81 @@
import { test, expect } from "@playwright/test";
test("Teacher can create new assignment", async ({ page }) => {
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "teacher" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerkracht1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
// Go to assignments
await expect(page.getByRole("banner").getByRole("link", { name: "Assignments" })).toBeVisible();
await page.getByRole("banner").getByRole("link", { name: "Assignments" }).click();
await expect(page.getByRole("heading", { name: "Assignments" })).toBeVisible();
await expect(page.getByRole("button", { name: "New Assignment" })).toBeVisible();
// Create new assignment
await page.getByRole("button", { name: "New Assignment" }).click();
await expect(page.getByRole("button", { name: "submit" })).toBeVisible();
await expect(page.getByRole("link", { name: "cancel" })).toBeVisible();
await page.getByRole("textbox", { name: "Title Title" }).fill("Assignment test 1");
await page.getByRole("textbox", { name: "Select a learning path Select" }).click();
await page.getByText("Using notebooks").click();
await page.getByRole("textbox", { name: "Pick a class Pick a class" }).click();
await page.getByText("class01").click();
await page.getByRole("textbox", { name: "Select Deadline Select" }).fill("2099-01-01T12:34");
await page.getByRole("textbox", { name: "Description Description" }).fill("Assignment description");
await page.getByRole("button", { name: "submit" }).click();
await expect(page.getByText("Assignment test")).toBeVisible();
await expect(page.getByRole("main").getByRole("button").first()).toBeVisible();
await expect(page.getByRole("main")).toContainText("Assignment test 1");
await expect(page.getByRole("link", { name: "Learning path" })).toBeVisible();
await expect(page.getByRole("main")).toContainText("Assignment description");
});
test("Student can see list of assignments", async ({ page }) => {
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "student" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerling1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
// Go to assignments
await expect(page.getByRole("banner").getByRole("link", { name: "Assignments" })).toBeVisible();
await page.getByRole("banner").getByRole("link", { name: "Assignments" }).click();
await expect(page.getByRole("heading", { name: "Assignments" })).toBeVisible();
await expect(page.getByText("dire straits")).toBeVisible();
await expect(page.locator(".button-row > .v-btn").first()).toBeVisible();
await expect(page.getByText("Class: class01").first()).toBeVisible();
});
test("Student can see assignment details", async ({ page }) => {
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "student" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerling1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
// Go to assignments
await expect(page.getByRole("banner").getByRole("link", { name: "Assignments" })).toBeVisible();
await page.getByRole("banner").getByRole("link", { name: "Assignments" }).click();
await expect(page.getByText("Assignment: Conditional")).toBeVisible();
await expect(page.locator("div:nth-child(2) > .v-card > .button-row > .v-btn")).toBeVisible();
// View assignment details
await page.locator("div:nth-child(2) > .v-card > .button-row > .v-btn").click();
await expect(page.getByText("Assignment: Conditional")).toBeVisible();
await expect(page.getByRole("link", { name: "Learning path" })).toBeVisible();
await expect(page.getByRole("progressbar").locator("div").first()).toBeVisible();
});

View file

@ -1,8 +1,16 @@
import { test, expect } from "./fixtures.js";
import { test, expect } from "@playwright/test";
test("Users can filter", async ({ page }) => {
await page.goto("/user");
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "teacher" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerkracht1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
// Filter
await page.getByRole("combobox").filter({ hasText: "Select a themeAll" }).locator("i").click();
await page.getByText("Nature and climate").click();
await page.getByRole("combobox").filter({ hasText: "Select ageAll agesSelect age" }).locator("i").click();

View file

@ -1,5 +0,0 @@
import { test, expect } from "./fixtures.js";
test("myTest", async ({ page }) => {
await expect(page).toHaveURL("/");
});

107
frontend/e2e/class.spec.ts Normal file
View file

@ -0,0 +1,107 @@
import { test, expect } from "@playwright/test";
test("Teacher can create a class", async ({ page }) => {
const className = "DeTijdLoze";
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "teacher" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerkracht1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
// Go to class
await expect(page.getByRole("banner").getByRole("link", { name: "Classes" })).toBeVisible();
await page.getByRole("banner").getByRole("link", { name: "Classes" }).click();
// Check if the class page is visible
await expect(page.getByRole("heading", { name: "Classes" })).toBeVisible();
await expect(page.getByRole("textbox", { name: "classname classname" })).toBeVisible();
await expect(page.getByRole("button", { name: "create" })).toBeVisible();
// Create a class
await page.getByRole("textbox", { name: "classname classname" }).click();
await page.getByRole("textbox", { name: "classname classname" }).fill(className);
await page.getByRole("button", { name: "create" }).click();
// Check if the class is created
await expect(page.getByRole("dialog").getByText("code")).toBeVisible();
await expect(page.getByRole("button", { name: "close" })).toBeVisible();
});
test("Teacher can share a class by code", async ({ page }) => {
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "teacher" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerkracht1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
// Go to classes
await expect(page.getByRole("banner").getByRole("link", { name: "Classes" })).toBeVisible();
await page.getByRole("banner").getByRole("link", { name: "Classes" }).click();
await expect(page.getByRole("row", { name: "class01" }).locator("i").nth(1)).toBeVisible();
await page.getByRole("row", { name: "class01" }).locator("i").nth(1).click();
await expect(page.getByRole("button").filter({ hasText: /^$/ }).nth(2)).toBeVisible();
await expect(page.getByRole("button").filter({ hasText: /^$/ }).nth(3)).toBeVisible();
await page.getByRole("button").filter({ hasText: /^$/ }).nth(3).click();
await expect(page.getByText("copied!")).toBeVisible();
await page.getByRole("button", { name: "close" }).click();
});
test("Student can join class by code", async ({ page }) => {
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "student" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerling1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
// Go to class
await expect(page.getByRole("banner").getByRole("link", { name: "Classes" })).toBeVisible();
await page.getByRole("banner").getByRole("link", { name: "Classes" }).click();
// Check if the class page is visible
await expect(page.getByRole("heading", { name: "Classes" })).toBeVisible();
await expect(page.getByRole("heading", { name: "Join class" })).toBeVisible();
await expect(page.getByRole("textbox", { name: "CODE CODE" })).toBeVisible();
await expect(page.getByRole("button", { name: "submit" })).toBeVisible();
// Join a class
await page.getByRole("textbox", { name: "CODE CODE" }).click();
await page.getByRole("textbox", { name: "CODE CODE" }).fill("X2J9QT");
await page.getByRole("button", { name: "submit" }).click();
});
test("Teacher can remove student from class", async ({ page }) => {
await page.goto("/");
// Login
await page.getByRole("link", { name: "log in" }).click();
await page.getByRole("button", { name: "teacher" }).click();
await page.getByRole("textbox", { name: "Username or email" }).fill("testleerkracht1");
await page.getByRole("textbox", { name: "Password" }).fill("password");
await page.getByRole("button", { name: "Sign In" }).click();
await expect(page.getByRole("banner").getByRole("link", { name: "Classes" })).toBeVisible();
await page.getByRole("banner").getByRole("link", { name: "Classes" }).click();
await expect(page.getByRole("link", { name: "class01" })).toBeVisible();
await expect(page.locator("#app")).toContainText("8");
await page.getByRole("link", { name: "class01" }).click();
await expect(page.getByRole("cell", { name: "Kurt Cobain" })).toBeVisible();
await expect(page.getByRole("row", { name: "Kurt Cobain remove" }).getByRole("button")).toBeVisible();
await page.getByRole("row", { name: "Kurt Cobain remove" }).getByRole("button").click();
await expect(page.getByText("Are you sure?")).toBeVisible();
await expect(page.getByRole("button", { name: "cancel" })).toBeVisible();
await expect(page.getByRole("button", { name: "yes" })).toBeVisible();
await page.getByRole("button", { name: "yes" }).click();
await page.getByRole("banner").getByRole("link", { name: "Classes" }).click();
await expect(page.locator("#app")).toContainText("7");
});