tests: e2e testing course#254
Conversation
Rei-x
left a comment
There was a problem hiding this comment.
spoko teściki napisane, sporo rzeczy zostało przetestowane, jedyne czego mi brakuje to jakiejś miłości do organizacji tych testów, wszystko jest w jednym pliku i nie ma żadnych describe ani nic 😭
dodatkowo raczej nie powinno się używać testId oraz locatorów - sugeruje to, że masz mało dostępny kodzik
|
|
||
| await chosenFaculty.click(); | ||
|
|
||
| const registrationButton = page.locator('button[name="registration"]'); |
There was a problem hiding this comment.
raczej nie powinno się używać locatora, jak jest taka opcja to użyj getByRole (i popraw kod, żeby dało się go użyć)
| @@ -0,0 +1,22 @@ | |||
| import type { Page } from "@playwright/test"; | |||
|
|
|||
| export const selectFacultyAndRegistration = async (page: Page) => { | |||
There was a problem hiding this comment.
żeby zrobić reużywalny kodzik w playwrighcie popularny jest POM (Page Object Model) - zachęcam do poczytania sobie:3
| test("should show empty plans page without logging in on first visit", async ({ | ||
| page, | ||
| }) => { | ||
| await page.goto(BASE_URL); |
There was a problem hiding this comment.
mogłeś to sobie w opcje playwrighta wrzucić, wtedy mógłbyś tu tylko dać:
| await page.goto(BASE_URL); | |
| await page.goto("/"); |
https://playwright.dev/docs/api/class-testoptions#test-options-base-url
| page, | ||
| }) => { | ||
| await page.goto(`${BASE_URL}/plans`); | ||
| await page.getByTestId("add-new-plan-button").click(); |
There was a problem hiding this comment.
oj, używanie testId to powinna być ostateczność, raczej wypadałoby przerobić ten kod albo test, żeby najlepiej używać getByRole
There was a problem hiding this comment.
mogłeś ten plik podzielić na parę różnych zamiast robić jeden duży o nazwie "tests" 😭
| import { BASE_URL, INVALID_EMAIL, VALID_EMAIL } from "./utils/const"; | ||
| import { selectFacultyAndRegistration } from "./utils/helpers"; | ||
|
|
||
| test("should show empty plans page without logging in on first visit", async ({ |
There was a problem hiding this comment.
brakuje mi jakichś test.describe tutaj, wszystko jest wrzucone do jednego worka i nie wiadomo co do czego jest
| page, | ||
| }) => { | ||
| await page.route( | ||
| "**/departments/*/registrations/*/courses", |
There was a problem hiding this comment.
da się też w ogóle msw w playwrightcie używać jakbyś był ciekawy: https://github.com/mswjs/playwright
| await expect(firstSelectedCourse).toBeVisible(); | ||
|
|
||
| await page.getByText(/skopiuj/i).click(); | ||
| await page.waitForTimeout(2000); |
There was a problem hiding this comment.
no raczej coś takiego to powinna być ostateczność, lepiej używaj jakichś expect.poll albo zwiększ timeout na domyślnym czekaniu playwrighta
| await page.goto(BASE_URL); | ||
| await page.getByText(/błąd/i).click(); | ||
|
|
||
| const emailInput = page.locator('input[name="email"]'); |
There was a problem hiding this comment.
tutaj raczej po labelu lepiej się dostać
bez logowania
Important
Add end-to-end tests for course planning features using Playwright, including plan creation, editing, deletion, sharing, and feedback form validation.
tests/tests.spec.tsfor creating, editing, deleting, and sharing plans..pngand.icsfiles.playwright.config.ts..gitignoreto include Playwright-related files.@playwright/testtodevDependenciesinpackage.json.data-testidattributes to buttons inpage.client.tsx,plan-display-link.tsx, andplan-item.tsxfor testability.schemas.tsfor feedback form.This description was created by
for f5fa3e9. You can customize this summary. It will automatically update as commits are pushed.