Skip to content

Commit

Permalink
Tests to event page components addition + bug fixes (#229)
Browse files Browse the repository at this point in the history
Co-authored-by: sonylomo <sonylomo1@gmail.com>

[Have you read the contributing guidelines ?](https://github.com/SpaceyaTech/SYT-Web-Redesign/blob/Dev/docs/CONTRIBUTING.md)

# What is the purpose of your _pull request_?

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation

# Proposed changes

# Warning

Please read these points carefully and answer honestly with an `X`
into all the boxes. Example : [X]

Before submitting a _pull request_ make sure you have:

- [ ] Read the guidelines for contributing.
- [ ] Wrote some tests.
- [ ] Respected the linting guidelines (read the guide below for help).

## How to Check and Fix Linting Issues

Run `npm run validate`. This command will run prettier and eslint checks to ensure linting guidelines are respected.

- If the command exits with code 0 (build is successful), there are no linting issues.

- If the command exits with a code other than 0, scroll up the command output and look for identified linting issues. Fix them and revalidate to check if the issues have been resolved by re-running the command.
  • Loading branch information
CodedVeli committed Sep 16, 2024
1 parent c28a4bb commit 41c7704
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/GoBackBtn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function GoBackBtn() {
return (
<NavLink
to={-1}
data-testid="go-back-button"
className="border cursor-pointer rounded-full bg-white p-1 w-fit"
>
<div className="flex-center bg-green-light rounded-full px-3 py-1.5 gap-2">
Expand Down
10 changes: 8 additions & 2 deletions src/pages/events/sections/EventsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ function EventsSection() {

{isSuccess && (
<div className="w-full flex items-center flex-col">
<div className="flex items-center justify-between mb-6 gap-12">
<div
data-testId="categories-list"
className="flex items-center justify-between mb-6 gap-12"
>
{isSuccess && (
<div className="flex items-center justify-center space-x-4 w-full md:w-fit mx-auto overflow-auto">
{uniqueCategory.map((category) => (
Expand All @@ -110,7 +113,10 @@ function EventsSection() {
)}
</div>

<div className="w-full grid grid-cols-1 sm:grid-cols-2 place-content-center lg:grid-cols-3 gap-8">
<div
data-testId="events-list"
className="w-full grid grid-cols-1 sm:grid-cols-2 place-content-center lg:grid-cols-3 gap-8"
>
{/* {Array.isArray(events) &&
events.map((event) => <EventCard key={event.id} event={event} />)} */}
{filteredEvents?.map((event) => (
Expand Down
48 changes: 48 additions & 0 deletions tests/pages/events-page.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { expect, test } from "@playwright/test";

Check failure on line 1 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start

2) [chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start Test timeout of 30000ms exceeded.

Check failure on line 1 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start

2) [chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Test timeout of 30000ms exceeded.

Check failure on line 1 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start

2) [chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Test timeout of 30000ms exceeded.

Check failure on line 1 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:39:3 › Events page tests › should have categories list on start

3) [chromium] › pages/events-page.spec.js:39:3 › Events page tests › should have categories list on start Test timeout of 30000ms exceeded.

test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:5173/events");
});

test.describe("Events page tests", () => {
test("should have correct metadata", async ({ page }) => {
await expect(page).toHaveTitle("Upcoming Events - SpaceYaTech");
const descriptionMeta = await page.locator("meta[name='description']");
await expect(descriptionMeta).toHaveAttribute(
"content",
"Upcoming tech events powered by SpaceYaTech."
);
const ogImageMeta = await page.locator("meta[property='og:image']");
await expect(ogImageMeta).toHaveAttribute(
"content",
"https://apis.spaceyatech.com/media/blog-images/syt.png"
);
});
test("should have a go back button", async ({ page }) => {
const goBackButton = page.getByTestId("go-back-button");
await expect(goBackButton).toBeVisible();
});

test("should have a featured carousel", async ({ page }) => {
const featuredCarousel = page.locator("text=Featured Events");
await expect(featuredCarousel).toBeVisible();

Check failure on line 28 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:26:3 › Events page tests › should have a featured carousel

1) [chromium] › pages/events-page.spec.js:26:3 › Events page tests › should have a featured carousel Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: locator('text=Featured Events') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for locator('text=Featured Events') 26 | test("should have a featured carousel", async ({ page }) => { 27 | const featuredCarousel = page.locator("text=Featured Events"); > 28 | await expect(featuredCarousel).toBeVisible(); | ^ 29 | }); 30 | test("should have a Search event", async ({ page }) => { 31 | await expect(page.getByRole("button", { name: "Search" })).toBeVisible(); at /home/runner/work/SYT-Web-Redesign/SYT-Web-Redesign/tests/pages/events-page.spec.js:28:36

Check failure on line 28 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:26:3 › Events page tests › should have a featured carousel

1) [chromium] › pages/events-page.spec.js:26:3 › Events page tests › should have a featured carousel Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: locator('text=Featured Events') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for locator('text=Featured Events') 26 | test("should have a featured carousel", async ({ page }) => { 27 | const featuredCarousel = page.locator("text=Featured Events"); > 28 | await expect(featuredCarousel).toBeVisible(); | ^ 29 | }); 30 | test("should have a Search event", async ({ page }) => { 31 | await expect(page.getByRole("button", { name: "Search" })).toBeVisible(); at /home/runner/work/SYT-Web-Redesign/SYT-Web-Redesign/tests/pages/events-page.spec.js:28:36

Check failure on line 28 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:26:3 › Events page tests › should have a featured carousel

1) [chromium] › pages/events-page.spec.js:26:3 › Events page tests › should have a featured carousel Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: locator('text=Featured Events') Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for locator('text=Featured Events') 26 | test("should have a featured carousel", async ({ page }) => { 27 | const featuredCarousel = page.locator("text=Featured Events"); > 28 | await expect(featuredCarousel).toBeVisible(); | ^ 29 | }); 30 | test("should have a Search event", async ({ page }) => { 31 | await expect(page.getByRole("button", { name: "Search" })).toBeVisible(); at /home/runner/work/SYT-Web-Redesign/SYT-Web-Redesign/tests/pages/events-page.spec.js:28:36
});
test("should have a Search event", async ({ page }) => {
await expect(page.getByRole("button", { name: "Search" })).toBeVisible();
});
test("should have event list on start", async ({ page }) => {
await page.waitForSelector("[data-testId=\"events-list\"]");

Check failure on line 34 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start

2) [chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start Error: page.waitForSelector: Test timeout of 30000ms exceeded. Call log: - waiting for locator('[data-testId="events-list"]') to be visible 32 | }); 33 | test("should have event list on start", async ({ page }) => { > 34 | await page.waitForSelector("[data-testId=\"events-list\"]"); | ^ 35 | const eventsList = page.getByTestId("events-list"); 36 | await expect(eventsList).toBeVisible(); 37 | }); at /home/runner/work/SYT-Web-Redesign/SYT-Web-Redesign/tests/pages/events-page.spec.js:34:16

Check failure on line 34 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start

2) [chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: page.waitForSelector: Test timeout of 30000ms exceeded. Call log: - waiting for locator('[data-testId="events-list"]') to be visible 32 | }); 33 | test("should have event list on start", async ({ page }) => { > 34 | await page.waitForSelector("[data-testId=\"events-list\"]"); | ^ 35 | const eventsList = page.getByTestId("events-list"); 36 | await expect(eventsList).toBeVisible(); 37 | }); at /home/runner/work/SYT-Web-Redesign/SYT-Web-Redesign/tests/pages/events-page.spec.js:34:16

Check failure on line 34 in tests/pages/events-page.spec.js

View workflow job for this annotation

GitHub Actions / tests

[chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start

2) [chromium] › pages/events-page.spec.js:33:3 › Events page tests › should have event list on start Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: page.waitForSelector: Test timeout of 30000ms exceeded. Call log: - waiting for locator('[data-testId="events-list"]') to be visible 32 | }); 33 | test("should have event list on start", async ({ page }) => { > 34 | await page.waitForSelector("[data-testId=\"events-list\"]"); | ^ 35 | const eventsList = page.getByTestId("events-list"); 36 | await expect(eventsList).toBeVisible(); 37 | }); at /home/runner/work/SYT-Web-Redesign/SYT-Web-Redesign/tests/pages/events-page.spec.js:34:16
const eventsList = page.getByTestId("events-list");
await expect(eventsList).toBeVisible();
});

test("should have categories list on start", async ({ page }) => {
await page.waitForSelector("[data-testId=\"categories-list\"]");
const categoriesList = page.getByTestId("categories-list");
await expect(categoriesList).toBeVisible();
});

test("should have a loader when loading events", async ({ page }) => {
await expect(page.getByText("Loading events...")).toBeVisible();
});
});
39 changes: 39 additions & 0 deletions vite.config.js.timestamp-1726468811508-c6c9efaa18449.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// vite.config.js
import path, { dirname } from "path";
import { fileURLToPath } from "url";
import react from "file:///home/kibuchi/Projects/SYT/SYT-Web-Redesign/node_modules/@vitejs/plugin-react/dist/index.mjs";
import million from "file:///home/kibuchi/Projects/SYT/SYT-Web-Redesign/node_modules/million/dist/packages/compiler.mjs";
import {
defineConfig,
loadEnv,
} from "file:///home/kibuchi/Projects/SYT/SYT-Web-Redesign/node_modules/vite/dist/node/index.js";
var __vite_injected_original_import_meta_url =
"file:///home/kibuchi/Projects/SYT/SYT-Web-Redesign/vite.config.js";
var __filename = fileURLToPath(__vite_injected_original_import_meta_url);
var __dirname = dirname(__filename);
var vite_config_default = defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
define: {
"process.env.REACT_APP_API_BASE_URL": JSON.stringify(
env.REACT_APP_API_BASE_URL
),
},
plugins: [million.vite({ auto: true }), react()],
test: {
include: ["src/**/*.test.js"],
},
server: {
watch: {
usePolling: true,
},
},
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
};
});
export { vite_config_default as default };
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvaG9tZS9raWJ1Y2hpL1Byb2plY3RzL1NZVC9TWVQtV2ViLVJlZGVzaWduXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvaG9tZS9raWJ1Y2hpL1Byb2plY3RzL1NZVC9TWVQtV2ViLVJlZGVzaWduL3ZpdGUuY29uZmlnLmpzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9ob21lL2tpYnVjaGkvUHJvamVjdHMvU1lUL1NZVC1XZWItUmVkZXNpZ24vdml0ZS5jb25maWcuanNcIjsvKiBlc2xpbnQtZGlzYWJsZSBpbXBvcnQvbm8tZXh0cmFuZW91cy1kZXBlbmRlbmNpZXMgKi9cbi8qIGVzbGludC1kaXNhYmxlIG5vLX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