-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Issue#25] add test API for DELETE by id for article #35
base: main
Are you sure you want to change the base?
Conversation
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.
will review again after changes are introduced
I have added corrections in the test, the test works correctly, please review :) |
tests/api/articles-id-delete.spec.ts
Outdated
}); | ||
|
||
test("delete article by ID 60", async ({ request }) => { | ||
const nonExistentArticleID = 60; |
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.
I believe you meant the existing article?
…into chore/ISSUE-25_DELETE_articles_id-test
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.
General comment:
I think that we agreed to add Given/When/Then in all tests. Especially in this test it would be beneficial - would make more obvious why the article is created at first. I'm not pushing, but you can consider adding GWT comments :)
tests/api/articles-id-delete.spec.ts
Outdated
expect(deleteResponse.status()).toBe(expectedResponseCode); | ||
}); | ||
|
||
// Error - Received: 401 |
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.
I know that we discussed that but a lot of time passed by and I completely don't remember. Can you please explain again why this test fails?
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.
Agreed 5.02:
- reason it fails is because regular user can try to delete only his/her article
- would be nice to add 2 different tests, for regular user and admin
…into chore/ISSUE-25_DELETE_articles_id-test
import { testUsers } from "@_src_fixtures_api/auth"; | ||
|
||
test.describe("DELETE articles/{id}", () => { | ||
const baseURL: string = process.env.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.
as discussed this can be deleted
|
||
test.describe("DELETE articles/{id}", () => { | ||
const baseURL: string = process.env.BASE_URL; | ||
const articles: string = `${baseURL}/api/articles/`; |
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.
baseURL part can be deleted
}); | ||
|
||
// 401 status received - Use the `test.fail();` instruction to mark as a failed test | ||
test("returns 404 status code when delete a non-existent article", async ({ request }) => { |
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.
test to fix: returns 401 when delete a non-existing article as a regular user
|
||
// Then: The response status code should be 404 | ||
expect(response.status()).toBe(expectedResponseCode); | ||
}); |
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.
new test to be added: returns 404 when delete a non-existing article as an admin user
This is a draft to verify the API request for POST and DELETE method