Skip to content
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

[cypress] nested set table #__menu #43456

Open
wants to merge 19 commits into
base: 4.4-dev
Choose a base branch
from
Open

Conversation

alikon
Copy link
Contributor

@alikon alikon commented May 11, 2024

Pull Request for Issue #43441 .

Summary of Changes

delete an item on nested set table

Testing Instructions

run npm run cypress:run -- --spec 'tests/System/integration/api/com_menus/SiteMenuItems.cy.js'

Actual result BEFORE applying this Pull Request

fail

Expected result AFTER applying this Pull Request

success

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@bembelimen
Copy link
Contributor

I think we should really not use the "After" and "afterEach" event: https://docs.cypress.io/guides/references/best-practices#Using-after-Or-afterEach-Hooks

@laoneo

@alikon alikon marked this pull request as ready for review May 18, 2024 07:25
tests/System/integration/api/com_menus/SiteMenuItems.cy.js Outdated Show resolved Hide resolved
tests/System/integration/api/com_menus/SiteMenuItems.cy.js Outdated Show resolved Hide resolved
tests/System/integration/api/com_menus/SiteMenuItems.cy.js Outdated Show resolved Hide resolved
tests/System/support/commands/db.js Outdated Show resolved Hide resolved
tests/System/support/commands/db.js Outdated Show resolved Hide resolved
@laoneo laoneo self-assigned this May 31, 2024
@alikon
Copy link
Contributor Author

alikon commented Jun 3, 2024

still weird the drone failure

I would say "it works on my end" 🤕

@laoneo
Copy link
Member

laoneo commented Jun 7, 2024

What can be that the chaining I pointed out here can cause the issues as the task function does run async. Try my suggestion, perhaps it brings an improvement.

@alikon
Copy link
Contributor Author

alikon commented Jun 8, 2024

drone is happy now 👌

const menuItem = { ...defaultMenuItemOptions, ...menuItemData };
// Extract the component from the link
const component = (new URLSearchParams(menuItem.link.replace('index.php', ''))).get('option');
cy.task('queryDB', `SELECT extension_id FROM #__extensions WHERE name = '${component}'`).then((id) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need now here a return.

cy.task('queryDB', `SELECT extension_id FROM #__extensions WHERE name = '${component}'`).then((id) => {
// Get the correct component id from the extensions record
menuItem.component_id = id[0].extension_id;
cy.task('queryDB', `UPDATE #__menu SET rgt = rgt + 2 WHERE rgt >= '${defaultMenuItemOptions.lft}'`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here a return. Otherwise the calling function doesn't get the id of the menu item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants