Unit/System Tests bug PR-6.1-dev Pending

User tests: Successful: Unsuccessful:

avatar muhme
muhme
10 Jan 2026

Summary of Changes

System Tests are failing with #46631 as db_createCategory() hacks the category simplified in the database table. To prevent reimplementing nested set properly (lft/rgt/level/path) it is simple replaced by api_post() call.

  • Replaced all db_createCategory() by api_post()
  • Deleted db_createCategory() command in source and documentation
  • Unified all create category usage with beforeEach() deletion as recommended by Cypress.
    • This ensures even with test canceled in the middle of execution, the next test will work.
    • As there is no afterEach there may stay objects in instance, e.g. news feed category 'Automated System Tests Category Title feed delete'
  • Introduced support/constants.mjs with AST_CATEGORY_TITLE
    • Only used for the changed stuff, could be extended later
  • Note: There are 19 more db_* commands, but the other ones we would leave for performance reasons.

Testing Instructions

  • Code review is needed and requested before human tests
  • Human tests:
    • System Tests should run without error (this is already given by CI)
    • System Tests should run withouts errors including PR #46631
    • Single System Tests (without Joomla installation step) should be running multiple times without errors,
      choose one or multiple of the modified tests, e.g.
      npx cypress run --spec tests/System/integration/administrator/components/com_categories/Categories.cy.js
      npx cypress run --spec tests/System/integration/administrator/components/com_categories/Categories.cy.js
      
    • Check db_createCategory() is removed from source and documentation

Actual result BEFORE applying this Pull Request

  • System Tests failing with #46631

Expected result AFTER applying this Pull Request

  • System Tests passed with #46631

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

avatar muhme muhme - open - 10 Jan 2026
avatar muhme muhme - change - 10 Jan 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 10 Jan 2026
Category ⇒ Administration com_categories Unit Tests Repository JavaScript
avatar brianteeman
brianteeman - comment - 10 Jan 2026

To prevent reimplementing nested set properly (lft/rgt/level/path) it is simple replaced by api_post() call.

surely that makes it an unrealistic test

avatar muhme
muhme - comment - 10 Jan 2026

@laoneo Could you please carry out a review before the testers start? It works with the PR, but is everything implemented as we need it, or could something be improved?

avatar muhme muhme - change - 10 Jan 2026
Labels Added: Unit/System Tests PR-6.1-dev
avatar joomla-cms-bot joomla-cms-bot - change - 10 Jan 2026
Category Administration com_categories Unit Tests Repository JavaScript ⇒ Unit Tests Repository JavaScript
avatar muhme
muhme - comment - 10 Jan 2026

To prevent reimplementing nested set properly (lft/rgt/level/path) it is simple replaced by api_post() call.

surely that makes it an unrealistic test

There are tests that create a category in the backend. What we are talking about here is that if we need to create categories as a prerequisite for other tests, the not fully implemented database table hack will be replaced by API call.

avatar muhme muhme - change - 10 Jan 2026
Labels Added: bug
avatar laoneo
laoneo - comment - 10 Jan 2026

I would move the api call to its own function and not call everywhere the api directly.

avatar tecpromotion tecpromotion - change - 11 Jan 2026
Title
…
System Tests – Replace db_createCategory() by API
[6.1] System Tests – Replace db_createCategory() by API
avatar tecpromotion tecpromotion - edited - 11 Jan 2026
avatar muhme
muhme - comment - 15 Jan 2026

I would move the api call to its own function and not call everywhere the api directly.

Sorry, I don't understand the reasons for this. That would be a separate function with a different name, but without any additional functionality, right? But what's the advantage? And does that only apply to the changed places or also to the 200 cy.api_* calls in 40 files that already exist?

Maybe we can do that later as refactoring and just do the bare minimum in this PR to make it work?

avatar HLeithner
HLeithner - comment - 17 Jul 2026

@muhme @laoneo what's the status of this pr, one test failed

avatar muhme
muhme - comment - 18 Jul 2026

@muhme @laoneo what's the status of this pr, one test failed

The failed test api/com_content/Articles.cy.js passed three times locally with current 6.1-dev branch.
And the error TypeError: cy.db_createCategory is not a function looks like a Cypress glitch?
I would recommend running the tests again.

avatar muhme
muhme - comment - 18 Jul 2026

@muhme @laoneo what's the status of this pr, one test failed

The failed test api/com_content/Articles.cy.js passed three times locally with current 6.1-dev branch. And the error TypeError: cy.db_createCategory is not a function looks like a Cypress glitch? I would recommend running the tests again.

Nonsense 😅 If I test with this PR applied! the tests fail. That's expected because this PR removes db_createCategory.

It looks like additional tests were added over the past few months. Those new tests will need to have db_createCategory removed as well. I will do that once I have the time.

avatar alikon
alikon - comment - 19 Jul 2026

@muhme
can you explain why db_createCategory() changed to by api_post()

"To prevent reimplementing nested set properly (lft/rgt/level/path) it is simple replaced call."

and then brutally deleting category with cy.task('queryDB', `DELETE FROM #__categories WHERE title LIKE '${AST_CATEGORY_TITLE}%'`);

which broke the nested set ?

avatar alikon
alikon - comment - 19 Jul 2026

@muhme
can you explain why db_createCategory() changed to by api_post()

"To prevent reimplementing nested set properly (lft/rgt/level/path) it is simple replaced call."

and then brutally deleting category with cy.task('queryDB', `DELETE FROM #__categories WHERE title LIKE '${AST_CATEGORY_TITLE}%'`);

which broke the nested set ?

maybe we need to do like with menus

Cypress.Commands.add('db_createMenuItem', (menuItemData) => {
const defaultMenuItemOptions = {
title: 'test menu item',
alias: 'test-menu-item',
menutype: 'mainmenu',
type: 'component',
link: 'index.php?option=com_content',
component_id: 19,
path: 'test-menu-item',
parent_id: 1,
level: 1,
published: 1,
access: 1,
language: '*',
params: '',
img: '',
lft: 0,
rgt: 0,
};
// Create space for rgt and lft
cy.task('queryDB', 'SELECT rgt FROM #__menu WHERE id = 1').then((myrgt) => {
defaultMenuItemOptions.lft = myrgt[0].rgt;
defaultMenuItemOptions.rgt = myrgt[0].rgt + 1;
const menuItem = { ...defaultMenuItemOptions, ...menuItemData };
// Extract the component from the link
const component = (new URLSearchParams(menuItem.link.replace('index.php', ''))).get('option');
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;
return cy.task('queryDB', `UPDATE #__menu SET rgt = rgt + 2 WHERE rgt >= '${defaultMenuItemOptions.lft}'`)
.then(() => cy.task('queryDB', `UPDATE #__menu SET lft = lft + 2 WHERE lft > '${defaultMenuItemOptions.rgt}'`))
.then(() => cy.task('queryDB', createInsertQuery('menu', menuItem)))
.then(async (info) => info.insertId);
});
});
});
/**
* Delete a menu item in the database with the given title.
*
* @param {Object} menuItemTitle The menu item tile to delete
*
*/
Cypress.Commands.add('db_deleteMenuItem', (menuItemTitle) => {
cy.task('queryDB', `SELECT lft, rgt, (rgt - lft) +1 AS width FROM #__menu WHERE title = '${menuItemTitle.title}'`).then((record) => {
if (record.length > 0) {
cy.task('queryDB', `DELETE FROM #__menu WHERE lft BETWEEN '${record[0].lft}' AND '${record[0].rgt}'`)
.then(() => cy.task('queryDB', `UPDATE #__menu SET lft = lft - '${record[0].width}' WHERE lft > '${record[0].rgt}'`))
.then(() => cy.task('queryDB', `UPDATE #__menu SET rgt = rgt - '${record[0].width}' WHERE rgt > '${record[0].rgt}'`));
}
});
});

avatar muhme
muhme - comment - 21 Jul 2026

@alikon Thank you for your comments.

can you explain why db_createCategory() changed to api_post()?

ATT discussed this back in January 😅

... brutally deleting category ... which broke the nested set

Yes, that's bad and definitely not acceptable 🙈

maybe we need to do like with menus

It would be great if you could extend db_createCategory(). Would you be willing to take that on, @alikon? 🙏

@richard67 @HLeithner @laoneo In that case, I would close this PR. I think @alikon's proposal to solve wrong lft and rgt setting for categories is more appropriate. Since this is a bug and only affects the System Tests, I guess the fix should be submitted as a new PR against the 5.4-dev branch.

avatar alikon
alikon - comment - 22 Jul 2026

@muhme done with #48133

avatar muhme muhme - close - 22 Jul 2026
avatar muhme
muhme - comment - 22 Jul 2026

Closed in favour of #48133 – thx @alikon

avatar muhme muhme - change - 22 Jul 2026
Status Pending ⇒ Closed
Closed_Date 0000-00-00 00:00:00 ⇒ 2026-07-22 08:38:15
Closed_By ⇒ muhme

Add a Comment

Login with GitHub to post a comment