diff --git a/src/language/de-DE/de-DE.mod_zitat_service_de.ini b/src/language/de-DE/de-DE.mod_zitat_service_de.ini index 2ef50bd..4969c29 100644 --- a/src/language/de-DE/de-DE.mod_zitat_service_de.ini +++ b/src/language/de-DE/de-DE.mod_zitat_service_de.ini @@ -4,32 +4,15 @@ ; MIT License, Copyright (c) 2008 - 2023 Heiko Lübbe ; https://github.com/muhme/quote_joomla ; -MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = " - -
-
🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦
-

zitat-service.de, Version 2.0.2

-

Zeigt ein Zufalls-Zitat der Benutzer-Gemeinschaft www.zitat-service.de/de an.

-

Hilfe: github.com/muhme/quote_joomla/wiki/Hilfe

-
" +MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = "Zeigt ein zufälliges Zitat aus der zitat-service.de Nutzergemeinschaft in den folgenden Sprachen an: 🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦.
Hilfe unter github.com/muhme/quote_joomla/wiki/Hilfe" MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_LABEL = "Autor wählen" -MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_DESC = "Wähle einen Autor aus der Liste (tippe die Angfangsbuchstaben des Nachnamens). Wähle \"*\", um Zitate aller Autoren anzuzeigen." +MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_DESC = "Wähle einen Autor aus der Liste (tippe die Angfangsbuchstaben des Nachnamens). Wähle „*”, um Zitate aller Autoren anzuzeigen." MOD_ZITAT_SERVICE_DE_FIELD_CATEGORY_LABEL = "Kategorie wählen" -MOD_ZITAT_SERVICE_DE_FIELD_CATEGORY_DESC = "Wähle eine Kategorie aus der Liste (tippe die Anfangsbuchstaben). Wähle \"*\", um Zitate aus allen Kategorien anzuzeigen." +MOD_ZITAT_SERVICE_DE_FIELD_CATEGORY_DESC = "Wähle eine Kategorie aus der Liste (tippe die Anfangsbuchstaben). Wähle „*”, um Zitate aus allen Kategorien anzuzeigen." MOD_ZITAT_SERVICE_DE_FIELD_USER_LABEL = "Benutzer wählen" -MOD_ZITAT_SERVICE_DE_FIELD_USER_DESC = "Wähle einen Login-Namen aus der Liste (tippe die Anfangsbuchstaben). Wähle \"*\", um Zitate aus der ganzen Benutzer-Gemeinschaft anzuzeigen." +MOD_ZITAT_SERVICE_DE_FIELD_USER_DESC = "Wähle einen Login-Namen aus der Liste (tippe die Anfangsbuchstaben). Wähle „*”, um Zitate aus der ganzen Benutzer-Gemeinschaft anzuzeigen." MOD_ZITAT_SERVICE_DE_FIELD_LANGUAGE_LABEL = "Sprache wählen" -MOD_ZITAT_SERVICE_DE_FIELD_LANGUAGE_DESC = "Wähle ein einzelne oder \"all\" für alle Sprachen. Bei \"frontend\" wird - wenn unterstützt - die Sprache des Browsers genutzt, sonst Englisch." +MOD_ZITAT_SERVICE_DE_FIELD_LANGUAGE_DESC = "Wähle ein einzelne oder „all” für alle Sprachen. Bei „frontend” wird - wenn unterstützt - die Sprache des Browsers genutzt, sonst Englisch." MOD_ZITAT_SERVICE_DE_FIELD_TARGET_LABEL = "Vorgabe für HTML-Links" MOD_ZITAT_SERVICE_DE_FIELD_TARGET_DESC = "Ohne Eingabe öffnen Links im gleichen Fenster/Tab. Sonst kann das target-Attribut von HTML-Links gesetzt werden." MOD_ZITAT_SERVICE_DE_FIELD_SCRIPT_LABEL = "Abfragemethode" @@ -37,4 +20,4 @@ MOD_ZITAT_SERVICE_DE_FIELD_SCRIPT_DESC = "Die Abfragemethode legt fest, wie d MOD_ZITAT_SERVICE_DE_FIELD_SCRIPT_0 = "Aus Joomla (langsamer)" MOD_ZITAT_SERVICE_DE_FIELD_SCRIPT_1 = "Asynchron mit JavaScript im Web-Browser (empfohlen)" MOD_ZITAT_SERVICE_DE_FIELD_HEIGHT_LABEL = "Höhe (CSS)" -MOD_ZITAT_SERVICE_DE_FIELD_HEIGHT_DESC = "Die minimale Höhe des Moduls, z.B. \"20ex\" oder \"200px\"." +MOD_ZITAT_SERVICE_DE_FIELD_HEIGHT_DESC = "Die minimale Höhe des Moduls, z.B. „20ex” oder ”200px”." diff --git a/src/language/en-GB/en-GB.mod_zitat_service_de.ini b/src/language/en-GB/en-GB.mod_zitat_service_de.ini index d56da34..beb57d8 100644 --- a/src/language/en-GB/en-GB.mod_zitat_service_de.ini +++ b/src/language/en-GB/en-GB.mod_zitat_service_de.ini @@ -4,24 +4,7 @@ ; MIT License, Copyright (c) 2008 - 2023 Heiko Lübbe ; https://github.com/muhme/quote_joomla ; -MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = " - -
-
🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦
-

zitat-service.de, Version 2.0.2

-

Displays a random quote from the user community at www.zitat-service.de/en.

-

Help: github.com/muhme/quote_joomla/wiki.

-
" +MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = "Displays a random quote from the zitat-service.de user community in the following languages: 🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦.
See help at github.com/muhme/quote_joomla/wiki." MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_LABEL = "Choose Author" MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_DESC = "Select an author from the list (type the initial letters of the surname). Select '*', to display quotes from all authors." MOD_ZITAT_SERVICE_DE_FIELD_CATEGORY_LABEL = "Choose Category" diff --git a/src/language/es-ES/es-ES.mod_zitat_service_de.ini b/src/language/es-ES/es-ES.mod_zitat_service_de.ini index 06dcde8..9ae4a27 100644 --- a/src/language/es-ES/es-ES.mod_zitat_service_de.ini +++ b/src/language/es-ES/es-ES.mod_zitat_service_de.ini @@ -4,24 +4,7 @@ ; MIT License, Copyright (c) 2008 - 2023 Heiko Lübbe ; https://github.com/muhme/quote_joomla ; -MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = " - -
-
🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦
-

zitat-service.de, Versión 2.0.2

-

Muestra una cita aleatoria de la comunidad de usuarios en www.zitat-service.de/es.

-

Ayuda: github.com/muhme/quote_joomla/wiki/Ayuda.

-
" +MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = "Muestra una cita aleatoria de la comunidad de usuarios de zitat-service.de en los siguientes idiomas: 🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦.
Ver ayuda en github.com/muhme/quote_joomla/wiki/Ayuda." MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_LABEL = "Elegir Autor" MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_DESC = "Selecciona un autor de la lista (escribe las letras iniciales del apellido). Selecciona '*', para mostrar citas de todos los autores." MOD_ZITAT_SERVICE_DE_FIELD_CATEGORY_LABEL = "Elegir Categoría" diff --git a/src/language/ja-JP/ja-JP.mod_zitat_service_de.ini b/src/language/ja-JP/ja-JP.mod_zitat_service_de.ini index a3c2fe2..63d00b0 100644 --- a/src/language/ja-JP/ja-JP.mod_zitat_service_de.ini +++ b/src/language/ja-JP/ja-JP.mod_zitat_service_de.ini @@ -4,24 +4,7 @@ ; MIT License, Copyright (c) 2008 - 2023 Heiko Lübbe ; https://github.com/muhme/quote_joomla ; -MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = " - -
-
🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦
-

zitat-service.de、バージョン2.0.2

-

www.zitat-service.de/jaのユーザーコミュニティからランダムな引用を表示します。

-

助けてくれ:github.com/muhme/quote_joomla/wiki/ヘルプ

-
" +MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = "zitat-service.de ユーザーコミュニティからのランダムな引用を以下の言語で表示します: 🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦.
github.com/muhme/quote_joomla/wiki/ヘルプをご覧くださいのヘルプを参照。" MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_LABEL = "著者を選択" MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_DESC = "リストから著者を選択してください(姓の頭文字を入力)。'*'を選択すると、すべての著者の引用を表示します。" MOD_ZITAT_SERVICE_DE_FIELD_CATEGORY_LABEL = "カテゴリを選択" diff --git a/src/language/uk-UA/uk-UA.mod_zitat_service_de.ini b/src/language/uk-UA/uk-UA.mod_zitat_service_de.ini index 153430d..d3dfddd 100644 --- a/src/language/uk-UA/uk-UA.mod_zitat_service_de.ini +++ b/src/language/uk-UA/uk-UA.mod_zitat_service_de.ini @@ -4,24 +4,7 @@ ; MIT License, Copyright (c) 2008 - 2023 Heiko Lübbe ; https://github.com/muhme/quote_joomla ; -MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = " - -
-
🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦
-

zitat-service.de, Версія 2.0.2

-

Відображає випадковий цитат зі спільноти користувачів www.zitat-service.de/uk.

-

Допомога: github.com/muhme/quote_joomla/wiki/Допомога.

-
" +MOD_ZITAT_SERVICE_DE_XML_DESCRIPTION = "Відображає випадкову цитату зі спільноти користувачів zitat-service.de наступними мовами: 🇩🇪 🇬🇧 🇪🇸 🇯🇵 🇺🇦.
довідку за адресою github.com/muhme/quote_joomla/wiki/Допомога." MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_LABEL = "Вибрати автора" MOD_ZITAT_SERVICE_DE_FIELD_AUTHOR_DESC = "Виберіть автора зі списку (введіть початкові літери прізвища). Виберіть '*', щоб відобразити цитати всіх авторів." MOD_ZITAT_SERVICE_DE_FIELD_CATEGORY_LABEL = "Вибрати категорію" diff --git a/test/README.md b/test/README.md index ed8da0d..749bf62 100644 --- a/test/README.md +++ b/test/README.md @@ -10,13 +10,15 @@ For an overview of the module and its features, please refer to the main [../REA ### NPM Package joomla-cypress -As a base for the Cypress test automation in Joomla 4 and Joomla 5 the npm package [joomla-projects/joomla-cypress](https://github.com/joomla-projects/joomla-cypress/tree/develop) in development branch is used. Currently my fork is used until all the fixes are packed in next version. If you wish to run Cypress on local host machine you have to install the dependencies: +As a base for the Cypress installation in Joomla 4 and Joomla 5 the npm package [joomla-projects/joomla-cypress](https://github.com/joomla-projects/joomla-cypress/tree/develop) in development branch is used. Currently my fork is used until all the fixes are packed in next version. If you wish to run Cypress on local host machine you have to install the dependencies: ``` host$ npm i ``` Joomla 3 is not supported, installation and test is Cypress 'native' implemented and switched via environment variable `JOOMLA_VERSION`. +In the meantime (since the admin login now requires a locale) the package `joomla-cypress` is no longer used in the tests. + ### 1st Preparing with the Installation As preparation for the end-to-end tests you can use automated Joomla and module installation. @@ -58,7 +60,7 @@ host$ scripts/install.sh ### 2nd Testing -There is the end-to-end test suite `test.cy.js` with actual 66 tests for the different four module and three advanced options in the five supported languages. You can run with script e.g. for Joomla 5: +There is the end-to-end test suite `test.cy.js` with actual 76 tests for the backend translation, the different four module and three advanced options in the five supported languages. You can run with script e.g. for Joomla 5: ``` host$ scripts/test.sh 5 ``` diff --git a/test/cypress/e2e/test.cy.ts b/test/cypress/e2e/test.cy.ts index d2cd29a..9dc9fba 100644 --- a/test/cypress/e2e/test.cy.ts +++ b/test/cypress/e2e/test.cy.ts @@ -14,9 +14,64 @@ import * as TestHelpers from "./testHelper"; describe(`Test module zitat-service.de for Joomla ${Cypress.env( "joomla_version" )}`, () => { - const languages = ["de", "en", "es", "ja", "uk"]; - // user 'heikoAdmin' (id 1) has exactly one quote in each language + // https://github.com/muhme/quote_joomla/issues/2 "backend translation of the modules is broken" + describe("Backend I18N translation", () => { + + const description = { + en: "Displays a random quote", + de: "Zeigt ein zufälliges Zitat", + es: "Muestra una cita aleatoria", + ja: "ランダムな引用", + uk: "Відображає випадкову цитату" + } + // five tests for the five locales + TestHelpers.LOCALES.forEach((locale) => { + it(`verify module translation for ${locale} on Module tab`, function () { + TestHelpers.doLogin(locale); + TestHelpers.openModule(); + cy.contains('h2', 'zitat-service.de').should('exist'); + cy.contains(description[locale.substring(0, 2)]).should('be.visible'); + cy.get('body').then($body => { + if ($body.text().includes('MOD_ZITAT_')) { + throw new Error('String "MOD_ZITAT_" found on Module tab'); + } + }); + }); + }); + + const queryMethod = { + en: "Query Method", + de: "Abfragemethode", + es: "Método de Consulta", + ja: "クエリ方法", + uk: "Метод запиту" + } + // five tests for the five locales + TestHelpers.LOCALES.forEach((locale) => { + it(`verify module translation for ${locale} on Advanced tab`, function () { + TestHelpers.doLogin(locale); + TestHelpers.openModule(); + cy.contains('h2', 'zitat-service.de').should('exist'); + if (Cypress.env("joomla_version") === "3") { + // Joomla 3 uses the Bootstrap 2.x framework for its admin UI + cy.contains("li a", /Advanced|Erweitert|Avanzado|高度な設定|Розгорнутий/).click(); + } else { + cy.get( + 'div[role="tablist"] button[aria-controls="attrib-advanced"]' + ).click(); + } + cy.contains(queryMethod[locale.substring(0, 2)]).should('be.visible'); + cy.get('body').then($body => { + if ($body.text().includes('MOD_ZITAT_')) { + throw new Error('String "MOD_ZITAT_" found on Advanced tab'); + } + }); + }); + }); + }); + + // zitat-service user 'heikoAdmin' (id 1) has exactly one quote in each language interface TestData { quotation: string; quotationLink: string; @@ -68,8 +123,8 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }; describe("JavaScript-based and set user and frontend multi-language test", () => { - // choose user 'heikoAdmin' (id 1) as this one has exactly one quote in each language - it("prepare multi-language test with choosing user 'heikoAdmin'", function () { + // choose zitat-service user 'heikoAdmin' (id 1) as this one has exactly one quote in each language + it("prepare multi-language test with choosing zitat-service user 'heikoAdmin'", function () { TestHelpers.setOption({ "#jform_params_user": "1" }); }); @@ -114,8 +169,8 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }); describe("Joomla-based and set user and frontend multi-language test", () => { - // choose user 'heikoAdmin' (id 1) as this one has exactly one quote in each language - it("prepare multi-language test with choosing user 'heikoAdmin' and query method 'from Joomla'", function () { + // choose zitat-service user 'heikoAdmin' (id 1) as this one has exactly one quote in each language + it("prepare multi-language test with choosing zitat-service user 'heikoAdmin' and query method 'from Joomla'", function () { TestHelpers.setOption( { "#jform_params_user": "1" }, { @@ -183,7 +238,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }; // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check ${testData[lang] ? "the presence of quote for author" : "error" } in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); @@ -219,7 +274,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }; // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check ${testData[lang] ? "the presence of quote for category" : "error" } in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); @@ -252,7 +307,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( "Treffen sich zwei Ameisen. Fragt die eine: „Und – was machen Sie so?” Sagt die andere: „Sie meinen beruflich?”"; // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check the presence of quote in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); cy.get("#zitat-service").should("exist"); @@ -276,7 +331,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( "Treffen sich zwei Ameisen. Fragt die eine: „Und – was machen Sie so?” Sagt die andere: „Sie meinen beruflich?”"; // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check the presence of quote in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); cy.get("#zitat-service").should("exist"); @@ -294,7 +349,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }); // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check there is no target in any link for ${lang} in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); cy.get(".quote a").each(($el) => { @@ -311,7 +366,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }); // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check target is set for all links in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); cy.get(".quote a").each(($el) => { @@ -334,7 +389,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }); // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check there is no target in any link in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); cy.get(".quote a").each(($el) => { @@ -358,7 +413,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }); // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check target is set for all links in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); cy.get(".quote a").each(($el) => { @@ -376,7 +431,7 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }); // five tests in the five languages - languages.forEach((lang) => { + TestHelpers.languages().forEach((lang) => { it(`check min-height in ${lang}`, () => { TestHelpers.myVisit(`/index.php/${lang}`); cy.get(".quote a").each(($el) => { @@ -388,21 +443,4 @@ describe(`Test module zitat-service.de for Joomla ${Cypress.env( }); }); }); - - // describe("Backend I18N translation", () => { - // it("prepare reset to all defaults", function () { - // TestHelpers.setOption({}); - // }); - - // // five tests in the five languages - // languages.forEach((lang) => { - // it(`check ${lang}`, () => { - // TestHelpers.myVisit(`/index.php/${lang}`); - // cy.get(".quote a").each(($el) => { - // // for each link found inside a .quote div, check that the target attribute is 'quoteCypressTest' - // cy.wrap($el).should("not.have.attr", "target", "quoteCypressTest"); - // }); - // }); - // }); - // }); }); diff --git a/test/cypress/e2e/testHelper.ts b/test/cypress/e2e/testHelper.ts index 49678d4..c730f2d 100644 --- a/test/cypress/e2e/testHelper.ts +++ b/test/cypress/e2e/testHelper.ts @@ -5,22 +5,33 @@ * * test_helper.js - utility methods used in the tests */ -import "joomla-cypress"; + +export const LOCALES = ["de-DE", "en-GB", "es-ES", "ja-JP", "uk-UA"]; + +/** + * returns languages array from LOCALES array + * e.g. ["de", "en", "es", "ja", "uk"] + */ +function languages() { + return LOCALES.map(locale => locale.substring(0, 2)); +} +export { languages }; /** * Do backend login as admin. */ -function doLogin() { +function doLogin(locale: string) { - if (Cypress.env("joomla_version") === "3") { - // do admin login by own - cy.visit("/administrator/index.php"); - cy.get("#mod-login-username").type(Cypress.env("username")); - cy.get("#mod-login-password").type(Cypress.env("password")); - cy.get("button.btn.btn-primary.btn-block.btn-large.login-button").click(); - } else { - cy.doAdministratorLogin(Cypress.env("username"), Cypress.env("password")); - } + // do admin login by own (and not with joomla-cypress:doAdministratorLogin) to set locale + cy.visit("/administrator/index.php"); + cy.get("#mod-login-username").type(Cypress.env("username")); + cy.get("#mod-login-password").type(Cypress.env("password")); + cy.get('#lang').select(locale, { force: true }); // "force: true" needed for Joomla 3 as element is not visible + cy.contains('button', 'Log in').click(); + + // verify + cy.visit("/administrator"); + cy.get('body').should('have.class', 'admin'); } export { doLogin }; @@ -35,96 +46,95 @@ function openModule() { } export { openModule }; - /** - * Set module options with: - * 1. backend login as admin - * 2. open the module zitat-service.de - * 3. reset all four module options to the default values - * 4. set given module options with #id to value - * 5. reset all three advanced options to the default values - * 6. set given advanced options with #id to value - * 7. save module configuration - */ - function setOption(options, advanced = {}) { - // 1. backend login as admin - doLogin(); - - // 2. open the module zitat-service.de - openModule(); - - // 3. reset all four module options to the default values ('*', respective 'frontend' for language) - cy.get("#jform_params_user") - .invoke("val", "") - .trigger("change", { force: true }); - cy.get("#jform_params_author") - .invoke("val", "") - .trigger("change", { force: true }); - cy.get("#jform_params_category") - .invoke("val", "") - .trigger("change", { force: true }); - cy.get("#jform_params_language").select("", { force: true }); - - // 4. set given module options with #id to value - Object.entries(options).forEach(([id, value]) => { - cy.log(`Set module parameter "${id}" to "${value}"`); - cy.get(id).invoke("val", value).trigger("change", { force: true }); - }); +/** + * Set module options with: + * 1. backend login as admin + * 2. open the module zitat-service.de + * 3. reset all four module options to the default values + * 4. set given module options with #id to value + * 5. reset all three advanced options to the default values + * 6. set given advanced options with #id to value + * 7. save module configuration + */ +function setOption(options, advanced = {}) { + // 1. backend login as admin + doLogin("en-GB"); - // 5. reset all three advanced options to the default values (clear, respective 1 for the radio-button) - if (Cypress.env("joomla_version") === "3") { - // Joomla 3 uses the Bootstrap 2.x framework for its admin UI - cy.contains("li a", "Advanced").click(); - } else { - cy.get( - 'div[role="tablist"] button[aria-controls="attrib-advanced"]' - ).click(); - } - cy.get("#jform_params_target").clear(); + // 2. open the module zitat-service.de + openModule(); + + // 3. reset all four module options to the default values ('*', respective 'frontend' for language) + cy.get("#jform_params_user") + .invoke("val", "") + .trigger("change", { force: true }); + cy.get("#jform_params_author") + .invoke("val", "") + .trigger("change", { force: true }); + cy.get("#jform_params_category") + .invoke("val", "") + .trigger("change", { force: true }); + cy.get("#jform_params_language").select("", { force: true }); + + // 4. set given module options with #id to value + Object.entries(options).forEach(([id, value]) => { + cy.log(`Set module parameter "${id}" to "${value}"`); + cy.get(id).invoke("val", value).trigger("change", { force: true }); + }); + + // 5. reset all three advanced options to the default values (clear, respective 1 for the radio-button) + if (Cypress.env("joomla_version") === "3") { + // Joomla 3 uses the Bootstrap 2.x framework for its admin UI + cy.contains("li a", "Advanced").click(); + } else { cy.get( - 'input[type="radio"][name="jform[params][script]"][value="1"]' - ).check(); - cy.get("#jform_params_height").clear({ force: true }); - - // 6. set given advanced options with #id to value - Object.entries(advanced).forEach(([id, value]) => { - if (value === "check") { - cy.log(`Check advanced parameter "${id}"`); - cy.get(id).check(); - cy.wait(3000); - } else { - cy.log(`Set advanced parameter "${id}" to "${value}"`); - cy.get(id).invoke("val", value).trigger("change", { force: true }); - } - }); - - - // 7. save module configuration - cy.get("button.button-save").contains("Save & Close").click(); - // Check for the success message (Joomla 3 w/o final dot) - cy.contains(".alert-message", /Module saved\.?/, { timeout: 30000 }).should( - "be.visible" - ); - - // ignore backend admin logout - } - export {setOption}; - - /** - * do cy.visit() and check for deprecated notice - * @param string path - */ - function myVisit(path) { - cy.visit(path); - // wait for the body element to be available - cy.get("body").should(($body) => { - // get the text of the body element - const text = $body.text(); - // assert that the 'Deprecated: ' string is not present - expect(text).not.to.include("Deprecated: "); - // assert that the 'Warning: ' string is not present - expect(text).not.to.include("Warning: "); - // assert that the 'Error: ' string is not present - expect(text).not.to.include("Error: "); - }); + 'div[role="tablist"] button[aria-controls="attrib-advanced"]' + ).click(); } - export {myVisit}; + cy.get("#jform_params_target").clear(); + cy.get( + 'input[type="radio"][name="jform[params][script]"][value="1"]' + ).check(); + cy.get("#jform_params_height").clear({ force: true }); + + // 6. set given advanced options with #id to value + Object.entries(advanced).forEach(([id, value]) => { + if (value === "check") { + cy.log(`Check advanced parameter "${id}"`); + cy.get(id).check(); + cy.wait(3000); + } else { + cy.log(`Set advanced parameter "${id}" to "${value}"`); + cy.get(id).invoke("val", value).trigger("change", { force: true }); + } + }); + + // 7. save module configuration + cy.get("button.button-save").contains("Save & Close").click(); + // Check for the success message (Joomla 3 w/o final dot) + cy.contains(".alert-message", /Module saved\.?/, { timeout: 30000 }).should( + "be.visible" + ); + + // ignore backend admin logout +} +export { setOption }; + +/** + * do cy.visit() and check for deprecated notice + * @param string path + */ +function myVisit(path) { + cy.visit(path); + // wait for the body element to be available + cy.get("body").should(($body) => { + // get the text of the body element + const text = $body.text(); + // assert that the 'Deprecated: ' string is not present + expect(text).not.to.include("Deprecated: "); + // assert that the 'Warning: ' string is not present + expect(text).not.to.include("Warning: "); + // assert that the 'Error: ' string is not present + expect(text).not.to.include("Error: "); + }); +} +export { myVisit }; diff --git a/test/cypress/joomla-cypress.d.ts b/test/cypress/joomla-cypress.d.ts deleted file mode 100644 index 65e9d0b..0000000 --- a/test/cypress/joomla-cypress.d.ts +++ /dev/null @@ -1,13 +0,0 @@ - -/* - * MIT License, Copyright (c) 2023 Heiko Lübbe - * https://github.com/muhme/quote_wordpress - * - * joomla-cypress.d.ts - declare used methods - */ -declare namespace Cypress { - interface Chainable { - // only this that I use in testHelper.ts - doAdministratorLogin(username: string, password: string): Chainable; - } -} diff --git a/test/cypress/tsconfig.json b/test/cypress/tsconfig.json index c1cf8e6..587ebd8 100644 --- a/test/cypress/tsconfig.json +++ b/test/cypress/tsconfig.json @@ -4,5 +4,5 @@ "lib": ["es5", "dom"], "types": ["cypress", "node"] }, - "include": ["**/*.ts", "e2e/install.cy.js", "joomla-cypress.d.ts"] + "include": ["**/*.ts", "e2e/install.cy.js"] }