From 9c930b7b411f5e88f2f890639159e09bdadb78dc Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 30 Jun 2021 11:31:18 -0400 Subject: [PATCH] updated isPseudoLocalized() to correctly process multiple elements --- .../dashboard-card/DashboardCardTitle.tsx | 7 ++++++- .../integration-tests-cypress/support/i18n.ts | 8 ++++++-- .../tests/i18n/pseudolocalization.spec.ts | 15 +++++++++++++-- .../integration-tests-cypress/views/list-page.ts | 2 +- frontend/public/components/filter-toolbar.tsx | 1 + frontend/public/components/masthead-toolbar.jsx | 2 +- frontend/public/locales/en/public.json | 2 ++ frontend/public/module/k8s/cluster-settings.ts | 5 +++-- 8 files changed, 33 insertions(+), 9 deletions(-) diff --git a/frontend/packages/console-shared/src/components/dashboard/dashboard-card/DashboardCardTitle.tsx b/frontend/packages/console-shared/src/components/dashboard/dashboard-card/DashboardCardTitle.tsx index 742577294cb..1ddc1600ec2 100644 --- a/frontend/packages/console-shared/src/components/dashboard/dashboard-card/DashboardCardTitle.tsx +++ b/frontend/packages/console-shared/src/components/dashboard/dashboard-card/DashboardCardTitle.tsx @@ -3,7 +3,12 @@ import classNames from 'classnames'; const DashboardCardTitle: React.FC = React.memo( ({ className, children }) => ( -

{children}

+

+ {children} +

), ); diff --git a/frontend/packages/integration-tests-cypress/support/i18n.ts b/frontend/packages/integration-tests-cypress/support/i18n.ts index 7d984f9d23c..b5c41bad91c 100644 --- a/frontend/packages/integration-tests-cypress/support/i18n.ts +++ b/frontend/packages/integration-tests-cypress/support/i18n.ts @@ -48,7 +48,11 @@ Cypress.Commands.add( prevSubject: true, }, (subject) => { - const text = subject.text(); - expect(text).to.match(/\[[^a-zA-Z]+\]/); + cy.wrap(subject).each(($el) => { + const text = $el.text(); + if (text.length > 0) { + expect(text).to.match(/\[[^a-zA-Z]+\]/); + } + }); }, ); diff --git a/frontend/packages/integration-tests-cypress/tests/i18n/pseudolocalization.spec.ts b/frontend/packages/integration-tests-cypress/tests/i18n/pseudolocalization.spec.ts index a69bb7a3c53..2179f4d3d10 100644 --- a/frontend/packages/integration-tests-cypress/tests/i18n/pseudolocalization.spec.ts +++ b/frontend/packages/integration-tests-cypress/tests/i18n/pseudolocalization.spec.ts @@ -20,7 +20,15 @@ describe('Localization', () => { cy.log('test masthead'); cy.visit('/dashboards?pseudolocalization=true&lng=en'); masthead.clickMastheadLink('help-dropdown-toggle'); - cy.byTestID('application-launcher-item').isPseudoLocalized(); + // wait for both console help menu items and additionalHelpActions items to load + // additionalHelpActions come from ConsoleLinks 'HelpMenu' yaml and are not translated + cy.get('.pf-c-app-launcher__group').should('have.length', 2); + // only test console help items which are translated + cy.get('.pf-c-app-launcher__group') + .first() + .within(() => { + cy.get('[role="menuitem"]').isPseudoLocalized(); + }); }); it('pseudolocalizes navigation', () => { @@ -42,7 +50,10 @@ describe('Localization', () => { it('pseudolocalizes utilization card', () => { cy.log('test utilization card components'); cy.visit('/dashboards?pseudolocalization=true&lng=en'); - cy.byTestID('utilization-card-item-text').isPseudoLocalized(); + cy.byLegacyTestID('utilization-card').within(() => { + cy.byTestID('dashboard-card-title').isPseudoLocalized(); + cy.byTestID('utilization-card-item-text').isPseudoLocalized(); + }); }); it('pseudolocalizes monitoring pages', () => { diff --git a/frontend/packages/integration-tests-cypress/views/list-page.ts b/frontend/packages/integration-tests-cypress/views/list-page.ts index 215dfc9716f..35945a8c80b 100644 --- a/frontend/packages/integration-tests-cypress/views/list-page.ts +++ b/frontend/packages/integration-tests-cypress/views/list-page.ts @@ -25,7 +25,7 @@ export const listPage = { }, filter: { byName: (name: string) => { - cy.byLegacyTestID('item-filter').type(name); + cy.byTestID('name-filter-input').type(name); }, numberOfActiveFiltersShouldBe: (numFilters: number) => { cy.get("[class='pf-c-toolbar__item pf-m-chip-group']").should('have.length', numFilters); diff --git a/frontend/public/components/filter-toolbar.tsx b/frontend/public/components/filter-toolbar.tsx index b9bac112a44..d66fe807222 100644 --- a/frontend/public/components/filter-toolbar.tsx +++ b/frontend/public/components/filter-toolbar.tsx @@ -362,6 +362,7 @@ const FilterToolbar_: React.FC = (prop /> ) : ( { setNameInputText(value); diff --git a/frontend/public/components/masthead-toolbar.jsx b/frontend/public/components/masthead-toolbar.jsx index 7065c5630ac..8be891372bf 100644 --- a/frontend/public/components/masthead-toolbar.jsx +++ b/frontend/public/components/masthead-toolbar.jsx @@ -308,7 +308,7 @@ class MastheadToolbarContents_ extends React.Component { _helpActions(additionalHelpActions) { const { flags, cv, t, fireTelemetryEvent } = this.props; const helpActions = []; - const reportBugLink = cv && cv.data ? getReportBugLink(cv.data) : null; + const reportBugLink = cv && cv.data ? getReportBugLink(cv.data, t) : null; helpActions.push({ name: '', diff --git a/frontend/public/locales/en/public.json b/frontend/public/locales/en/public.json index 50537ca7981..1ba2cbe013f 100644 --- a/frontend/public/locales/en/public.json +++ b/frontend/public/locales/en/public.json @@ -1668,6 +1668,8 @@ "VolumeSnapshotContents": "VolumeSnapshotContents", "ConsolePlugin": "ConsolePlugin", "ConsolePlugins": "ConsolePlugins", + "Open Support Case with Red Hat": "Open Support Case with Red Hat", + "Report Bug to Red Hat": "Report Bug to Red Hat", "Loading {{title}} status": "Loading {{title}} status", "Unsupported": "Unsupported", "Disable": "Disable", diff --git a/frontend/public/module/k8s/cluster-settings.ts b/frontend/public/module/k8s/cluster-settings.ts index 448554e4b61..3dc45a010de 100644 --- a/frontend/public/module/k8s/cluster-settings.ts +++ b/frontend/public/module/k8s/cluster-settings.ts @@ -1,5 +1,6 @@ import * as _ from 'lodash-es'; import * as semver from 'semver'; +import i18next from 'i18next'; import { ClusterVersionModel } from '../../models'; import { referenceForModel } from './k8s'; @@ -209,11 +210,11 @@ Browser: ${window.navigator.userAgent} `); return _.isEmpty(prerelease) ? { - label: 'Open Support Case with Red Hat', + label: i18next.t('public~Open Support Case with Red Hat'), href: `https://access.redhat.com/support/cases/#/case/new?product=OpenShift%20Container%20Platform&version=${major}.${minor}&clusterId=${cv.spec.clusterID}`, } : { - label: 'Report Bug to Red Hat', + label: i18next.t('public~Report Bug to Red Hat'), href: `https://bugzilla.redhat.com/enter_bug.cgi?product=OpenShift%20Container%20Platform&version=${bugzillaVersion}&cf_environment=${environment}`, }; };