diff --git a/README.md b/README.md index 82ffbbe..8674925 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ config (where it is) framework/config.py ← environment variables ## How a test runs -**API test**, for example `test_get_note_by_id(logged_in_client)`: +**API test**, for example `test_tc216_get_note_by_id(logged_in_client)`: 1. The `settings` fixture reads the environment, once per run. 2. The `account` fixture registers a brand-new user through the API. @@ -95,7 +95,7 @@ config (where it is) framework/config.py ← environment variables model: `ApiResponse[Note].model_validate(response.json())`. 5. Teardown deletes the account and, with it, all its notes. This also runs when the test failed. -**UI test**, for example `test_completing_a_note_updates_the_progress(notes_page)`: +**UI test**, for example `test_tc105_completing_a_note_updates_the_progress(notes_page)`: 1. A user is registered and logged in through the API (steps 1-3 above). This is much faster than filling in the login form every time. @@ -111,7 +111,7 @@ config (where it is) framework/config.py ← environment variables and a trace in `test-results/`. 7. Teardown deletes the account. -**Hybrid test**, for example `test_note_completed_in_the_app_is_completed_in_the_api`: +**Hybrid test**, for example `test_tc112_note_completed_in_the_app_is_completed_in_the_api`: 1. It creates notes through the API. 2. It changes them in the browser. @@ -134,6 +134,10 @@ Each side checks the other, and the set-up costs one HTTP call instead of a form The markers are defined in `pytest.ini`: `api`, `ui`, `e2e`, `smoke` and `demo`. `smoke` marks the 9 quickest checks of the main paths. `--strict-markers` turns a misspelt marker into an error. +Every test function starts with its case ID (`test_tc214_create_note_in_each_category`); run one case with +`pytest -k tc214`. The cases are written out for a manual run (setup, steps, expected results, data sets) in +[docs/manual-test-cases.md](docs/manual-test-cases.md): UI TC-101 to TC-109, hybrid TC-110 to TC-114, API TC-201 to TC-223. + ## Setup ``` diff --git a/docs/manual-test-cases.md b/docs/manual-test-cases.md new file mode 100644 index 0000000..cba9584 --- /dev/null +++ b/docs/manual-test-cases.md @@ -0,0 +1,330 @@ +# Manual test cases + +The test cases this framework automates, written as a tester would run them by hand. Every case has +an ID; the pytest function that covers it starts with the same ID (`test_tc214_create_note_in_each_category`), +so a failure in the report leads straight to the case below, and one case runs with +`pytest -k tc214`. Parametrized tests are one case with several data sets (`[Home]`, `[Work]` ...). + +| ID range | Area | Automated in | +|---|---|---| +| TC-101 to TC-109 | Notes web app: login and notes | `tests/ui/` (Playwright) | +| TC-110 to TC-114 | API and web app together (hybrid) | `tests/e2e/` | +| TC-201 to TC-223 | Notes REST API | `tests/api/` (requests + pydantic) | + +Not listed: `tests/demo/` (fails, skips and xfails on purpose to show the report). + +## Setup + +- Web app: ; API: + (public, shared). +- A fresh account per case: register one in the app or with `POST /users/register`, e.g. name + `Pytest User a1b2c3`, e-mail `pytest.a1b2c3d4e5@example.com`, password `Pw-a1b2c3d4e5`. +- API calls send form fields; protected calls need header `x-auth-token: `. +- Categories: Home, Work, Personal. + +## Summary + +| ID | Title | Type | Priority | +|---|---|---|---| +| TC-101 | Valid login opens the (empty) notes page | UI / Smoke | High | +| TC-102 | Wrong password shows an error | UI / Negative | High | +| TC-103 | Empty login form asks for e-mail and password | UI / Negative | Medium | +| TC-104 | A note added through the form is listed | UI / Smoke | High | +| TC-105 | Completing one of two notes updates the progress | UI | Medium | +| TC-106 | Completing every note shows "all done" | UI | Low | +| TC-107 | A deleted note disappears after confirming | UI | High | +| TC-108 | Search shows only the matching note | UI | Medium | +| TC-109 | Search without a match says so | UI / Negative | Low | +| TC-110 | A note created through the API is shown in the app | Hybrid / Smoke | High | +| TC-111 | The category filter shows only that category | Hybrid | Medium | +| TC-112 | A note completed in the app is completed in the API | Hybrid | High | +| TC-113 | A note deleted in the app is gone from the API | Hybrid | High | +| TC-114 | A note changed through the API shows the new text | Hybrid | Medium | +| TC-201 | The API reports it is running | API / Smoke | High | +| TC-202 | Register returns the new user | API / Smoke | High | +| TC-203 | Register refuses an e-mail that is taken | API / Negative | High | +| TC-204 | Register validates its fields (3 data sets) | API / Negative | Medium | +| TC-205 | Login returns a token | API / Smoke | High | +| TC-206 | Login failure does not reveal which part was wrong (2 data sets) | API / Security | High | +| TC-207 | Profile returns the logged-in user | API | Medium | +| TC-208 | Profile requires a valid token (2 data sets) | API / Security | High | +| TC-209 | Profile update returns the new values | API | Medium | +| TC-210 | Profile update validates the phone number | API / Negative | Low | +| TC-211 | A changed password replaces the old one | API / Security | High | +| TC-212 | Changing the password checks the current one | API / Security | High | +| TC-213 | Logout invalidates the token | API / Security | High | +| TC-214 | Create a note in each category (3 data sets) | API / Smoke | High | +| TC-215 | The list contains exactly the user's notes | API | High | +| TC-216 | Get a note by id | API | Medium | +| TC-217 | PUT replaces every field | API | Medium | +| TC-218 | PATCH changes only the completed flag | API | Medium | +| TC-219 | A deleted note is gone | API | High | +| TC-220 | Create note validates its fields (3 data sets) | API / Negative | Medium | +| TC-221 | Get a note with a bad id (2 data sets) | API / Negative | Low | +| TC-222 | Users cannot see or delete each other's notes | API / Security | High | +| TC-223 | Notes require a token | API / Security | High | + +--- + +## UI: login (`tests/ui/test_login.py`) + +Precondition for all: a registered account; the app's login page is open. + +### TC-101 Valid login opens the (empty) notes page + +| # | Step | Expected result | +|---|---|---| +| 1 | Enter the account's e-mail and password, click **Login** | The notes page: "You don't have any notes in all categories" | + +### TC-102 Wrong password shows an error + +| # | Step | Expected result | +|---|---|---| +| 1 | Enter the e-mail and a wrong password, click **Login** | "Incorrect email address or password"; still on the login page | + +### TC-103 Empty login form asks for e-mail and password + +| # | Step | Expected result | +|---|---|---| +| 1 | Click **Login** without entering anything | "Email address is required" and "Password is required" under the fields | + +## UI: notes (`tests/ui/test_notes.py`) + +Precondition for all: logged in with a fresh account (no notes). + +### TC-104 A note added through the form is listed + +| # | Step | Expected result | +|---|---|---| +| 1 | **+ Add Note**: category Home, title `Note a1b2c3d4e5`, description `Created by pytest (a1b2c3d4e5)`, **Create** | A card with the title and description | +| 2 | Read the progress line | "You have 0/1 notes completed in the all categories" | + +### TC-105 Completing one of two notes updates the progress + +| # | Step | Expected result | +|---|---|---| +| 1 | Add two notes; switch one card's toggle to completed | "You have 1/2 notes completed in the all categories" | + +### TC-106 Completing every note shows "all done" + +| # | Step | Expected result | +|---|---|---| +| 1 | Add notes and complete all of them | "You have completed all notes" | + +### TC-107 A deleted note disappears after confirming + +| # | Step | Expected result | +|---|---|---| +| 1 | Add a note; **Delete** on its card; **Delete** in the confirmation dialog | The card is gone; "You don't have any notes in all categories" | + +### TC-108 Search shows only the matching note + +| # | Step | Expected result | +|---|---|---| +| 1 | Add two notes; search for the first one's title | Only that note's card | + +### TC-109 Search without a match says so + +| # | Step | Expected result | +|---|---|---| +| 1 | Search for a title that does not exist | No cards; "Couldn't find any notes in all categories" | + +## Hybrid: API and app (`tests/e2e/test_api_and_ui.py`) + +Precondition for all: an account, logged in both in the app and through the API (token). + +### TC-110 A note created through the API is shown in the app + +| # | Step | Expected result | +|---|---|---| +| 1 | `POST /notes` with a title, description and category | `200` | +| 2 | Reload the app | A card with that title and description | + +### TC-111 The category filter shows only that category + +| # | Step | Expected result | +|---|---|---| +| 1 | Create one note per category through the API; reload the app; click the **Work** filter | Only the Work note | + +### TC-112 A note completed in the app is completed in the API + +| # | Step | Expected result | +|---|---|---| +| 1 | Create a note through the API; in the app switch it to completed | "You have completed all notes" | +| 2 | `GET /notes/` | `completed: true` | + +### TC-113 A note deleted in the app is gone from the API + +| # | Step | Expected result | +|---|---|---| +| 1 | Create a note through the API; delete it in the app (confirm) | Card gone | +| 2 | `GET /notes/` | `404` | + +### TC-114 A note changed through the API shows the new text + +| # | Step | Expected result | +|---|---|---| +| 1 | Create a note; `PUT /notes/` with title `Renamed through the API`; reload the app | The card shows "Renamed through the API" | + +--- + +## API: health and users (`tests/api/test_health.py`, `test_users.py`) + +### TC-201 The API reports it is running + +| # | Step | Expected result | +|---|---|---| +| 1 | `GET /health-check` | `200`; `success: true`, message "Notes API is Running" | + +### TC-202 Register returns the new user + +| # | Step | Expected result | +|---|---|---| +| 1 | `POST /users/register` with a new name, e-mail and password | `201`; "User account created successfully"; the user's name and e-mail in `data` | + +### TC-203 Register refuses an e-mail that is taken + +| # | Step | Expected result | +|---|---|---| +| 1 | Register again with an existing e-mail | `409`; "An account already exists with the same email address" | + +### TC-204 Register validates its fields + +Each data set: register with one invalid field (the others valid). Expected `400` and the message. + +| Data set | Field | Value | Message | +|---|---|---|---| +| invalid-email | email | `not-an-email` | A valid email address is required | +| name-too-short | name | `Abc` | User name must be between 4 and 30 characters | +| password-too-short | password | `12345` | Password must be between 6 and 30 characters | + +### TC-205 Login returns a token + +| # | Step | Expected result | +|---|---|---| +| 1 | `POST /users/login` with e-mail and password | `200`; the user's e-mail and a `token` of 64 hex characters | + +### TC-206 Login failure does not reveal which part was wrong + +| Data set | Login with | Expected result | +|---|---|---| +| wrong-password | the account's e-mail, a wrong password | `401`, "Incorrect email address or password" | +| unknown-user | an unregistered e-mail | Exactly the same answer | + +### TC-207 Profile returns the logged-in user + +| # | Step | Expected result | +|---|---|---| +| 1 | `GET /users/profile` with the token | `200`; the account's name and e-mail | + +### TC-208 Profile requires a valid token + +| Data set | Header | Expected result | +|---|---|---| +| no-token | none | `401`, "No authentication token specified in x-auth-token header" | +| invalid-token | `x-auth-token: not-a-real-token` | `401`, "Access token is not valid or has expired, you will need to login" | + +### TC-209 Profile update returns the new values + +| # | Step | Expected result | +|---|---|---| +| 1 | `PATCH /users/profile` name `Updated Name`, phone `01234567890`, company `Acme QA` | `200`; the new values returned and stored | + +### TC-210 Profile update validates the phone number + +| # | Step | Expected result | +|---|---|---| +| 1 | `PATCH /users/profile` with a phone of fewer than 8 digits | `400`; "Phone number should be between 8 and 20 digits" | + +### TC-211 A changed password replaces the old one + +| # | Step | Expected result | +|---|---|---| +| 1 | `POST /users/change-password` with the current and a new password | `200` | +| 2 | Log in with the old password; then with the new one | Old: `401`; new: `200` | + +### TC-212 Changing the password checks the current one + +| # | Step | Expected result | +|---|---|---| +| 1 | `POST /users/change-password` with a wrong current password | `400`; "The current password is incorrect" | + +### TC-213 Logout invalidates the token + +| # | Step | Expected result | +|---|---|---| +| 1 | `DELETE /users/logout` with the token | `200` | +| 2 | `GET /users/profile` with the same token | `401` | + +## API: notes (`tests/api/test_notes.py`) + +Precondition for all: logged in through the API (token). + +### TC-214 Create a note in each category + +Data sets: `Home`, `Work`, `Personal`. + +| # | Step | Expected result | +|---|---|---| +| 1 | `POST /notes` with title, description and the category | `200`; title, description and category as sent; `completed: false` | + +### TC-215 The list contains exactly the user's notes + +| # | Step | Expected result | +|---|---|---| +| 1 | Create some notes; `GET /notes` | `200`; exactly the ids just created, no others | + +### TC-216 Get a note by id + +| # | Step | Expected result | +|---|---|---| +| 1 | Create a note; `GET /notes/` | `200`; the same note as the create answer | + +### TC-217 PUT replaces every field + +| # | Step | Expected result | +|---|---|---| +| 1 | Create a note; `PUT /notes/` with a new title, description, category and `completed: true` | `200`; all four fields changed; `updated_at` not earlier than before | + +### TC-218 PATCH changes only the completed flag + +| # | Step | Expected result | +|---|---|---| +| 1 | Create a note; `PATCH /notes/` `completed=true` | `200`; `completed: true`; title, description and category unchanged | + +### TC-219 A deleted note is gone + +| # | Step | Expected result | +|---|---|---| +| 1 | Create a note; `DELETE /notes/` | `200` | +| 2 | `GET /notes/` | `404`; "No note was found with the provided ID, Maybe it was deleted" | + +### TC-220 Create note validates its fields + +Each data set: `POST /notes`; expected `400` and the message. + +| Data set | Title | Description | Category | Message | +|---|---|---|---|---| +| title-too-short | `Abc` | `Long enough` | Home | Title must be between 4 and 100 characters | +| description-too-short | `Valid title` | `Abc` | Home | Description must be between 4 and 1000 characters | +| unknown-category | `Valid title` | `Long enough` | Hobby | Category must be one of the categories: Home, Work, Personal | + +### TC-221 Get a note with a bad id + +| Data set | Request | Expected result | +|---|---|---| +| malformed-id | `GET /notes/123` | `400`, "Note ID must be a valid ID" | +| unknown-id | `GET /notes/6ace0ca52d855102960a16ec` | `404`, "No note was found with the provided ID, Maybe it was deleted" | + +### TC-222 Users cannot see or delete each other's notes + +| # | Step | Expected result | +|---|---|---| +| 1 | User A creates a note; user B (second account) `GET`s and `DELETE`s it with B's token | `404` both times (no IDOR / BOLA hole) | +| 2 | User A reads the note | `200`, untouched | + +### TC-223 Notes require a token + +| # | Step | Expected result | +|---|---|---| +| 1 | `GET /notes` without `x-auth-token` | `401` | diff --git a/tests/api/test_health.py b/tests/api/test_health.py index 1e5446f..1a43333 100644 --- a/tests/api/test_health.py +++ b/tests/api/test_health.py @@ -7,7 +7,7 @@ @pytest.mark.api @pytest.mark.smoke -def test_api_reports_it_is_running(api_client): +def test_tc201_api_reports_it_is_running(api_client): """The health endpoint answers 200 with the running message, in the standard response envelope.""" # Act: no login needed for the health check response = api_client.health_check() diff --git a/tests/api/test_notes.py b/tests/api/test_notes.py index 5ddeaac..91c9e56 100644 --- a/tests/api/test_notes.py +++ b/tests/api/test_notes.py @@ -19,7 +19,7 @@ def create(client, category: str = "Home") -> Note: @pytest.mark.smoke @pytest.mark.parametrize("category", ["Home", "Work", "Personal"]) -def test_create_note_in_each_category(logged_in_client, category): +def test_tc214_create_note_in_each_category(logged_in_client, category): """A note can be created in each of the three categories, and the API returns exactly what was sent.""" # Arrange: unique title and description, category of this case data = new_note(category) @@ -34,7 +34,7 @@ def test_create_note_in_each_category(logged_in_client, category): assert note.completed is False -def test_get_notes_lists_every_note_of_the_user(logged_in_client): +def test_tc215_get_notes_lists_every_note_of_the_user(logged_in_client): """The list contains exactly the user's own notes: no more, no fewer.""" # Arrange: two notes through the API (the user is new, so these are all of them) created = {create(logged_in_client, "Home").id, create(logged_in_client, "Work").id} @@ -48,7 +48,7 @@ def test_get_notes_lists_every_note_of_the_user(logged_in_client): assert {note.id for note in notes} == created -def test_get_note_by_id(logged_in_client): +def test_tc216_get_note_by_id(logged_in_client): """Reading a note by id returns the same note that creating it returned.""" # Arrange note = create(logged_in_client) @@ -61,7 +61,7 @@ def test_get_note_by_id(logged_in_client): assert ApiResponse[Note].model_validate(response.json()).data == note -def test_put_replaces_every_field(logged_in_client): +def test_tc217_put_replaces_every_field(logged_in_client): """PUT replaces all fields of a note and moves its updated_at forward.""" # Arrange note = create(logged_in_client, "Home") @@ -81,7 +81,7 @@ def test_put_replaces_every_field(logged_in_client): assert updated.updated_at >= note.updated_at -def test_patch_changes_only_the_completed_flag(logged_in_client): +def test_tc218_patch_changes_only_the_completed_flag(logged_in_client): """PATCH changes the completed flag and leaves every other field as it was.""" # Arrange note = create(logged_in_client) @@ -100,7 +100,7 @@ def test_patch_changes_only_the_completed_flag(logged_in_client): ) -def test_deleted_note_is_gone(logged_in_client): +def test_tc219_deleted_note_is_gone(logged_in_client): """A deleted note can no longer be read: 404 with the not-found message.""" # Arrange note = create(logged_in_client) @@ -128,7 +128,7 @@ def test_deleted_note_is_gone(logged_in_client): ], ids=["title-too-short", "description-too-short", "unknown-category"], ) -def test_create_note_validates_its_fields(logged_in_client, title, description, category, message): +def test_tc220_create_note_validates_its_fields(logged_in_client, title, description, category, message): """Each invalid field of a new note is refused with 400 and its own message.""" # Act: one invalid value per case, the other fields valid response = logged_in_client.create_note(title, description, category) @@ -146,7 +146,7 @@ def test_create_note_validates_its_fields(logged_in_client, title, description, ], ids=["malformed-id", "unknown-id"], ) -def test_get_note_with_a_bad_id(logged_in_client, note_id, status, message): +def test_tc221_get_note_with_a_bad_id(logged_in_client, note_id, status, message): """A malformed id is a client error (400); a well-formed id that does not exist is 404.""" # Act response = logged_in_client.get_note(note_id) @@ -156,7 +156,7 @@ def test_get_note_with_a_bad_id(logged_in_client, note_id, status, message): assert response.json()["message"] == message -def test_users_cannot_see_or_delete_each_others_notes(logged_in_client, settings, second_account): +def test_tc222_users_cannot_see_or_delete_each_others_notes(logged_in_client, settings, second_account): """Another logged-in user can neither read nor delete a user's note (no IDOR / BOLA hole).""" # Arrange: user A owns a note; user B logs in with its own client note = create(logged_in_client) @@ -173,7 +173,7 @@ def test_users_cannot_see_or_delete_each_others_notes(logged_in_client, settings assert logged_in_client.get_note(note.id).status_code == 200, "the owner's note must be untouched" -def test_notes_require_a_token(api_client): +def test_tc223_notes_require_a_token(api_client): """The notes cannot be listed without logging in.""" # Act: a client that never logged in response = api_client.get_notes() diff --git a/tests/api/test_users.py b/tests/api/test_users.py index 29522fe..8c67cfa 100644 --- a/tests/api/test_users.py +++ b/tests/api/test_users.py @@ -14,7 +14,7 @@ @pytest.mark.smoke -def test_register_returns_the_new_user(api_client, unregistered_cleanup): +def test_tc202_register_returns_the_new_user(api_client, unregistered_cleanup): """A new user can register: 201, a confirmation message and the user's own name and email back.""" # Arrange: unique name, email and password for this test user = new_user() @@ -31,7 +31,7 @@ def test_register_returns_the_new_user(api_client, unregistered_cleanup): assert (body.data.name, body.data.email) == (user.name, user.email) -def test_register_refuses_an_email_that_is_taken(api_client, account): +def test_tc203_register_refuses_an_email_that_is_taken(api_client, account): """Registering with an email that already has an account fails with 409 Conflict.""" # Act: the `account` fixture has already registered this email response = api_client.register("Someone Else", account.email, "Other-Pass-1") @@ -50,7 +50,7 @@ def test_register_refuses_an_email_that_is_taken(api_client, account): ], ids=["invalid-email", "name-too-short", "password-too-short"], ) -def test_register_validates_its_fields(api_client, unregistered_cleanup, field, value, message): +def test_tc204_register_validates_its_fields(api_client, unregistered_cleanup, field, value, message): """Each invalid field is refused with 400 and its own message (one report row per case).""" # Arrange: a valid user, with one field replaced by the invalid value of this case user = new_user() @@ -70,7 +70,7 @@ def test_register_validates_its_fields(api_client, unregistered_cleanup, field, @pytest.mark.smoke -def test_login_returns_a_token(api_client, account): +def test_tc205_login_returns_a_token(api_client, account): """Logging in with the right password returns the user's email and a 64-character hex token.""" # Act response = api_client.login(account.email, account.password) @@ -83,7 +83,7 @@ def test_login_returns_a_token(api_client, account): @pytest.mark.parametrize("case", ["wrong-password", "unknown-user"]) -def test_login_failure_does_not_reveal_which_part_was_wrong(api_client, account, case): +def test_tc206_login_failure_does_not_reveal_which_part_was_wrong(api_client, account, case): """A wrong password and an unknown email get exactly the same 401 answer. Different answers would let an attacker find out which emails have an account. @@ -102,7 +102,7 @@ def test_login_failure_does_not_reveal_which_part_was_wrong(api_client, account, # --- profile ---------------------------------------------------------------------------------- -def test_profile_returns_the_logged_in_user(logged_in_client, account): +def test_tc207_profile_returns_the_logged_in_user(logged_in_client, account): """The profile endpoint returns the user that the token belongs to.""" # Act: the client sends the token of `account` response = logged_in_client.get_profile() @@ -121,7 +121,7 @@ def test_profile_returns_the_logged_in_user(logged_in_client, account): ], ids=["no-token", "invalid-token"], ) -def test_profile_requires_a_valid_token(api_client, token, message): +def test_tc208_profile_requires_a_valid_token(api_client, token, message): """Without a token, or with an invalid one, the profile is refused with 401 and a clear message.""" # Arrange: no token at all, or one the server never issued api_client.token = token @@ -134,7 +134,7 @@ def test_profile_requires_a_valid_token(api_client, token, message): assert response.json()["message"] == message -def test_profile_update_returns_the_new_values(logged_in_client): +def test_tc209_profile_update_returns_the_new_values(logged_in_client): """Updating the profile stores the new name, phone and company and returns them.""" # Act response = logged_in_client.update_profile(name="Updated Name", phone="01234567890", company="Acme QA") @@ -145,7 +145,7 @@ def test_profile_update_returns_the_new_values(logged_in_client): assert (user.name, user.phone, user.company) == ("Updated Name", "01234567890", "Acme QA") -def test_profile_update_validates_the_phone_number(logged_in_client): +def test_tc210_profile_update_validates_the_phone_number(logged_in_client): """A phone number shorter than 8 digits is refused with 400 and the rule in the message.""" # Act: 3 digits, the API needs 8-20 response = logged_in_client.update_profile(name="Updated Name", phone="123", company="Acme QA") @@ -158,7 +158,7 @@ def test_profile_update_validates_the_phone_number(logged_in_client): # --- password and logout ---------------------------------------------------------------------- -def test_changed_password_replaces_the_old_one(logged_in_client, api_client, account): +def test_tc211_changed_password_replaces_the_old_one(logged_in_client, api_client, account): """After a password change, only the new password works for logging in.""" # Arrange new_password = "Changed-Pass-1" @@ -173,7 +173,7 @@ def test_changed_password_replaces_the_old_one(logged_in_client, api_client, acc assert api_client.login(account.email, new_password).status_code == 200 -def test_change_password_checks_the_current_password(logged_in_client): +def test_tc212_change_password_checks_the_current_password(logged_in_client): """The password cannot be changed without the correct current password (400).""" # Act: a wrong current password response = logged_in_client.change_password("Not-The-Password-1", "Changed-Pass-1") @@ -183,7 +183,7 @@ def test_change_password_checks_the_current_password(logged_in_client): assert response.json()["message"] == "The current password is incorrect" -def test_logout_invalidates_the_token(logged_in_client): +def test_tc213_logout_invalidates_the_token(logged_in_client): """After logout the same token is refused, so a stolen token stops working once the user logs out.""" # Arrange: log out (the client keeps the old token) assert logged_in_client.logout().status_code == 200 diff --git a/tests/e2e/test_api_and_ui.py b/tests/e2e/test_api_and_ui.py index 7ffcc9b..5621503 100644 --- a/tests/e2e/test_api_and_ui.py +++ b/tests/e2e/test_api_and_ui.py @@ -21,7 +21,7 @@ def create_via_api(client, category: str = "Home") -> Note: @pytest.mark.smoke -def test_note_created_through_the_api_is_shown_in_the_app(logged_in_client, notes_page): +def test_tc110_note_created_through_the_api_is_shown_in_the_app(logged_in_client, notes_page): """API → UI: a note created through the API is shown in the app with its description.""" # Arrange: create the note through the API (fast) note = create_via_api(logged_in_client, "Personal") @@ -33,7 +33,7 @@ def test_note_created_through_the_api_is_shown_in_the_app(logged_in_client, note expect(notes_page.card_description(note.title)).to_have_text(note.description) -def test_category_filter_shows_only_that_category(logged_in_client, notes_page): +def test_tc111_category_filter_shows_only_that_category(logged_in_client, notes_page): """API → UI: with one note per category, the Work filter shows only the Work note.""" # Arrange: one note in each category, through the API notes = { @@ -48,7 +48,7 @@ def test_category_filter_shows_only_that_category(logged_in_client, notes_page): expect(notes_page.card_titles).to_have_text([notes["Work"].title]) -def test_note_completed_in_the_app_is_completed_in_the_api(logged_in_client, notes_page): +def test_tc112_note_completed_in_the_app_is_completed_in_the_api(logged_in_client, notes_page): """UI → API: a note completed in the app is stored as completed on the server.""" # Arrange note = create_via_api(logged_in_client) @@ -63,7 +63,7 @@ def test_note_completed_in_the_app_is_completed_in_the_api(logged_in_client, not assert stored.completed is True -def test_note_deleted_in_the_app_is_gone_from_the_api(logged_in_client, notes_page): +def test_tc113_note_deleted_in_the_app_is_gone_from_the_api(logged_in_client, notes_page): """UI → API: a note deleted in the app no longer exists on the server.""" # Arrange note = create_via_api(logged_in_client) @@ -76,7 +76,7 @@ def test_note_deleted_in_the_app_is_gone_from_the_api(logged_in_client, notes_pa assert logged_in_client.get_note(note.id).status_code == 404 -def test_note_changed_through_the_api_shows_the_new_text(logged_in_client, notes_page): +def test_tc114_note_changed_through_the_api_shows_the_new_text(logged_in_client, notes_page): """API → UI: a note renamed through the API shows the new title after the app reloads.""" # Arrange: a note that the app already shows note = create_via_api(logged_in_client) diff --git a/tests/ui/test_login.py b/tests/ui/test_login.py index 3824b2d..83a9913 100644 --- a/tests/ui/test_login.py +++ b/tests/ui/test_login.py @@ -11,7 +11,7 @@ @pytest.mark.smoke -def test_valid_login_opens_the_notes_page(login_page, account, settings): +def test_tc101_valid_login_opens_the_notes_page(login_page, account, settings): """A registered user logs in through the form and lands on their (still empty) notes page.""" # Act: the `account` fixture registered this user through the API login_page.login(account.email, account.password) @@ -23,7 +23,7 @@ def test_valid_login_opens_the_notes_page(login_page, account, settings): expect(notes.no_notes_message).to_have_text("You don't have any notes in all categories") -def test_wrong_password_shows_an_error(login_page, account): +def test_tc102_wrong_password_shows_an_error(login_page, account): """A wrong password shows the error message and keeps the user on the login page.""" # Act login_page.login(account.email, "Wrong-Pass-1") @@ -33,7 +33,7 @@ def test_wrong_password_shows_an_error(login_page, account): expect(login_page.page).to_have_url(login_page.url) -def test_empty_form_asks_for_email_and_password(login_page): +def test_tc103_empty_form_asks_for_email_and_password(login_page): """Submitting the empty form shows a 'required' hint under both fields.""" # Act: submit without typing anything login_page.submit.click() diff --git a/tests/ui/test_notes.py b/tests/ui/test_notes.py index 44d4b8d..f82fdc7 100644 --- a/tests/ui/test_notes.py +++ b/tests/ui/test_notes.py @@ -9,7 +9,7 @@ @pytest.mark.smoke -def test_note_added_through_the_form_is_listed(notes_page): +def test_tc104_note_added_through_the_form_is_listed(notes_page): """A note added through the form appears as a card with its description, and the counter shows 0/1.""" # Arrange: `notes_page` is already logged in as a new user without notes note = new_note("Work") @@ -22,7 +22,7 @@ def test_note_added_through_the_form_is_listed(notes_page): expect(notes_page.progress).to_have_text("You have 0/1 notes completed in the all categories") -def test_completing_a_note_updates_the_progress(notes_page): +def test_tc105_completing_a_note_updates_the_progress(notes_page): """Completing one of two notes changes the progress line to 1/2.""" # Arrange: two notes through the form first, second = new_note(), new_note() @@ -36,7 +36,7 @@ def test_completing_a_note_updates_the_progress(notes_page): expect(notes_page.progress).to_have_text("You have 1/2 notes completed in the all categories") -def test_completing_every_note_shows_all_done(notes_page): +def test_tc106_completing_every_note_shows_all_done(notes_page): """When every note is completed, the progress line says so.""" # Arrange note = new_note() @@ -49,7 +49,7 @@ def test_completing_every_note_shows_all_done(notes_page): expect(notes_page.progress).to_have_text("You have completed all notes") -def test_deleted_note_disappears_after_confirming(notes_page): +def test_tc107_deleted_note_disappears_after_confirming(notes_page): """A note deleted through its card and the confirmation dialog is gone from the list.""" # Arrange note = new_note() @@ -63,7 +63,7 @@ def test_deleted_note_disappears_after_confirming(notes_page): expect(notes_page.no_notes_message).to_have_text("You don't have any notes in all categories") -def test_search_shows_only_matching_notes(notes_page): +def test_tc108_search_shows_only_matching_notes(notes_page): """Searching for one note's title shows that note only.""" # Arrange: two notes with different unique titles wanted, other = new_note(), new_note() @@ -77,7 +77,7 @@ def test_search_shows_only_matching_notes(notes_page): expect(notes_page.card_titles).to_have_text([wanted.title]) -def test_search_without_match_says_so(notes_page): +def test_tc109_search_without_match_says_so(notes_page): """A search that matches nothing shows no cards and a 'couldn't find' message.""" # Arrange: the list is not empty, so the message comes from the search notes_page.add_note(new_note())