User tests: Successful: Unsuccessful:
Add test for deleting a content category via DELETE verb
run npx cypress run --spec tests/System/integration/api/com_content/Categories.cy.js
N/A
a test
Please select:
Documentation link for guide.joomla.org:
No documentation changes for guide.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | JavaScript Unit Tests |
I have tested this item 🔴 unsuccessfully on 8774a3d
I have tested this item 🔴 unsuccessfully on 8774a3d
The test passes, but the category is not deleted.
db_createCategory inserts the row without an asset (asset_id = 0). Nested::delete() then returns false without an error, and ApiController::delete() still answers 204. Checking the DB right after the DELETE:
| Category | DELETE | Row afterwards |
|---|---|---|
db_createCategory(... published: -2) (this PR) |
204 | still there |
created via API, PATCH published: -2 |
204 | gone |
Suggested test (verified locally, passes):
it('can delete a category', () => {
cy.api_post('/content/categories', { title: 'automated test content category', parent_id: 1, extension: 'com_content' })
.then((response) => response.body.data.id)
.then((id) => cy.api_patch(`/content/categories/${id}`, { published: -2 })
.then(() => cy.api_delete(`/content/categories/${id}`))
.then((response) => expect(response.status).to.equal(204))
.then(() => cy.task('queryDB', `SELECT id FROM #__categories WHERE id = ${id}`))
.then((rows) => expect(rows).to.have.length(0)));
});Side note (core, separate issue): the API returns 204 whenever $model->delete() fails without an error message, e.g. a trashed category that still contains articles.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48643.
| Labels |
Added:
Unit/System Tests
Webservices
PR-6.2-dev
|
||
I have tested this item ✅ successfully on 77700e8
The command runs through
result:
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ Categories.cy.js 00:33 7 7 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:33 7 7 - - -
Before the PR was applied it was 6 Tests
There is no new category or trashed category in the backend view
asset table
The test should check for left over item in the asset table too
After each tests there are one more left over item there.
We discussed on "Happy Testing Friday" that asset table
is actually never tested with cypress test
Heiko will write an issue about it.
I have tested this item ✅ successfully on 77700e8
The command runs through
result:
(Run Finished)
Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ √ Categories.cy.js 00:33 7 7 - - - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
√ All specs passed! 00:33 7 7 - - -
Before the PR was applied it was 6 Tests
There is no new category or trashed category in the backend view
asset table
The test should check for left over item in the asset table too
After each tests there are one more left over item there.
We discussed on "Happy Testing Friday" that asset table
is actually never tested with cypress test
Heiko will write an issue about it.
I have tested this item 🔴 unsuccessfully on 77700e8
The test is running and the deleted category is no more visible in backend, but there are still entries left in _assets table, see #48735
I have tested this item 🔴 unsuccessfully on 77700e8
The test is running and the deleted category is no more visible in backend, but there are still entries left in _assets table, see #48735
i'm unable to replicate you findings see #48735 (comment)
This pull request has conflicts, please resolve those before we can evaluate the pull request.
@alikon Now as PR #48648 has been merged, you might have to adjust your new test here. See in that PR's description:
Note: the test proposed in #48643 creates the category with
db_createCategory(no asset row). With this fix its delete returns 409 instead of a false 204, so that test needs to create the category via the API.
@tecpromotion Can you confirm this? Or did I misunderstand something?
And it needs to fix a merge conflict here in file tests/System/integration/api/com_content/Categories.cy.js.
I have tested this item 🔴 unsuccessfully on 8774a3d
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48643.