From cf955b6d7f48671dcf4e83126f9b54c462604ccc Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Tue, 28 Oct 2025 18:34:12 +0100 Subject: [PATCH 1/7] Revert "[4.1] All Categories (#37140)" This reverts commit 84c6ae2ad8e42c08a6d1765320f9963d2fe3d3bb. --- components/com_content/tmpl/archive/default.xml | 4 ++-- components/com_content/tmpl/featured/default.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/com_content/tmpl/archive/default.xml b/components/com_content/tmpl/archive/default.xml index 7e0fb8ececd38..9db86bab73dd4 100644 --- a/components/com_content/tmpl/archive/default.xml +++ b/components/com_content/tmpl/archive/default.xml @@ -19,9 +19,9 @@ extension="com_content" multiple="true" layout="joomla.form.field.list-fancy-select" - default=" " + default="" > - + diff --git a/components/com_content/tmpl/featured/default.xml b/components/com_content/tmpl/featured/default.xml index c102644d7517d..638ff14a591e9 100644 --- a/components/com_content/tmpl/featured/default.xml +++ b/components/com_content/tmpl/featured/default.xml @@ -19,10 +19,10 @@ extension="com_content" multiple="true" layout="joomla.form.field.list-fancy-select" - default=" " + default="" parentclass="stack span-3" > - + Date: Wed, 29 Oct 2025 19:12:37 +0100 Subject: [PATCH 2/7] update mysql --- .../sql/updates/mysql/6.0.1-2025-10-29.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql diff --git a/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql b/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql new file mode 100644 index 0000000000000..2b6df65cd366b --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql @@ -0,0 +1,18 @@ +UPDATE `#__menu` +SET `params` = JSON_SET(`params`, + JSON_UNQUOTE(JSON_SEARCH(`params`, 'one', ' ', NULL, '$.featured_categories[*]')), + '' + ) +WHERE JSON_VALID(`params`) = 1 + AND JSON_SEARCH(`params`, 'one', ' ', NULL, '$.featured_categories[*]') IS NOT NULL + AND `type` = 'component' + AND `link` = 'index.php?option=com_content&view=featured'; + +UPDATE `#__menu` +SET `link` = REGEXP_REPLACE( + `link`, + '(catid\\[\\d+\\]=)\\s+', + '\\1' + ) +WHERE `type` = 'component' + AND `link` LIKE 'index.php?option=com_content&view=archive%= %'; From 4f3a453593893c7f9fc47998d7a9e3dc83d7043d Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Wed, 29 Oct 2025 19:45:41 +0100 Subject: [PATCH 3/7] use standard replace REGEXP_REPLACE does not support backreferences in replacement string (mysql 8.0.13) All categories is always first index --- .../com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql b/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql index 2b6df65cd366b..bc4877ff4abdf 100644 --- a/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql +++ b/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql @@ -9,10 +9,6 @@ WHERE JSON_VALID(`params`) = 1 AND `link` = 'index.php?option=com_content&view=featured'; UPDATE `#__menu` -SET `link` = REGEXP_REPLACE( - `link`, - '(catid\\[\\d+\\]=)\\s+', - '\\1' - ) +SET `link` = REPLACE(`link`, 'catid[0]= ', 'catid[0]=') WHERE `type` = 'component' AND `link` LIKE 'index.php?option=com_content&view=archive%= %'; From febdea59d306fe3f0d7aac5cdd4e873b110c2251 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Sat, 1 Nov 2025 17:15:04 +0100 Subject: [PATCH 4/7] more precise --- .../com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql b/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql index bc4877ff4abdf..677a4624912f5 100644 --- a/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql +++ b/administrator/components/com_admin/sql/updates/mysql/6.0.1-2025-10-29.sql @@ -9,6 +9,6 @@ WHERE JSON_VALID(`params`) = 1 AND `link` = 'index.php?option=com_content&view=featured'; UPDATE `#__menu` -SET `link` = REPLACE(`link`, 'catid[0]= ', 'catid[0]=') +SET `link` = REPLACE(`link`, '&catid[0]= ', '&catid[0]=') WHERE `type` = 'component' - AND `link` LIKE 'index.php?option=com_content&view=archive%= %'; + AND `link` LIKE 'index.php?option=com_content&view=archive&catid[0]= %'; From 24a7411f99c0044e2c685ee1b0d60ff325a1d130 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Sat, 1 Nov 2025 17:15:15 +0100 Subject: [PATCH 5/7] add postgresql --- .../updates/postgresql/6.0.1-2025-10-29.sql | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 administrator/components/com_admin/sql/updates/postgresql/6.0.1-2025-10-29.sql diff --git a/administrator/components/com_admin/sql/updates/postgresql/6.0.1-2025-10-29.sql b/administrator/components/com_admin/sql/updates/postgresql/6.0.1-2025-10-29.sql new file mode 100644 index 0000000000000..94952c7643e62 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/6.0.1-2025-10-29.sql @@ -0,0 +1,21 @@ +UPDATE "#__menu" +SET "params" = jsonb_set( + "params"::jsonb, + '{featured_categories}', + COALESCE( + ( + SELECT jsonb_agg(to_jsonb(CASE WHEN elem = ' ' THEN '' ELSE elem END)) + FROM jsonb_array_elements_text("params"::jsonb->'featured_categories') AS t(elem) + ), + '[]'::jsonb + ), + false +) +WHERE ("params"::jsonb->'featured_categories') @> '[" "]'::jsonb + AND "type" = 'component' + AND "link" = 'index.php?option=com_content&view=featured'; + +UPDATE "#__menu" +SET "link" = REPLACE("link", '&catid[0]= ', '&catid[0]=') +WHERE "type" = 'component' + AND "link" LIKE 'index.php?option=com_content&view=archive&catid[0]= %'; From 7c62eea1cbe36673e87e848a3aeada1ade1b367a Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Sat, 1 Nov 2025 17:18:01 +0100 Subject: [PATCH 6/7] temp testing - this commit needs to be reverted --- .github/workflows/ci.yml | 227 +------- .../com_content/src/Model/ArchiveModel.php | 1 + cypress.config.dist.mjs | 6 +- .../fixtures/issue-46371/archive/default.xml | 314 +++++++++++ .../fixtures/issue-46371/featured/default.xml | 517 ++++++++++++++++++ .../System/integration/site/issue46371.cy.js | 204 +++++++ tests/System/plugins/db.mjs | 4 + 7 files changed, 1042 insertions(+), 231 deletions(-) create mode 100644 tests/System/fixtures/issue-46371/archive/default.xml create mode 100644 tests/System/fixtures/issue-46371/featured/default.xml create mode 100644 tests/System/integration/site/issue46371.cy.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02688c6958eac..f9f1943003e8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,219 +53,6 @@ jobs: if: steps.cache-assets.outputs.cache-hit != 'true' run: npm ci --unsafe-perm - code-style-php: - name: Check PHP code style - runs-on: ubuntu-latest - container: joomlaprojects/docker-images:php8.4 - needs: [composer] - strategy: - matrix: - command: ['php-cs-fixer fix -vvv --dry-run --diff', 'phpcs --extensions=php -p --standard=ruleset.xml .'] - steps: - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - with: - path: libraries/vendor - key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} - - name: Check PHP code style - env: - PHP_CS_FIXER_IGNORE_ENV: true - run: ./libraries/vendor/bin/${{ matrix.command }} - - code-style-js-css: - name: Check Javascript & CSS code style - runs-on: ubuntu-latest - container: joomlaprojects/docker-images:php8.4 - needs: [composer, npm] - strategy: - matrix: - check: ['lint:js', 'lint:testjs', 'lint:css'] - steps: - - uses: actions/setup-node@v4 - with: - node-version: latest - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - with: - path: | - node_modules - media - key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json', 'build/media_source/**', 'administrator/components/com_media/resources/**') }} - - name: Check code style - run: npm run ${{ matrix.check }} - - phpstan: - name: Run PHPstan - runs-on: ubuntu-latest - container: joomlaprojects/docker-images:php8.4 - needs: [code-style-php] - steps: - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - with: - path: libraries/vendor - key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} - - name: Run PHPstan - run: | - ./libraries/vendor/bin/phpstan --error-format=github - - tests-unit: - name: Run Unit tests - runs-on: ubuntu-latest - container: joomlaprojects/docker-images:php${{ matrix.php_version }} - needs: [code-style-php] - strategy: - matrix: - php_version: ['8.3', '8.4'] - steps: - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - with: - path: libraries/vendor - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - - name: Run Unit tests - run: ./libraries/vendor/bin/phpunit --testsuite Unit - - tests-integration: - name: Run integration tests - runs-on: ubuntu-latest - container: joomlaprojects/docker-images:php${{ matrix.php_version }} - needs: [code-style-php] - strategy: - matrix: - php_version: ['8.3', '8.4'] - config: - - my_version: '8.4' - engine: 'mysqli' - host: 'mysql' - user: 'joomla_ut' - - my_version: '8.0.13' - engine: 'mysqli' - host: 'mysql' - user: 'joomla_ut' - - maria_version: '12.0' - engine: 'mysqli' - host: 'maria' - user: 'joomla_ut' - - maria_version: '10.4' - engine: 'mysqli' - host: 'maria' - user: 'joomla_ut' - - pg_version: '12.0' - engine: 'pgsql' - host: 'postgres' - user: 'root' - - pg_version: '18.0' - engine: 'pgsql' - host: 'postgres' - user: 'root' - steps: - - uses: actions/checkout@v4 - - name: Start LDAP container - uses: docker://docker - with: - args: docker run -d --name openldap --network ${{ job.container.network }} --network-alias openldap -e "LDAP_ADMIN_USERNAME=admin" -e "LDAP_ADMIN_PASSWORD=adminpassword" -e "LDAP_USERS=customuser" -e "LDAP_PASSWORDS=custompassword" -e "LDAP_ENABLE_TLS=yes" -e "LDAP_TLS_CERT_FILE=/certs/openldap.crt" -e "LDAP_TLS_KEY_FILE=/certs/openldap.key" -e "LDAP_TLS_CA_FILE=/certs/CA.crt" -e "BITNAMI_DEBUG=true" -e "LDAP_CONFIG_ADMIN_ENABLED=yes" -e "LDAP_CONFIG_ADMIN_USERNAME=admin" -e "LDAP_CONFIG_ADMIN_PASSWORD=configpassword" -v "${{ github.workspace }}/tests/certs/openldap.crt":"/certs/openldap.crt" -v "${{ github.workspace }}/tests/certs/openldap.key":"/certs/openldap.key" -v "${{ github.workspace }}/tests/certs/CA.crt":"/certs/CA.crt" ghcr.io/joomla-projects/mirror-bitnami-openldap:latest - - uses: actions/cache/restore@v4 - with: - path: libraries/vendor - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - - name: Run Integration tests - env: - JTEST_DB_ENGINE: ${{ matrix.config.engine }} - JTEST_DB_HOST: ${{ matrix.config.host }} - JTEST_DB_USER: ${{ matrix.config.user }} - JTEST_DB_NAME: test_joomla - JTEST_DB_PASSWORD: joomla_ut - run: | - sleep 3 - ./libraries/vendor/bin/phpunit --testsuite Integration --configuration phpunit.xml.dist - - name: Stop LDAP container - uses: docker://docker - with: - args: docker kill openldap - services: - mysql: - image: mysql:${{ matrix.config.my_version || '8.4' }} - env: - MYSQL_USER: joomla_ut - MYSQL_PASSWORD: joomla_ut - MYSQL_ROOT_PASSWORD: joomla_ut - MYSQL_DATABASE: test_joomla - maria: - image: mariadb:${{ matrix.config.maria_version || '12.0' }} - env: - MARIADB_USER: joomla_ut - MARIADB_PASSWORD: joomla_ut - MARIADB_ROOT_PASSWORD: joomla_ut - MARIADB_DATABASE: test_joomla - postgres: - image: postgres:${{ matrix.config.pg_version || '18' }}-alpine - env: - POSTGRES_USER: root - POSTGRES_PASSWORD: joomla_ut - POSTGRES_DB: test_joomla - - tests-unit-windows: - name: Run Unit tests (Windows) - runs-on: windows-latest - needs: [code-style-php] - strategy: - matrix: - php_version: ['8.3', '8.4'] - steps: - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - id: cache-php-windows - with: - path: libraries/vendor - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php_version }} - extensions: openssl, mbstring, fileinfo, gd, gmp, pgsql, mysql, mysqli, curl, opcache, ldap - ini-values: post_max_size=256M, date.timezone="UTC" - - name: Install Composer dependencies - if: steps.cache-php-windows.outputs.cache-hit != 'true' - run: composer install --no-progress --ignore-platform-reqs - - name: Run Unit tests - run: php libraries/vendor/bin/phpunit --testsuite Unit - - tests-integration-windows: - name: Run integration tests (Windows) - runs-on: windows-latest - needs: [code-style-php] - strategy: - matrix: - php_version: ['8.3', '8.4'] - steps: - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - with: - path: libraries/vendor - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - - uses: shogo82148/actions-setup-mysql@v1 - with: - mysql-version: "mariadb-10.4" - root-password: "joomla_ut" - user: "joomla_ut" - password: "joomla_ut" - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php_version }} - extensions: openssl, mbstring, fileinfo, gd, gmp, pgsql, mysql, mysqli, curl, opcache, ldap - ini-values: post_max_size=256M, date.timezone="UTC" - - name: Install Composer dependencies - if: steps.cache-php-windows.outputs.cache-hit != 'true' - run: | - composer install --no-progress --ignore-platform-reqs - mysql -uroot -pjoomla_ut -e 'CREATE DATABASE IF NOT EXISTS test_joomla;' - - name: Run Integration tests - run: | - sleep 3 - php libraries/vendor/bin/phpunit --testsuite Integration --configuration phpunit-windows.xml.dist - tests-system-prepare: name: Prepare system tests runs-on: ubuntu-latest @@ -301,7 +88,6 @@ jobs: needs: [tests-system-prepare] strategy: matrix: - browser: ['chrome', 'edge'] config: - php_version: '8.4' test_group: cmysqlmax @@ -354,7 +140,7 @@ jobs: /github/home/.cache/Cypress key: ${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }} - name: Run System tests - run: bash tests/System/entrypoint.sh "$(pwd)" ${{ matrix.config.test_group }} ${{ matrix.config.db_engine }} ${{ matrix.config.db_host }} ${{ matrix.browser }} + run: bash tests/System/entrypoint.sh "$(pwd)" ${{ matrix.config.test_group }} ${{ matrix.config.db_engine }} ${{ matrix.config.db_host }} electron - name: Archive test results results uses: actions/upload-artifact@v4 if: always() @@ -383,14 +169,3 @@ jobs: POSTGRES_USER: root POSTGRES_PASSWORD: joomla_ut POSTGRES_DB: test_joomla - - typos: - name: Check for typos - runs-on: ubuntu-latest - steps: - - name: Checkout Actions Repository - uses: actions/checkout@v4 - - name: Spell Check Repository - uses: crate-ci/typos@v1.34.0 - with: - config: .github/workflows/typos.toml diff --git a/components/com_content/src/Model/ArchiveModel.php b/components/com_content/src/Model/ArchiveModel.php index cc4849ed6379e..56c15351e340d 100644 --- a/components/com_content/src/Model/ArchiveModel.php +++ b/components/com_content/src/Model/ArchiveModel.php @@ -95,6 +95,7 @@ protected function getListQuery() $app = Factory::getApplication(); $catids = $app->getInput()->get('catid', [], 'array'); $catids = array_values(array_diff($catids, [''])); + $catids = array_map('intval', $catids); // temp fix for text; postgres cannot convert space to int at WHERE IN $articleOrderDate = $params->get('order_date'); diff --git a/cypress.config.dist.mjs b/cypress.config.dist.mjs index 612b9e0c1dee8..9b31dada668e1 100644 --- a/cypress.config.dist.mjs +++ b/cypress.config.dist.mjs @@ -14,11 +14,7 @@ export default defineConfig({ baseUrl: 'https://localhost/', specPattern: [ 'tests/System/integration/install/**/*.cy.{js,jsx,ts,tsx}', - 'tests/System/integration/administrator/**/*.cy.{js,jsx,ts,tsx}', - 'tests/System/integration/site/**/*.cy.{js,jsx,ts,tsx}', - 'tests/System/integration/api/**/*.cy.{js,jsx,ts,tsx}', - 'tests/System/integration/plugins/**/*.cy.{js,jsx,ts,tsx}', - 'tests/System/integration/cli/**/*.cy.{js,jsx,ts,tsx}', + 'tests/System/integration/site/issue46371.cy.js', ], supportFile: 'tests/System/support/index.js', scrollBehavior: 'center', diff --git a/tests/System/fixtures/issue-46371/archive/default.xml b/tests/System/fixtures/issue-46371/archive/default.xml new file mode 100644 index 0000000000000..7e0fb8ececd38 --- /dev/null +++ b/tests/System/fixtures/issue-46371/archive/default.xml @@ -0,0 +1,314 @@ + + + + + + + + + + + +
+ + + +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
diff --git a/tests/System/fixtures/issue-46371/featured/default.xml b/tests/System/fixtures/issue-46371/featured/default.xml new file mode 100644 index 0000000000000..c102644d7517d --- /dev/null +++ b/tests/System/fixtures/issue-46371/featured/default.xml @@ -0,0 +1,517 @@ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + +
+
+
diff --git a/tests/System/integration/site/issue46371.cy.js b/tests/System/integration/site/issue46371.cy.js new file mode 100644 index 0000000000000..653b5a5d5f944 --- /dev/null +++ b/tests/System/integration/site/issue46371.cy.js @@ -0,0 +1,204 @@ +const dbdriver = Cypress.env('db_type') === 'pgsql' ? 'postgresql' : 'mysql'; +const sqlPath = `administrator/components/com_admin/sql/updates/${dbdriver}/6.0.1-2025-10-29.sql`; + +describe('Test if issues fixed', () => { + it('featured view', () => { + cy.db_createArticle({ title: 'automated test article 1', featured: 1 }); + cy.db_createArticle({ title: 'automated test article 2', featured: 0 }); + cy.db_createArticle({ title: 'automated test article 3', featured: 1 }); + cy.doAdministratorLogin(); + cy.visit('/administrator/index.php?option=com_menus&task=item.add'); + cy.get('#jform_title').clear().type('test menu content featured view'); + cy.get('.js-modal-content-select-field button').click(); + cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); + cy.get('@dialogContent').should('be.visible'); + cy.get('@dialogContent').within(() => { + cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); + cy.get('section.joomla-dialog-body iframe').iframe().within(() => { + cy.get('button.accordion-button').contains('Articles').click(); + cy.get('a[data-content-select]').contains('Featured Articles').click(); + }); + }); + cy.get('@dialogContent').should('not.exist'); + cy.get('#myTab div[role="tablist"] button[aria-controls="attrib-advanced"]').should('contain', 'Blog Layout').click(); + cy.get('#jform_params_featured_categories option:selected').should('have.text', '- All Categories -'); + cy.get('#jform_params_featured_categories option:selected').should('have.value', ''); + cy.clickToolbarButton('Save'); + cy.checkForSystemMessage('Menu item saved.'); + cy.visit('/'); + cy.get('a').contains('test menu content featured view').click(); + cy.get('main div.blog-featured').within(() => { + cy.get('.blog-item h2.item-title').should('contain', 'automated test article 1'); + cy.get('.blog-item h2.item-title').should('not.contain', 'automated test article 2'); + cy.get('.blog-item h2.item-title').should('contain', 'automated test article 3'); + }); + cy.readFile(sqlPath).then((sql) => { + cy.task('queryDB', sql.split(';')[0]).then((result) => { + if (Cypress.env('db_type') === 'pgsql') { + expect(result.rowCount).to.equal(0); + } else { + expect(result.affectedRows).to.equal(0); + } + }); + }); + cy.db_deleteMenuItem({ title: 'test menu content featured view' }); + }); + + it('archive view', () => { + cy.db_createArticle({ title: 'automated test article 1', state: 2 }); + cy.db_createArticle({ title: 'automated test article 2', state: 1 }); + cy.db_createArticle({ title: 'automated test article 3', state: 2 }); + cy.doAdministratorLogin(); + cy.visit('/administrator/index.php?option=com_menus&task=item.add'); + cy.get('#jform_title').clear().type('test menu content archive view'); + cy.get('.js-modal-content-select-field button').click(); + cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); + cy.get('@dialogContent').should('be.visible'); + cy.get('@dialogContent').within(() => { + cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); + cy.get('section.joomla-dialog-body iframe').iframe().within(() => { + cy.get('button.accordion-button').contains('Articles').click(); + cy.get('a[data-content-select]').contains('Archived Articles').click(); + }); + }); + cy.get('@dialogContent').should('not.exist'); + cy.get('#jform_request_catid option:selected').should('have.text', '- All Categories -'); + cy.get('#jform_request_catid option:selected').should('have.value', ''); + cy.clickToolbarButton('Save'); + cy.checkForSystemMessage('Menu item saved.'); + cy.visit('/'); + cy.get('a').contains('test menu content archive view').click(); + cy.url().should('match', /\?catid\[0\]=$/) + cy.get('#archive-items').within(() => { + cy.get('div.page-header h2').should('contain', 'automated test article 1'); + cy.get('div.page-header h2').should('not.contain', 'automated test article 2'); + cy.get('div.page-header h2').should('contain', 'automated test article 3'); + }); + cy.readFile(sqlPath).then((sql) => { + cy.task('queryDB', sql.split(';')[1]).then((result) => { + if (Cypress.env('db_type') === 'pgsql') { + expect(result.rowCount).to.equal(0); + } else { + expect(result.affectedRows).to.equal(0); + } + }); + }); + cy.db_deleteMenuItem({ title: 'test menu content archive view' }); + }); + + it('featured view (update)', () => { + cy.task('copyRelativeFile', { + source: 'components/com_content/tmpl/featured/default.xml', + destination: 'components/com_content/tmpl/featured/default.bak', + }); + cy.task('copyRelativeFile', { + source: 'tests/System/fixtures/issue-46371/featured/default.xml', + destination: 'components/com_content/tmpl/featured/default.xml', + }); + cy.db_createArticle({ title: 'automated test article 1', featured: 1 }); + cy.db_createArticle({ title: 'automated test article 2', featured: 0 }); + cy.db_createArticle({ title: 'automated test article 3', featured: 1 }); + cy.doAdministratorLogin(); + cy.visit('/administrator/index.php?option=com_menus&task=item.add'); + cy.get('#jform_title').clear().type('test menu content featured view'); + cy.get('.js-modal-content-select-field button').click(); + cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); + cy.get('@dialogContent').should('be.visible'); + cy.get('@dialogContent').within(() => { + cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); + cy.get('section.joomla-dialog-body iframe').iframe().within(() => { + cy.get('button.accordion-button').contains('Articles').click(); + cy.get('a[data-content-select]').contains('Featured Articles').click(); + }); + }); + cy.get('@dialogContent').should('not.exist'); + cy.get('#myTab div[role="tablist"] button[aria-controls="attrib-advanced"]').should('contain', 'Blog Layout').click(); + cy.get('#jform_params_featured_categories option:selected').should('have.text', '- All Categories -'); + cy.get('#jform_params_featured_categories option:selected').should('have.value', ' '); + cy.clickToolbarButton('Save'); + cy.checkForSystemMessage('Menu item saved.'); + cy.visit('/'); + cy.get('a').contains('test menu content featured view').click(); + cy.get('main div.blog-featured .blog-item').should('not.exist'); + cy.readFile(sqlPath).then((sql) => { + cy.task('queryDB', sql.split(';')[0]).then((result) => { + if (Cypress.env('db_type') === 'pgsql') { + expect(result.rowCount).to.equal(1); + } else { + expect(result.affectedRows).to.equal(1); + } + }); + }); + cy.reload(); + cy.get('main div.blog-featured').within(() => { + cy.get('.blog-item h2.item-title').should('contain', 'automated test article 1'); + cy.get('.blog-item h2.item-title').should('not.contain', 'automated test article 2'); + cy.get('.blog-item h2.item-title').should('contain', 'automated test article 3'); + }); + cy.db_deleteMenuItem({ title: 'test menu content featured view' }); + cy.task('copyRelativeFile', { + source: 'components/com_content/tmpl/featured/default.bak', + destination: 'components/com_content/tmpl/featured/default.xml', + }); + cy.task('deleteRelativePath', 'components/com_content/tmpl/featured/default.bak'); + }); + + it('archive view (update)', () => { + cy.task('copyRelativeFile', { + source: 'components/com_content/tmpl/archive/default.xml', + destination: 'components/com_content/tmpl/archive/default.bak', + }); + cy.task('copyRelativeFile', { + source: 'tests/System/fixtures/issue-46371/archive/default.xml', + destination: 'components/com_content/tmpl/archive/default.xml', + }); + cy.db_createArticle({ title: 'automated test article 1', state: 2 }); + cy.db_createArticle({ title: 'automated test article 2', state: 1 }); + cy.db_createArticle({ title: 'automated test article 3', state: 2 }); + cy.doAdministratorLogin(); + cy.visit('/administrator/index.php?option=com_menus&task=item.add'); + cy.get('#jform_title').clear().type('test menu content archive view'); + cy.get('.js-modal-content-select-field button').click(); + cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); + cy.get('@dialogContent').should('be.visible'); + cy.get('@dialogContent').within(() => { + cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); + cy.get('section.joomla-dialog-body iframe').iframe().within(() => { + cy.get('button.accordion-button').contains('Articles').click(); + cy.get('a[data-content-select]').contains('Archived Articles').click(); + }); + }); + cy.get('@dialogContent').should('not.exist'); + cy.get('#jform_request_catid option:selected').should('have.text', '- All Categories -'); + cy.get('#jform_request_catid option:selected').should('have.value', ' '); + cy.clickToolbarButton('Save'); + cy.checkForSystemMessage('Menu item saved.'); + cy.visit('/'); + cy.get('a').contains('test menu content archive view').click(); + cy.get('#archive-items div').should('not.exist'); + cy.url().should('match', /\?catid\[0\]=%20$/) + cy.readFile(sqlPath).then((sql) => { + cy.task('queryDB', sql.split(';')[1]).then((result) => { + if (Cypress.env('db_type') === 'pgsql') { + expect(result.rowCount).to.equal(1); + } else { + expect(result.affectedRows).to.equal(1); + } + }); + }); + cy.reload(); + cy.get('a').contains('test menu content archive view').click(); + cy.url().should('match', /\?catid\[0\]=$/) + cy.get('#archive-items').within(() => { + cy.get('div.page-header h2').should('contain', 'automated test article 1'); + cy.get('div.page-header h2').should('not.contain', 'automated test article 2'); + cy.get('div.page-header h2').should('contain', 'automated test article 3'); + }); + cy.db_deleteMenuItem({ title: 'test menu content archive view' }); + cy.task('copyRelativeFile', { + source: 'components/com_content/tmpl/archive/default.bak', + destination: 'components/com_content/tmpl/archive/default.xml', + }); + cy.task('deleteRelativePath', 'components/com_content/tmpl/archive/default.bak'); + }); +}); diff --git a/tests/System/plugins/db.mjs b/tests/System/plugins/db.mjs index e8bdcbff02f00..513339c09873e 100644 --- a/tests/System/plugins/db.mjs +++ b/tests/System/plugins/db.mjs @@ -73,6 +73,10 @@ function queryTestDB(joomlaQuery, config) { return [result.rows]; } + if (!insertItem && result.rows.length === 0) { + return result; + } + if (!insertItem || result.rows.length === 0) { return result.rows; } From 3bba3403561a85d96989f69c95e984152018d173 Mon Sep 17 00:00:00 2001 From: Christian Heel <66922325+heelc29@users.noreply.github.com> Date: Sat, 1 Nov 2025 17:21:28 +0100 Subject: [PATCH 7/7] Revert "temp testing - this commit needs to be reverted" This reverts commit 7c62eea1cbe36673e87e848a3aeada1ade1b367a. --- .github/workflows/ci.yml | 227 +++++++- .../com_content/src/Model/ArchiveModel.php | 1 - cypress.config.dist.mjs | 6 +- .../fixtures/issue-46371/archive/default.xml | 314 ----------- .../fixtures/issue-46371/featured/default.xml | 517 ------------------ .../System/integration/site/issue46371.cy.js | 204 ------- tests/System/plugins/db.mjs | 4 - 7 files changed, 231 insertions(+), 1042 deletions(-) delete mode 100644 tests/System/fixtures/issue-46371/archive/default.xml delete mode 100644 tests/System/fixtures/issue-46371/featured/default.xml delete mode 100644 tests/System/integration/site/issue46371.cy.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9f1943003e8c..02688c6958eac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,219 @@ jobs: if: steps.cache-assets.outputs.cache-hit != 'true' run: npm ci --unsafe-perm + code-style-php: + name: Check PHP code style + runs-on: ubuntu-latest + container: joomlaprojects/docker-images:php8.4 + needs: [composer] + strategy: + matrix: + command: ['php-cs-fixer fix -vvv --dry-run --diff', 'phpcs --extensions=php -p --standard=ruleset.xml .'] + steps: + - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: libraries/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} + - name: Check PHP code style + env: + PHP_CS_FIXER_IGNORE_ENV: true + run: ./libraries/vendor/bin/${{ matrix.command }} + + code-style-js-css: + name: Check Javascript & CSS code style + runs-on: ubuntu-latest + container: joomlaprojects/docker-images:php8.4 + needs: [composer, npm] + strategy: + matrix: + check: ['lint:js', 'lint:testjs', 'lint:css'] + steps: + - uses: actions/setup-node@v4 + with: + node-version: latest + - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: | + node_modules + media + key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json', 'build/media_source/**', 'administrator/components/com_media/resources/**') }} + - name: Check code style + run: npm run ${{ matrix.check }} + + phpstan: + name: Run PHPstan + runs-on: ubuntu-latest + container: joomlaprojects/docker-images:php8.4 + needs: [code-style-php] + steps: + - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: libraries/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }} + - name: Run PHPstan + run: | + ./libraries/vendor/bin/phpstan --error-format=github + + tests-unit: + name: Run Unit tests + runs-on: ubuntu-latest + container: joomlaprojects/docker-images:php${{ matrix.php_version }} + needs: [code-style-php] + strategy: + matrix: + php_version: ['8.3', '8.4'] + steps: + - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: libraries/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + - name: Run Unit tests + run: ./libraries/vendor/bin/phpunit --testsuite Unit + + tests-integration: + name: Run integration tests + runs-on: ubuntu-latest + container: joomlaprojects/docker-images:php${{ matrix.php_version }} + needs: [code-style-php] + strategy: + matrix: + php_version: ['8.3', '8.4'] + config: + - my_version: '8.4' + engine: 'mysqli' + host: 'mysql' + user: 'joomla_ut' + - my_version: '8.0.13' + engine: 'mysqli' + host: 'mysql' + user: 'joomla_ut' + - maria_version: '12.0' + engine: 'mysqli' + host: 'maria' + user: 'joomla_ut' + - maria_version: '10.4' + engine: 'mysqli' + host: 'maria' + user: 'joomla_ut' + - pg_version: '12.0' + engine: 'pgsql' + host: 'postgres' + user: 'root' + - pg_version: '18.0' + engine: 'pgsql' + host: 'postgres' + user: 'root' + steps: + - uses: actions/checkout@v4 + - name: Start LDAP container + uses: docker://docker + with: + args: docker run -d --name openldap --network ${{ job.container.network }} --network-alias openldap -e "LDAP_ADMIN_USERNAME=admin" -e "LDAP_ADMIN_PASSWORD=adminpassword" -e "LDAP_USERS=customuser" -e "LDAP_PASSWORDS=custompassword" -e "LDAP_ENABLE_TLS=yes" -e "LDAP_TLS_CERT_FILE=/certs/openldap.crt" -e "LDAP_TLS_KEY_FILE=/certs/openldap.key" -e "LDAP_TLS_CA_FILE=/certs/CA.crt" -e "BITNAMI_DEBUG=true" -e "LDAP_CONFIG_ADMIN_ENABLED=yes" -e "LDAP_CONFIG_ADMIN_USERNAME=admin" -e "LDAP_CONFIG_ADMIN_PASSWORD=configpassword" -v "${{ github.workspace }}/tests/certs/openldap.crt":"/certs/openldap.crt" -v "${{ github.workspace }}/tests/certs/openldap.key":"/certs/openldap.key" -v "${{ github.workspace }}/tests/certs/CA.crt":"/certs/CA.crt" ghcr.io/joomla-projects/mirror-bitnami-openldap:latest + - uses: actions/cache/restore@v4 + with: + path: libraries/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + - name: Run Integration tests + env: + JTEST_DB_ENGINE: ${{ matrix.config.engine }} + JTEST_DB_HOST: ${{ matrix.config.host }} + JTEST_DB_USER: ${{ matrix.config.user }} + JTEST_DB_NAME: test_joomla + JTEST_DB_PASSWORD: joomla_ut + run: | + sleep 3 + ./libraries/vendor/bin/phpunit --testsuite Integration --configuration phpunit.xml.dist + - name: Stop LDAP container + uses: docker://docker + with: + args: docker kill openldap + services: + mysql: + image: mysql:${{ matrix.config.my_version || '8.4' }} + env: + MYSQL_USER: joomla_ut + MYSQL_PASSWORD: joomla_ut + MYSQL_ROOT_PASSWORD: joomla_ut + MYSQL_DATABASE: test_joomla + maria: + image: mariadb:${{ matrix.config.maria_version || '12.0' }} + env: + MARIADB_USER: joomla_ut + MARIADB_PASSWORD: joomla_ut + MARIADB_ROOT_PASSWORD: joomla_ut + MARIADB_DATABASE: test_joomla + postgres: + image: postgres:${{ matrix.config.pg_version || '18' }}-alpine + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: joomla_ut + POSTGRES_DB: test_joomla + + tests-unit-windows: + name: Run Unit tests (Windows) + runs-on: windows-latest + needs: [code-style-php] + strategy: + matrix: + php_version: ['8.3', '8.4'] + steps: + - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + id: cache-php-windows + with: + path: libraries/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + extensions: openssl, mbstring, fileinfo, gd, gmp, pgsql, mysql, mysqli, curl, opcache, ldap + ini-values: post_max_size=256M, date.timezone="UTC" + - name: Install Composer dependencies + if: steps.cache-php-windows.outputs.cache-hit != 'true' + run: composer install --no-progress --ignore-platform-reqs + - name: Run Unit tests + run: php libraries/vendor/bin/phpunit --testsuite Unit + + tests-integration-windows: + name: Run integration tests (Windows) + runs-on: windows-latest + needs: [code-style-php] + strategy: + matrix: + php_version: ['8.3', '8.4'] + steps: + - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: libraries/vendor + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + - uses: shogo82148/actions-setup-mysql@v1 + with: + mysql-version: "mariadb-10.4" + root-password: "joomla_ut" + user: "joomla_ut" + password: "joomla_ut" + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + extensions: openssl, mbstring, fileinfo, gd, gmp, pgsql, mysql, mysqli, curl, opcache, ldap + ini-values: post_max_size=256M, date.timezone="UTC" + - name: Install Composer dependencies + if: steps.cache-php-windows.outputs.cache-hit != 'true' + run: | + composer install --no-progress --ignore-platform-reqs + mysql -uroot -pjoomla_ut -e 'CREATE DATABASE IF NOT EXISTS test_joomla;' + - name: Run Integration tests + run: | + sleep 3 + php libraries/vendor/bin/phpunit --testsuite Integration --configuration phpunit-windows.xml.dist + tests-system-prepare: name: Prepare system tests runs-on: ubuntu-latest @@ -88,6 +301,7 @@ jobs: needs: [tests-system-prepare] strategy: matrix: + browser: ['chrome', 'edge'] config: - php_version: '8.4' test_group: cmysqlmax @@ -140,7 +354,7 @@ jobs: /github/home/.cache/Cypress key: ${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }} - name: Run System tests - run: bash tests/System/entrypoint.sh "$(pwd)" ${{ matrix.config.test_group }} ${{ matrix.config.db_engine }} ${{ matrix.config.db_host }} electron + run: bash tests/System/entrypoint.sh "$(pwd)" ${{ matrix.config.test_group }} ${{ matrix.config.db_engine }} ${{ matrix.config.db_host }} ${{ matrix.browser }} - name: Archive test results results uses: actions/upload-artifact@v4 if: always() @@ -169,3 +383,14 @@ jobs: POSTGRES_USER: root POSTGRES_PASSWORD: joomla_ut POSTGRES_DB: test_joomla + + typos: + name: Check for typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Spell Check Repository + uses: crate-ci/typos@v1.34.0 + with: + config: .github/workflows/typos.toml diff --git a/components/com_content/src/Model/ArchiveModel.php b/components/com_content/src/Model/ArchiveModel.php index 56c15351e340d..cc4849ed6379e 100644 --- a/components/com_content/src/Model/ArchiveModel.php +++ b/components/com_content/src/Model/ArchiveModel.php @@ -95,7 +95,6 @@ protected function getListQuery() $app = Factory::getApplication(); $catids = $app->getInput()->get('catid', [], 'array'); $catids = array_values(array_diff($catids, [''])); - $catids = array_map('intval', $catids); // temp fix for text; postgres cannot convert space to int at WHERE IN $articleOrderDate = $params->get('order_date'); diff --git a/cypress.config.dist.mjs b/cypress.config.dist.mjs index 9b31dada668e1..612b9e0c1dee8 100644 --- a/cypress.config.dist.mjs +++ b/cypress.config.dist.mjs @@ -14,7 +14,11 @@ export default defineConfig({ baseUrl: 'https://localhost/', specPattern: [ 'tests/System/integration/install/**/*.cy.{js,jsx,ts,tsx}', - 'tests/System/integration/site/issue46371.cy.js', + 'tests/System/integration/administrator/**/*.cy.{js,jsx,ts,tsx}', + 'tests/System/integration/site/**/*.cy.{js,jsx,ts,tsx}', + 'tests/System/integration/api/**/*.cy.{js,jsx,ts,tsx}', + 'tests/System/integration/plugins/**/*.cy.{js,jsx,ts,tsx}', + 'tests/System/integration/cli/**/*.cy.{js,jsx,ts,tsx}', ], supportFile: 'tests/System/support/index.js', scrollBehavior: 'center', diff --git a/tests/System/fixtures/issue-46371/archive/default.xml b/tests/System/fixtures/issue-46371/archive/default.xml deleted file mode 100644 index 7e0fb8ececd38..0000000000000 --- a/tests/System/fixtures/issue-46371/archive/default.xml +++ /dev/null @@ -1,314 +0,0 @@ - - - - - - - - - - - -
- - - -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
diff --git a/tests/System/fixtures/issue-46371/featured/default.xml b/tests/System/fixtures/issue-46371/featured/default.xml deleted file mode 100644 index c102644d7517d..0000000000000 --- a/tests/System/fixtures/issue-46371/featured/default.xml +++ /dev/null @@ -1,517 +0,0 @@ - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - -
-
-
diff --git a/tests/System/integration/site/issue46371.cy.js b/tests/System/integration/site/issue46371.cy.js deleted file mode 100644 index 653b5a5d5f944..0000000000000 --- a/tests/System/integration/site/issue46371.cy.js +++ /dev/null @@ -1,204 +0,0 @@ -const dbdriver = Cypress.env('db_type') === 'pgsql' ? 'postgresql' : 'mysql'; -const sqlPath = `administrator/components/com_admin/sql/updates/${dbdriver}/6.0.1-2025-10-29.sql`; - -describe('Test if issues fixed', () => { - it('featured view', () => { - cy.db_createArticle({ title: 'automated test article 1', featured: 1 }); - cy.db_createArticle({ title: 'automated test article 2', featured: 0 }); - cy.db_createArticle({ title: 'automated test article 3', featured: 1 }); - cy.doAdministratorLogin(); - cy.visit('/administrator/index.php?option=com_menus&task=item.add'); - cy.get('#jform_title').clear().type('test menu content featured view'); - cy.get('.js-modal-content-select-field button').click(); - cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); - cy.get('@dialogContent').should('be.visible'); - cy.get('@dialogContent').within(() => { - cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); - cy.get('section.joomla-dialog-body iframe').iframe().within(() => { - cy.get('button.accordion-button').contains('Articles').click(); - cy.get('a[data-content-select]').contains('Featured Articles').click(); - }); - }); - cy.get('@dialogContent').should('not.exist'); - cy.get('#myTab div[role="tablist"] button[aria-controls="attrib-advanced"]').should('contain', 'Blog Layout').click(); - cy.get('#jform_params_featured_categories option:selected').should('have.text', '- All Categories -'); - cy.get('#jform_params_featured_categories option:selected').should('have.value', ''); - cy.clickToolbarButton('Save'); - cy.checkForSystemMessage('Menu item saved.'); - cy.visit('/'); - cy.get('a').contains('test menu content featured view').click(); - cy.get('main div.blog-featured').within(() => { - cy.get('.blog-item h2.item-title').should('contain', 'automated test article 1'); - cy.get('.blog-item h2.item-title').should('not.contain', 'automated test article 2'); - cy.get('.blog-item h2.item-title').should('contain', 'automated test article 3'); - }); - cy.readFile(sqlPath).then((sql) => { - cy.task('queryDB', sql.split(';')[0]).then((result) => { - if (Cypress.env('db_type') === 'pgsql') { - expect(result.rowCount).to.equal(0); - } else { - expect(result.affectedRows).to.equal(0); - } - }); - }); - cy.db_deleteMenuItem({ title: 'test menu content featured view' }); - }); - - it('archive view', () => { - cy.db_createArticle({ title: 'automated test article 1', state: 2 }); - cy.db_createArticle({ title: 'automated test article 2', state: 1 }); - cy.db_createArticle({ title: 'automated test article 3', state: 2 }); - cy.doAdministratorLogin(); - cy.visit('/administrator/index.php?option=com_menus&task=item.add'); - cy.get('#jform_title').clear().type('test menu content archive view'); - cy.get('.js-modal-content-select-field button').click(); - cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); - cy.get('@dialogContent').should('be.visible'); - cy.get('@dialogContent').within(() => { - cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); - cy.get('section.joomla-dialog-body iframe').iframe().within(() => { - cy.get('button.accordion-button').contains('Articles').click(); - cy.get('a[data-content-select]').contains('Archived Articles').click(); - }); - }); - cy.get('@dialogContent').should('not.exist'); - cy.get('#jform_request_catid option:selected').should('have.text', '- All Categories -'); - cy.get('#jform_request_catid option:selected').should('have.value', ''); - cy.clickToolbarButton('Save'); - cy.checkForSystemMessage('Menu item saved.'); - cy.visit('/'); - cy.get('a').contains('test menu content archive view').click(); - cy.url().should('match', /\?catid\[0\]=$/) - cy.get('#archive-items').within(() => { - cy.get('div.page-header h2').should('contain', 'automated test article 1'); - cy.get('div.page-header h2').should('not.contain', 'automated test article 2'); - cy.get('div.page-header h2').should('contain', 'automated test article 3'); - }); - cy.readFile(sqlPath).then((sql) => { - cy.task('queryDB', sql.split(';')[1]).then((result) => { - if (Cypress.env('db_type') === 'pgsql') { - expect(result.rowCount).to.equal(0); - } else { - expect(result.affectedRows).to.equal(0); - } - }); - }); - cy.db_deleteMenuItem({ title: 'test menu content archive view' }); - }); - - it('featured view (update)', () => { - cy.task('copyRelativeFile', { - source: 'components/com_content/tmpl/featured/default.xml', - destination: 'components/com_content/tmpl/featured/default.bak', - }); - cy.task('copyRelativeFile', { - source: 'tests/System/fixtures/issue-46371/featured/default.xml', - destination: 'components/com_content/tmpl/featured/default.xml', - }); - cy.db_createArticle({ title: 'automated test article 1', featured: 1 }); - cy.db_createArticle({ title: 'automated test article 2', featured: 0 }); - cy.db_createArticle({ title: 'automated test article 3', featured: 1 }); - cy.doAdministratorLogin(); - cy.visit('/administrator/index.php?option=com_menus&task=item.add'); - cy.get('#jform_title').clear().type('test menu content featured view'); - cy.get('.js-modal-content-select-field button').click(); - cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); - cy.get('@dialogContent').should('be.visible'); - cy.get('@dialogContent').within(() => { - cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); - cy.get('section.joomla-dialog-body iframe').iframe().within(() => { - cy.get('button.accordion-button').contains('Articles').click(); - cy.get('a[data-content-select]').contains('Featured Articles').click(); - }); - }); - cy.get('@dialogContent').should('not.exist'); - cy.get('#myTab div[role="tablist"] button[aria-controls="attrib-advanced"]').should('contain', 'Blog Layout').click(); - cy.get('#jform_params_featured_categories option:selected').should('have.text', '- All Categories -'); - cy.get('#jform_params_featured_categories option:selected').should('have.value', ' '); - cy.clickToolbarButton('Save'); - cy.checkForSystemMessage('Menu item saved.'); - cy.visit('/'); - cy.get('a').contains('test menu content featured view').click(); - cy.get('main div.blog-featured .blog-item').should('not.exist'); - cy.readFile(sqlPath).then((sql) => { - cy.task('queryDB', sql.split(';')[0]).then((result) => { - if (Cypress.env('db_type') === 'pgsql') { - expect(result.rowCount).to.equal(1); - } else { - expect(result.affectedRows).to.equal(1); - } - }); - }); - cy.reload(); - cy.get('main div.blog-featured').within(() => { - cy.get('.blog-item h2.item-title').should('contain', 'automated test article 1'); - cy.get('.blog-item h2.item-title').should('not.contain', 'automated test article 2'); - cy.get('.blog-item h2.item-title').should('contain', 'automated test article 3'); - }); - cy.db_deleteMenuItem({ title: 'test menu content featured view' }); - cy.task('copyRelativeFile', { - source: 'components/com_content/tmpl/featured/default.bak', - destination: 'components/com_content/tmpl/featured/default.xml', - }); - cy.task('deleteRelativePath', 'components/com_content/tmpl/featured/default.bak'); - }); - - it('archive view (update)', () => { - cy.task('copyRelativeFile', { - source: 'components/com_content/tmpl/archive/default.xml', - destination: 'components/com_content/tmpl/archive/default.bak', - }); - cy.task('copyRelativeFile', { - source: 'tests/System/fixtures/issue-46371/archive/default.xml', - destination: 'components/com_content/tmpl/archive/default.xml', - }); - cy.db_createArticle({ title: 'automated test article 1', state: 2 }); - cy.db_createArticle({ title: 'automated test article 2', state: 1 }); - cy.db_createArticle({ title: 'automated test article 3', state: 2 }); - cy.doAdministratorLogin(); - cy.visit('/administrator/index.php?option=com_menus&task=item.add'); - cy.get('#jform_title').clear().type('test menu content archive view'); - cy.get('.js-modal-content-select-field button').click(); - cy.get('joomla-dialog.joomla-dialog-content-select-field[type="iframe"]').as('dialogContent'); - cy.get('@dialogContent').should('be.visible'); - cy.get('@dialogContent').within(() => { - cy.get('header.joomla-dialog-header').should('contain', 'Menu Item Type'); - cy.get('section.joomla-dialog-body iframe').iframe().within(() => { - cy.get('button.accordion-button').contains('Articles').click(); - cy.get('a[data-content-select]').contains('Archived Articles').click(); - }); - }); - cy.get('@dialogContent').should('not.exist'); - cy.get('#jform_request_catid option:selected').should('have.text', '- All Categories -'); - cy.get('#jform_request_catid option:selected').should('have.value', ' '); - cy.clickToolbarButton('Save'); - cy.checkForSystemMessage('Menu item saved.'); - cy.visit('/'); - cy.get('a').contains('test menu content archive view').click(); - cy.get('#archive-items div').should('not.exist'); - cy.url().should('match', /\?catid\[0\]=%20$/) - cy.readFile(sqlPath).then((sql) => { - cy.task('queryDB', sql.split(';')[1]).then((result) => { - if (Cypress.env('db_type') === 'pgsql') { - expect(result.rowCount).to.equal(1); - } else { - expect(result.affectedRows).to.equal(1); - } - }); - }); - cy.reload(); - cy.get('a').contains('test menu content archive view').click(); - cy.url().should('match', /\?catid\[0\]=$/) - cy.get('#archive-items').within(() => { - cy.get('div.page-header h2').should('contain', 'automated test article 1'); - cy.get('div.page-header h2').should('not.contain', 'automated test article 2'); - cy.get('div.page-header h2').should('contain', 'automated test article 3'); - }); - cy.db_deleteMenuItem({ title: 'test menu content archive view' }); - cy.task('copyRelativeFile', { - source: 'components/com_content/tmpl/archive/default.bak', - destination: 'components/com_content/tmpl/archive/default.xml', - }); - cy.task('deleteRelativePath', 'components/com_content/tmpl/archive/default.bak'); - }); -}); diff --git a/tests/System/plugins/db.mjs b/tests/System/plugins/db.mjs index 513339c09873e..e8bdcbff02f00 100644 --- a/tests/System/plugins/db.mjs +++ b/tests/System/plugins/db.mjs @@ -73,10 +73,6 @@ function queryTestDB(joomlaQuery, config) { return [result.rows]; } - if (!insertItem && result.rows.length === 0) { - return result; - } - if (!insertItem || result.rows.length === 0) { return result.rows; }