Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update course e2e tests to rely on status messages #395

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
53 changes: 39 additions & 14 deletions apps/web/e2e/tests/admin/course-settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CourseActions {
}

async openCourse(): Promise<void> {
await this.page.getByRole("row", { name: TEST_COURSE.name }).click();
await this.page.getByText(TEST_COURSE.name).click();
await this.page.waitForURL(URL_PATTERNS.course);
await expect(this.page).toHaveURL(URL_PATTERNS.course);
await this.verifyCourseContent();
Expand All @@ -46,38 +46,53 @@ test.describe.serial("Course E2E", () => {
await page.getByRole("tab", { name: "Pricing" }).click();
await page.getByText("Free").click();
await page.getByRole("button", { name: "Save" }).click();
await page.reload();

await expect(page.locator("#isFree")).toBeChecked();
await expect(
page
.getByRole("status", { includeHidden: true })
.getByText("Course updated successfully", { exact: true }),
).toBeVisible();
});

test("should change course price to paid", async ({ page }) => {
await page.getByRole("tab", { name: "Pricing" }).click();
await page.getByText("Paid course").click();
await page.getByPlaceholder("Amount").fill("42069");
await page.getByRole("button", { name: "Save" }).click();
await page.reload();

await expect(page.locator("#isPaid")).toBeChecked();
await expect(
page
.getByRole("status", { includeHidden: true })
.getByText("Course updated successfully", { exact: true }),
).toBeVisible();

await page.getByText("Free").click();
await page.getByText("Paid course").click();
await expect(page.getByPlaceholder("Amount")).toHaveValue("42,069.00");
});

test("should change course status to draft", async ({ page }) => {
await page.getByRole("tab", { name: "Status" }).click();
await page.getByText("Draft").click();
await page.getByRole("button", { name: "Save" }).click();
await page.reload();

await expect(page.locator("#draft")).toBeChecked();
await expect(
page
.getByRole("status", { includeHidden: true })
.getByText("Course updated successfully", { exact: true }),
).toBeVisible();
});

test("should change course status to published", async ({ page }) => {
await page.getByRole("tab", { name: "Status" }).click();
await page.getByLabel("Published").click();
await page.getByRole("button", { name: "Save" }).click();
await page.reload();

await expect(page.locator("#published")).toBeChecked();
await expect(
page
.getByRole("status", { includeHidden: true })
.getByText("Course updated successfully", { exact: true }),
).toBeVisible();
});

test("should change course title", async ({ page }) => {
Expand Down Expand Up @@ -109,20 +124,30 @@ test.describe.serial("Course E2E", () => {
await page.getByLabel("Course title").fill(TEST_COURSE.name);
await page.getByLabel("Description").fill(TEST_COURSE.course_description);
await page.getByRole("button", { name: "Save" }).click();
await page.reload();
await expect(
page
.getByRole("status", { includeHidden: true })
.getByText("Course updated successfully", { exact: true }),
).toBeVisible();
await expect(page.getByRole("heading", { name: TEST_COURSE.name, level: 4 })).toBeVisible();
await expect(page.getByLabel("Description")).toHaveValue(TEST_COURSE.course_description);

await page.getByRole("tab", { name: "Pricing" }).click();
await page.getByText("Free").click();
await page.getByRole("button", { name: "Save" }).click();
await page.reload();
await expect(page.locator("#isFree")).toBeChecked();
await expect(
page
.getByRole("status", { includeHidden: true })
.getByText("Course updated successfully", { exact: true }),
).toBeVisible();

await page.getByRole("tab", { name: "Status" }).click();
await page.getByLabel("Published").click();
await page.getByRole("button", { name: "Save" }).click();
await page.reload();
await expect(page.locator("#published")).toBeChecked();
await expect(
page
.getByRole("status", { includeHidden: true })
.getByText("Course updated successfully", { exact: true }),
).toBeVisible();
});
});
Loading