Skip to content

Commit

Permalink
fix(frontend): ✅ fix blog end2end test to only acces… (#355)
Browse files Browse the repository at this point in the history
* fix(frontend): ✅ fix blog end2end test to only access first element

* refactor(ide): ♻️ move project en2end test into end2end folder

* test(frontend): ✅ add satellite end2end test

* style(frontend): 🚨 run prettier
  • Loading branch information
Mats authored and GitHub committed Apr 22, 2024
1 parent 831f6ef commit 6b7a2aa
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
2 changes: 2 additions & 0 deletions frontend/tests/componentTests/SatelliteSelector.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import SatelliteSelector from "@/components/homeComponents/SatelliteSelector";
import { test, expect } from "@playwright/experimental-ct-react";
6 changes: 4 additions & 2 deletions frontend/tests/e2e/blog.desktop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ test.describe("Blogs pages test", () => {
await expect(page.getByTestId("pageSubtitle")).toBeVisible();
await page.getByTestId("blogsSatellitesButton").click();
await expect(page).toHaveURL("/blog?page=1&tag=Satellites");
await expect(page.getByTestId("articleTag")).toHaveText("Satellites");
await page.getByTestId("blogCardLink").click();
await expect(page.getByTestId("articleTag").first()).toHaveText(
"Satellites",
);
await page.getByTestId("blogCardLink").first().click();
await expect(page).toHaveURL(/\/blog\/.+$/);
});
test("individualBlogPagetest", async ({ page }) => {
Expand Down
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions frontend/tests/e2e/satellite.desktop.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test, expect } from "@playwright/test";

test.describe("All Satellites Page Test", () => {
test("CheckHeadingAndSubtitleIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(page.getByTestId("pageHeader")).toBeVisible();
await expect(page.getByTestId("pageSubtitle")).toBeVisible();
});
test("CheckIfCardIsClickable", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(
page.getByTestId("satellitesTableRow").first(),
).toBeVisible();
await page.getByTestId("satellitesTableRow").first().click();
//Checks if the URL matches /satellites/anySlug
await expect(page).toHaveURL(/\/satellites\/.+$/);
});
});

test.describe("Individual Satellite Page Test", () => {
test("TestHeadingAndParagraphIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("button", { name: "Satellites" }).click();
await page.getByTestId("satellitesTableRow").first().click();
await expect(page).toHaveURL(/\/satellites\/.+$/);
await expect(page.getByRole("heading").first()).toBeVisible();
await expect(page.getByRole("heading").nth(2)).toBeVisible();
await expect(page.getByTestId("blockParagraph").first()).toBeVisible();
});
});
45 changes: 45 additions & 0 deletions frontend/tests/e2e/satellite.mobile.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { test, expect } from "@playwright/test";

test.describe("All Satellites Page Test", () => {
test.use({
viewport: { width: 390, height: 844 },
});

test("CheckHeadingAndSubtitleIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("navigation").getByRole("button").click();
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(page.getByTestId("pageHeader")).toBeVisible();
await expect(page.getByTestId("pageSubtitle")).toBeVisible();
});
test("CheckIfCardIsClickable", async ({ page }) => {
await page.goto("/");
await page.getByRole("navigation").getByRole("button").click();
await page.getByRole("button", { name: "Satellites" }).click();
await expect(page).toHaveURL("/satellites");
await expect(
page.getByTestId("satellitesTableRow").first(),
).toBeVisible();
await page.getByTestId("satellitesTableRow").first().click();
//Checks if the URL matches /satellites/anySlug
await expect(page).toHaveURL(/\/satellites\/.+$/);
});
});

test.describe("Individual Satellite Page Test", () => {
test.use({
viewport: { width: 390, height: 844 },
});

test("TestHeadingAndParagraphIsVisible", async ({ page }) => {
await page.goto("/");
await page.getByRole("navigation").getByRole("button").click();
await page.getByRole("button", { name: "Satellites" }).click();
await page.getByTestId("satellitesTableRow").first().click();
await expect(page).toHaveURL(/\/satellites\/.+$/);
await expect(page.getByRole("heading").first()).toBeVisible();
await expect(page.getByRole("heading").nth(2)).toBeVisible();
await expect(page.getByTestId("blockParagraph").first()).toBeVisible();
});
});

0 comments on commit 6b7a2aa

Please sign in to comment.