Skip to content

Commit

Permalink
(chore) Extract translations from extension, hook and workspace files (
Browse files Browse the repository at this point in the history
…#2146)

* Widen the scope of the translation extraction

* Bump framework

* Tweak results viewer e2e test

---------

Co-authored-by: Dennis Kigen <[email protected]>
  • Loading branch information
vasharma05 and denniskigen authored Dec 13, 2024
1 parent edc522b commit e4ab50e
Show file tree
Hide file tree
Showing 24 changed files with 190 additions and 174 deletions.
21 changes: 14 additions & 7 deletions e2e/specs/results-viewer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable playwright/no-nested-step */
import { expect } from '@playwright/test';
import { type Visit } from '@openmrs/esm-framework';
import { generateRandomPatient, type Patient, startVisit, endVisit, deletePatient } from '../commands';
import { test } from '../core';
import { ResultsViewerPage, VisitsPage } from '../pages';
import { ChartPage, ResultsViewerPage, VisitsPage } from '../pages';

let patient: Patient;
let visit: Visit;
Expand All @@ -13,6 +14,7 @@ test.beforeEach(async ({ api }) => {
});

test('Record and edit test results', async ({ page }) => {
const chartPage = new ChartPage(page);
const resultsViewerPage = new ResultsViewerPage(page);
const visitsPage = new VisitsPage(page);
const form = page.locator('[data-extension-slot-name="form-widget-slot"]');
Expand Down Expand Up @@ -209,12 +211,12 @@ test('Record and edit test results', async ({ page }) => {
},
];

await test.step('When I visit the results viewer page', async () => {
await resultsViewerPage.goTo(patient.uuid);
await test.step('When I visit the chart summary page', async () => {
await chartPage.goTo(patient.uuid);
});

await test.step('And I click on the `Clinical forms` button on the siderail', async () => {
await page.getByLabel(/clinical forms/i).click();
await test.step('And I click the `Clinical forms` button on the siderail', async () => {
await page.getByLabel(/clinical forms/i, { exact: true }).click();
});

await test.step('Then I should see the clinical forms workspace', async () => {
Expand All @@ -226,11 +228,15 @@ test('Record and edit test results', async ({ page }) => {
await expect(page.getByRole('cell', { name: /laboratory test results/i })).toBeVisible();
});

await test.step('When I launch the `Laboratory Test Results` form', async () => {
await test.step('When I click the `Laboratory Test Results` link to launch the form', async () => {
await page.getByText(/laboratory test results/i).click();
});

await test.step('And I fill the "Complete Blood Count" section', async () => {
await test.step('Then I should see the `Laboratory Test Results` form launch in the workspace', async () => {
await expect(page.getByText(/laboratory test results/i)).toBeVisible();
});

await test.step('When I fill the "Complete Blood Count" section', async () => {
for (const { label, value } of completeBloodCountData) {
await test.step(label, async () => {
await form.getByLabel(label, { exact: true }).fill(value);
Expand Down Expand Up @@ -276,6 +282,7 @@ test('Record and edit test results', async ({ page }) => {
});
}
});

for (const { resultsPageReference, value } of chemistryResultsData) {
await test.step(resultsPageReference, async () => {
const row = page.locator(`tr:has-text("${resultsPageReference}"):has(td:has-text("${value}"))`).first();
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-form-engine-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -43,7 +43,7 @@
"react-error-boundary": "^4.0.13"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-form-entry-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"zone.js": "~0.14.8"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"single-spa": "6.x"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-generic-patient-widgets-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -43,7 +43,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-allergies-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -41,7 +41,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-attachments-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -44,7 +44,7 @@
"react-html5-camera-photo": "^1.5.11"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "^18.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-banner-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -42,7 +42,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
4 changes: 4 additions & 0 deletions packages/esm-patient-banner-app/translations/en.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"activeVisit": "Active Visit",
"address1": "Address line 1",
"address2": "Address line 2",
"city": "City",
"cityVillage": "city",
"country": "Country",
"countyDistrict": "District",
"deceased": "Deceased",
"district": "District",
"from_lower": "from",
"implementationLogo": "Implementation logo",
"patientAge": "Age:",
"patientDateOfBirthWithSeparator": "Date of birth:",
Expand All @@ -14,6 +17,7 @@
"patientNameWithSeparator": "Patient name:",
"postalCode": "Postal code",
"printIdentifierSticker": "Print identifier sticker",
"started": "Started",
"state": "State",
"stateProvince": "State",
"telephoneNumberWithSeparator": "Telephone number:"
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-chart-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -42,7 +42,7 @@
},
"peerDependencies": {
"@carbon/react": "1.x",
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "*",
"dayjs": "1.x",
"lodash-es": "4.x",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function makePath(target: DashboardConfig, params: Record<string, string> = {})
return parts.join('/');
}

function getDashboardDefinition(meta: object, config: ConfigObject) {
return { ...meta, ...config };
function getDashboardDefinition(meta: object, config: ConfigObject, moduleName: string) {
return { ...meta, ...config, moduleName };
}

interface ChartReviewProps {
Expand All @@ -35,11 +35,13 @@ const ChartReview: React.FC<ChartReviewProps> = ({ patientUuid, patient, view, s
const { navGroups } = useNavGroups();

const ungroupedDashboards = extensionStore.slots['patient-chart-dashboard-slot'].assignedExtensions.map((e) =>
getDashboardDefinition(e.meta, e.config),
getDashboardDefinition(e.meta, e.config, e.moduleName),
);
const groupedDashboards = navGroups
.map((slotName) =>
extensionStore.slots[slotName].assignedExtensions.map((e) => getDashboardDefinition(e.meta, e.config)),
extensionStore.slots[slotName].assignedExtensions.map((e) =>
getDashboardDefinition(e.meta, e.config, e.moduleName),
),
)
.flat();
const dashboards = ungroupedDashboards.concat(groupedDashboards) as Array<DashboardConfig>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useEffect, useMemo, useState } from 'react';
import classNames from 'classnames';
import { useMatch } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Extension, ExtensionSlot, useExtensionSlotMeta } from '@openmrs/esm-framework';
import { launchPatientWorkspace, launchStartVisitPrompt } from '@openmrs/esm-patient-common-lib';
import { dashboardPath } from '../../constants';
import styles from './dashboard-view.scss';
import { launchPatientWorkspace, launchStartVisitPrompt } from '@openmrs/esm-patient-common-lib';
import classNames from 'classnames';

/**
* The layout mode dictates the width occuppied by the chart dashboard widgets.
Expand All @@ -21,6 +22,7 @@ export interface DashboardConfig {
path: string;
hideDashboardTitle?: boolean;
layoutMode?: LayoutMode;
moduleName: string;
}

interface DashboardViewProps {
Expand All @@ -31,6 +33,7 @@ interface DashboardViewProps {

export function DashboardView({ dashboard, patientUuid, patient }: DashboardViewProps) {
const widgetMetas = useExtensionSlotMeta(dashboard.slot);
const { t } = useTranslation(dashboard.moduleName);
const {
params: { view },
} = useMatch(dashboardPath);
Expand Down Expand Up @@ -61,7 +64,7 @@ export function DashboardView({ dashboard, patientUuid, patient }: DashboardView
return (
<>
<ExtensionSlot state={state} name="top-of-all-patient-dashboards-slot" />
{!dashboard.hideDashboardTitle && resolvedTitle && <h1 className={styles.dashboardTitle}>{resolvedTitle}</h1>}
{!dashboard.hideDashboardTitle && resolvedTitle && <h1 className={styles.dashboardTitle}>{t(resolvedTitle)}</h1>}
<div className={styles.dashboardContainer}>
<ExtensionSlot key={dashboard.slot} name={dashboard.slot} className={styles.dashboard}>
{(extension) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-common-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"uuid": "^8.3.2"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"react": "18.x",
"single-spa": "6.x"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-conditions-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -42,7 +42,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-flags-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color",
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -40,7 +40,7 @@
"@carbon/react": "^1.33.1"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-forms-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -43,7 +43,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-immunizations-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -44,7 +44,7 @@
"zod": "^3.22.2"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-lists-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests --color",
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -40,7 +40,7 @@
"@carbon/react": "^1.33.1"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
4 changes: 2 additions & 2 deletions packages/esm-patient-medications-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.modal.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/**/*.hook.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand All @@ -42,7 +42,7 @@
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"@openmrs/esm-framework": "5.x",
"@openmrs/esm-framework": "6.x",
"@openmrs/esm-patient-common-lib": "8.x",
"dayjs": "1.x",
"react": "18.x",
Expand Down
Loading

0 comments on commit e4ab50e

Please sign in to comment.