npm run cypress:run -- --spec 'tests/System/integration/api/com_menus/SiteMenuItems.cy.js'
all 6 tests are successfull
the one test 'can create a site menu item' fails with 'Status: 400 - Bad Request'
1 failing
1) Test that menu items site API endpoint
can create a site menu item:
CypressError: `cy.request()` failed on:
http://localhost:8080/api/index.php/v1/menus/site/items
The response we received from your web server was:
> 400: Bad Request
This was considered a failure because the status code was not `2xx` or `3xx`.
If you do not want status codes to cause failures pass the option: `failOnStatusCode: false`
-----------------------------------------------------------
The request we sent was:
Method: POST
URL: http://localhost:8080/api/index.php/v1/menus/site/items
Headers: {
"Connection": "keep-alive",
"Authorization": "Bearer c2hhMjU2OjM6ZTJmMjJlYTNlNTU0NmM1MDJhYTIzYzMwN2MxYzAwZTQ5NzJhMWRmOTUyNjY5MTk2YjE5ODJmZWMwZTcxNzgwMQ==",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Cypress/13.2.0 Chrome/114.0.5735.289 Electron/25.8.0 Safari/537.36",
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"content-type": "application/json",
"content-length": 268
}
Body: {"title":"automated test site menu item","menutype":"main-menu","access":"1","parent_id":"1","publish_down":"","publish_up":"","published":"1","template_style_id":"0","toggle_modules_assigned":"1","toggle_modules_published":"1","type":"component","alias":"","link":""}
-----------------------------------------------------------
The response we got was:
Status: 400 - Bad Request
Headers: {
"date": "Wed, 08 May 2024 05:43:31 GMT",
"server": "Apache/2.4.59 (Unix) PHP/8.3.6",
"x-powered-by": "JoomlaAPI/1.0",
"x-frame-options": "SAMEORIGIN",
"referrer-policy": "strict-origin-when-cross-origin",
"cross-origin-opener-policy": "same-origin",
"expires": "Wed, 17 Aug 2005 00:00:00 GMT",
"last-modified": "Wed, 08 May 2024 05:43:31 GMT",
"cache-control": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
"pragma": "no-cache",
"content-length": "156",
"connection": "close",
"content-type": "application/vnd.api+json; charset=utf-8"
}
Body: {
"errors": [
{
"title": "Save failed with the following error: Joomla\\Component\\Menus\\Administrator\\Table\\MenuTable::_getNode(1, id) failed.",
"code": 400
}
]
}
https://on.cypress.io/request
at <unknown> (http://localhost:8080/__cypress/runner/cypress_runner.js:133013:72)
at tryCatcher (http://localhost:8080/__cypress/runner/cypress_runner.js:1807:23)
at Promise._settlePromiseFromHandler (http://localhost:8080/__cypress/runner/cypress_runner.js:1519:31)
at Promise._settlePromise (http://localhost:8080/__cypress/runner/cypress_runner.js:1576:18)
at Promise._settlePromise0 (http://localhost:8080/__cypress/runner/cypress_runner.js:1621:10)
at Promise._settlePromises (http://localhost:8080/__cypress/runner/cypress_runner.js:1701:18)
at _drainQueueStep (http://localhost:8080/__cypress/runner/cypress_runner.js:2407:12)
at _drainQueue (http://localhost:8080/__cypress/runner/cypress_runner.js:2400:9)
at Async._drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:2416:5)
at Async.drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:2286:14)
From Your Spec Code:
at Context.eval (webpack://joomla/./tests/System/support/commands/api.js:8:92)
Labels |
Added:
No Code Attached Yet
|
__menu
table ?__menu
shows that there is no entry with id 1
and therefore the used parent_id 1
fails, hardwired the parent_id
was changed to (at this moment) existing id 2
the test run was successful several timesparent_id
But the more important question is, why is the so importand looking __menu entry id=1 title=Menu_Item_Root alias=root
deleted in a fresh instance with running only sytem tests? The obvious suspect is the test case can delete a site menu item
in the same file. And with this question, the approach of getting the first menu entry and using its id
sound more like a work around and does not fix the main cause that menu entry #1 being deleted.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-05-11 09:20:42 |
Closed_By | ⇒ | alikon |
on fresh macOS-docker-4.4-dev installation
SiteMenuItems.cy.js
deletes one more entry from the __menu
table, starting with id=1
can create a site menu item
fails because there is no longer a parent menu entry id=1INSERT INTO `jos44_menu` (`id`, `menutype`, `title`, `alias`, `note`, `path`, `link`, `type`, `published`, `parent_id`, `level`, `component_id`, `checked_out`, `checked_out_time`, `browserNav`, `access`, `img`, `template_style_id`, `params`, `lft`, `rgt`, `home`, `language`, `client_id`, `publish_up`, `publish_down`) VALUES
(1, '', 'Menu_Item_Root', 'root', '', '', '', '', 1, 0, 0, 0, NULL, NULL, 0, 0, '', 0, '', 0, 43, 0, '*', 0, NULL, NULL);
gh pr checkout 43456
tests/System/integration/api/com_menus/SiteMenuItems.cy.js
has changed to beforeEach
SiteMenuItems.cy.js
__menu
entries are deleted ✅Thank you for fixing ?
i was able to reproduce on 2nd run
": "Save failed with the following error: Joomla\\Component\\Menus\\Administrator\\Table\\MenuTable::_getNode(1, id) failed.",
and the #__menu table is messed up for lft, rgt