-
Notifications
You must be signed in to change notification settings - Fork 6
tests: e2e testing course #254
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
base: main
Are you sure you want to change the base?
Conversation
Rei-x
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ż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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.