From be1365c9fed7ee74c758aa7ed0c943713a11b01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=CC=8Cimon=20Macek?= Date: Thu, 19 Sep 2024 18:02:06 +0200 Subject: [PATCH] update command (to account for breaking change) --- src/components/__tests__/CountdownEvent.cy.js | 27 ++--------- src/components/__tests__/DrawerHeader.cy.js | 46 ++++++------------- src/i18n/en.toml | 2 +- test/cypress/support/commands.js | 13 ++++-- 4 files changed, 31 insertions(+), 57 deletions(-) diff --git a/src/components/__tests__/CountdownEvent.cy.js b/src/components/__tests__/CountdownEvent.cy.js index 67160c4b6..044f26304 100755 --- a/src/components/__tests__/CountdownEvent.cy.js +++ b/src/components/__tests__/CountdownEvent.cy.js @@ -23,28 +23,11 @@ describe('', () => { }); it('has translation for all strings', () => { - const translationKeyList = [ - 'index.countdown.title', - 'index.countdown.days', - 'index.countdown.hours', - 'index.countdown.minutes', - 'index.countdown.seconds', - ]; - - translationKeyList.forEach((translationKey) => { - const defaultEnglishString = i18n.global.t(translationKey, 'en'); - - const locales = i18n.global.availableLocales; - locales - .filter((locale) => locale !== 'en') - .forEach((locale) => { - i18n.global.locale = locale; - const translatedString = i18n.global.t(translationKey); - cy.wrap(translatedString) - .should('be.a', 'string') - .and('not.equal', defaultEnglishString); - }); - }); + cy.testLanguageStringsInContext( + ['title', 'days', 'hours', 'minutes', 'seconds'], + 'index.countdown', + i18n, + ); }); it('displays internationalized labels', () => { diff --git a/src/components/__tests__/DrawerHeader.cy.js b/src/components/__tests__/DrawerHeader.cy.js index 87320c9e7..b62a65cca 100644 --- a/src/components/__tests__/DrawerHeader.cy.js +++ b/src/components/__tests__/DrawerHeader.cy.js @@ -23,38 +23,22 @@ describe('', () => { }); it('has translation for all strings', () => { - const translationStrings = [ - 'titleStateDefault', - 'titleStateContact', - 'titleParticipants', - 'titleCoordinators', - 'titleGuide', - 'buttonGuide', - 'titleContact', - 'buttonContact', - 'titleLinks', - 'titleSocials', - ]; - - const translationKeyList = translationStrings.map( - (item) => `index.help.${item}`, + cy.testLanguageStringsInContext( + [ + 'titleStateDefault', + 'titleStateContact', + 'titleParticipants', + 'titleCoordinators', + 'titleGuide', + 'buttonGuide', + 'titleContact', + 'buttonContact', + 'titleLinks', + 'titleSocials', + ], + 'index.help', + i18n, ); - - translationKeyList.forEach((translationKey) => { - const defaultEnglishString = i18n.global.t(translationKey, 'en'); - - const locales = i18n.global.availableLocales; - locales - .filter((locale) => locale !== 'en') - .forEach((locale) => { - i18n.global.locale = locale; - const translatedString = i18n.global.t(translationKey); - - cy.wrap(translatedString) - .should('be.a', 'string') - .and('not.equal', defaultEnglishString); - }); - }); }); it('renders logo', () => { diff --git a/src/i18n/en.toml b/src/i18n/en.toml index 2896821de..5dd632bbd 100755 --- a/src/i18n/en.toml +++ b/src/i18n/en.toml @@ -154,7 +154,7 @@ labelCompanyShort = "Company" labelConfirmBillingDetails = "I confirm that the billing information above is correct" labelCoordinatorResponsibility = "I will arrange for the company to pay all or part of the entry fee for our employee team(s)." labelDonorEntryFee = "My organisation would like to support AutoMat and pay a charity entry fee of 500 CZK excluding VAT per person" -labelEmail = "E-mail" +labelEmail = "Email" labelFirstName = "First Name" labelGender = "Gender" labelHouseNumber = "House number" diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 65f5a3675..81f7a1af0 100644 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -51,14 +51,21 @@ Cypress.Commands.add( ); translationKeyList.forEach((translationKey) => { - const defaultEnglishString = i18n.global.t(translationKey, 'en'); + const defaultEnglishString = i18n.global.t( + translationKey, + {}, + { locale: 'en' }, + ); const locales = i18n.global.availableLocales; locales .filter((locale) => locale !== 'en') .forEach((locale) => { - i18n.global.locale = locale; - const translatedString = i18n.global.t(translationKey); + const translatedString = i18n.global.t( + translationKey, + {}, + { locale: locale }, + ); cy.wrap(translatedString) .should('be.a', 'string')