-
Notifications
You must be signed in to change notification settings - Fork 112
(test) O3-4968: Adding e2e tests for TranslationBuilder component #833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Bharath-K-Shetty
wants to merge
30
commits into
openmrs:main
Choose a base branch
from
Bharath-K-Shetty:test/O3-4968
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+232
−18
Open
Changes from 10 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ef2959e
Workflow 1: Basic Translation Builder Display
Bharath-K-Shetty f6514ea
Workflow 2: Language Selection and Switching
Bharath-K-Shetty 3be06ac
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty 2bec8c3
Added remaining e2e tests to Translation Builder
Bharath-K-Shetty ed1dfe7
Merge branch 'main' of https://github.com/Bharath-K-Shetty/openmrs-es…
Bharath-K-Shetty 90abacd
Merge branch 'test/O3-4968' of https://github.com/Bharath-K-Shetty/op…
Bharath-K-Shetty 977c97f
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty f93ebdc
Merge branch 'main' of https://github.com/Bharath-K-Shetty/openmrs-es…
Bharath-K-Shetty 95d0bd9
Refined the e2e test workflows
Bharath-K-Shetty fae2941
Merge branch 'test/O3-4968' of https://github.com/Bharath-K-Shetty/op…
Bharath-K-Shetty dee15b2
Updated the step names
Bharath-K-Shetty 4b007ba
Added workflow for upload and download translation file
Bharath-K-Shetty 833dfdc
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty 7090561
Made all the tests pass
Bharath-K-Shetty 49fe191
Merge branch 'test/O3-4968' of https://github.com/Bharath-K-Shetty/op…
Bharath-K-Shetty 2581cb8
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty 9f73bc6
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty 5bf32e7
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty 03cf72e
Merge branch 'main' of https://github.com/Bharath-K-Shetty/openmrs-es…
Bharath-K-Shetty e9871f9
Merge branch 'main' into test/O3-4968
NethmiRodrigo 4d2d42e
remove eslint-disable and update to use formBuilderPage.page queries
Bharath-K-Shetty cd025b2
Merge branch 'main' of https://github.com/Bharath-K-Shetty/openmrs-es…
Bharath-K-Shetty 04820c4
Merge branch 'test/O3-4968' of https://github.com/Bharath-K-Shetty/op…
Bharath-K-Shetty 76adcd2
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty 78a81e4
Merge branch 'main' into test/O3-4968
Bharath-K-Shetty 6891076
Merge branch 'main' of https://github.com/Bharath-K-Shetty/openmrs-es…
Bharath-K-Shetty 96485a8
Refined the step names of the workflows
Bharath-K-Shetty 8eec6a6
Merge branch 'test/O3-4968' of https://github.com/Bharath-K-Shetty/op…
Bharath-K-Shetty fbbed14
Merge branch 'main' of https://github.com/Bharath-K-Shetty/openmrs-es…
Bharath-K-Shetty b1af41d
Update the step names of the upload translation workflow
Bharath-K-Shetty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* eslint-disable testing-library/prefer-screen-queries */ | ||
|
|
||
| import { test } from '../core'; | ||
| import { expect } from '@playwright/test'; | ||
| import { deleteForm, createForm, createValueReference, addFormResources } from '../commands/form-operations'; | ||
| import { FormBuilderPage } from '../pages'; | ||
|
|
||
| let formUuid = ''; | ||
|
|
||
| const formDetails = { | ||
| name: 'Covid-19 Screening', | ||
| description: 'A test form for recording COVID-19 screening information', | ||
| version: '1.0', | ||
| published: true, | ||
| }; | ||
Bharath-K-Shetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test.describe('Translation Builder Workflows', () => { | ||
Bharath-K-Shetty marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| test.beforeEach(async ({ api }) => { | ||
| const form = await createForm(api, false, formDetails); | ||
| formUuid = form.uuid; | ||
|
|
||
| const valueReference = await createValueReference(api); | ||
| await addFormResources(api, valueReference, formUuid); | ||
| }); | ||
Bharath-K-Shetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test('Manage translations: switch languages, filter, and search', async ({ page }) => { | ||
| const formBuilderPage = new FormBuilderPage(page); | ||
|
|
||
| await test.step('Open a form in the translation builder', async () => { | ||
Bharath-K-Shetty marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await formBuilderPage.gotoFormBuilder(); | ||
| await formBuilderPage.searchForForm(formDetails.name); | ||
| await formBuilderPage.page.getByRole('row', { name: formDetails.name }).getByLabel('Edit Schema').first().click(); | ||
| await formBuilderPage.translationBuilderTab().click(); | ||
| }); | ||
|
|
||
Bharath-K-Shetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await test.step('Switch between languages', async () => { | ||
| await formBuilderPage.languageDropdown().click(); | ||
| const dropdownMenu = formBuilderPage.translationBuilderPanel().locator('.cds--list-box__menu'); | ||
| await expect(dropdownMenu).toBeVisible(); | ||
| await expect(dropdownMenu.getByRole('option', { name: 'English (en)' })).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Filter translations using tabs', async () => { | ||
| await formBuilderPage.allTranslationsTab().click(); | ||
| await expect(formBuilderPage.allTranslationsTab()).toHaveAttribute('aria-selected', 'true'); | ||
|
|
||
| await formBuilderPage.translatedTab().click(); | ||
| await expect(page.locator('[data-status="translated"]')).toHaveCount(0); | ||
|
|
||
| await formBuilderPage.untranslatedTab().click(); | ||
| await expect(formBuilderPage.untranslatedTab()).toHaveAttribute('aria-selected', 'true'); | ||
| await expect(page.locator('[data-status="untranslated"]').first()).toBeVisible(); | ||
| }); | ||
|
|
||
| await test.step('Search for a translation string', async () => { | ||
| const searchInput = formBuilderPage.translationSearchInput(); | ||
| await searchInput.fill('Visit Details'); | ||
| await expect(searchInput).toHaveValue('Visit Details'); | ||
Bharath-K-Shetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const results = page.locator('[data-testid="translation-entry"]'); | ||
| await expect(results).not.toHaveCount(0); | ||
| await expect(results.first()).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test('Edit and update an individual translation', async ({ page }) => { | ||
| const formBuilderPage = new FormBuilderPage(page); | ||
|
|
||
| await test.step('When I open a form in the translation builder', async () => { | ||
| await formBuilderPage.gotoFormBuilder(); | ||
| await formBuilderPage.searchForForm(formDetails.name); | ||
| await formBuilderPage.page.getByRole('row', { name: formDetails.name }).getByLabel('Edit Schema').first().click(); | ||
| await formBuilderPage.translationBuilderTab().click(); | ||
| }); | ||
|
|
||
Bharath-K-Shetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await test.step('Edit a translation string and save it', async () => { | ||
Bharath-K-Shetty marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| await formBuilderPage.editTranslationButton(0).click(); | ||
| const translationInput = formBuilderPage.translationValueInput(); | ||
| await translationInput.fill('Test Translation Updated'); | ||
| await formBuilderPage.saveTranslationButton().click(); | ||
| await expect(formBuilderPage.translationModal()).toBeHidden(); | ||
| await expect(formBuilderPage.editTranslationButton(0)).toBeEnabled(); | ||
| }); | ||
Bharath-K-Shetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
Bharath-K-Shetty marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test.afterEach(async ({ api }) => { | ||
| if (formUuid) { | ||
| await deleteForm(api, formUuid); | ||
| } | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ const EditTranslationModal: React.FC<EditTranslationModalProps> = ({ onClose, or | |
| labelText={t('translationValue', 'Translated Value')} | ||
| value={newValue} | ||
| onChange={(e) => setNewValue(e.target.value)} | ||
| data-testid="translation-value-input" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: Is the data test id necessary? Can't we target the button from the label text? |
||
| /> | ||
| </ModalBody> | ||
| <ModalFooter> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -287,16 +287,26 @@ const TranslationBuilder: React.FC<TranslationBuilderProps> = ({ formSchema, onU | |
| <div className={styles.translationEditor}> | ||
| {filteredTranslations.length > 0 ? ( | ||
| filteredTranslations.map(([key, value]) => ( | ||
| <div key={key} className={styles.translationRow}> | ||
| <div className={styles.translationKey}>{key}</div> | ||
| <div className={styles.translatedKey}>{value}</div> | ||
| <div | ||
| key={key} | ||
| className={styles.translationRow} | ||
| data-testid="translation-entry" | ||
| data-status="untranslated" | ||
| > | ||
| <div className={styles.translationKey} data-testid="translation-key"> | ||
| {key} | ||
| </div> | ||
| <div className={styles.translatedKey} data-testid="translation-value"> | ||
| {value} | ||
| </div> | ||
| <div className={styles.inlineControls}> | ||
| <IconButton | ||
| kind="ghost" | ||
| label={t('editString', 'Edit string')} | ||
| onClick={() => handleEditClick(key)} | ||
| size="md" | ||
| className={styles.deleteButton} | ||
| data-testid="edit-translation-button" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here about the label |
||
| > | ||
| <Edit /> | ||
| </IconButton> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.