Skip to content

Commit

Permalink
update program state test
Browse files Browse the repository at this point in the history
  • Loading branch information
NethmiRodrigo committed Dec 19, 2024
1 parent ef8539f commit d76aad3
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ const programs: Array<Program> = [

describe('ProgramStateTypeQuestion', () => {
it('renders without crashing', async () => {
mockUsePrograms.mockReturnValue({ programs: [], programsLookupError: null, isLoadingPrograms: false });
mockUsePrograms.mockReturnValue({ programs: programs, programsLookupError: null, isLoadingPrograms: false });
mockUseProgramWorkflowStates.mockReturnValue({
programStates: [],
programStatesLookupError: null,
@@ -158,6 +158,16 @@ describe('ProgramStateTypeQuestion', () => {
});
await user.click(programOneSelectOption);
expect(screen.getByRole('combobox', { name: /^program$/i })).toHaveDisplayValue(/program 1/i);
expect(
screen.queryByRole('option', {
name: /program 1/i,
}),
).not.toBeInTheDocument();
expect(
screen.queryByRole('option', {
name: /program 2/i,
}),
).not.toBeInTheDocument();

const programWorkflowInput = screen.getByRole('combobox', {
name: /program workflow/i,
@@ -175,7 +185,19 @@ describe('ProgramStateTypeQuestion', () => {

const programWorkflowSelectionOption = screen.getByRole('option', { name: /program 1 workflow 1/i });
await user.click(programWorkflowSelectionOption);
screen.logTestingPlaygroundURL();
expect(screen.getByRole('combobox', { name: /^program workflow$/i })).toHaveDisplayValue(/program 1 workflow 1/i);
expect(screen.queryByRole('option', { name: /program 1 workflow 1/i })).not.toBeInTheDocument();
expect(screen.queryByRole('option', { name: /program 1 workflow 2/i })).not.toBeInTheDocument();
expect(screen.getByText(/program state/i)).toBeInTheDocument();

const programStateMenu = screen.getByRole('combobox', {
name: /program state/i,
});
expect(programStateMenu).toBeInTheDocument();
await user.click(programStateMenu);

expect(screen.getByRole('option', { name: /program 1 state 1/i })).toBeInTheDocument();
expect(screen.getByRole('option', { name: /program 1 state 2/i })).toBeInTheDocument();
});

it('renders the selected program, workflow and state in edit mode', async () => {
11 changes: 11 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"addInlineDate": "Add inline date",
"addObsCommentTextBox": "Add obs comment text box",
"addObsGroupQuestion": "Add a grouped question",
"addPage": "Add Page",
"addProgram": "Add program",
@@ -15,6 +17,7 @@
"checkFilters": "Check the filters above",
"chooseEncounterType": "Choose an encounter type to link your form to",
"choosePatientIdentifierType": "Choose a patient identifier type",
"choosePersonAttributeType": "Choose a person attribute type",
"chooseQuestionType": "Choose a question type",
"chooseRenderingType": "Choose a rendering type",
"close": "Close",
@@ -61,6 +64,7 @@
"errorCopy": "Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.",
"errorCreatingForm": "Error creating form",
"errorCreatingPage": "Error creating page",
"errorCreatingQuestion": "Error creating question",
"errorCreatingSection": "Error creating section",
"errorDeletingForm": "Error deleting form",
"errorDeletingPage": "Error deleting page",
@@ -70,6 +74,7 @@
"errorFetchingConceptName": "Couldn't resolve concept name",
"errorFetchingConcepts": "Error fetching concepts",
"errorFetchingPatientIdentifierTypes": "Error fetching patient identifier types",
"errorFetchingPersonAttributeTypes": "Error fetching person attribute types",
"errorFetchingPrograms": "Error fetching programs",
"errorFetchingProgramState": "Error fetching program state",
"errorOnLine": "Error on line",
@@ -81,6 +86,7 @@
"errorSavingQuestion": "Error saving question",
"errorUnpublishingForm": "Error unpublishing form",
"errorUpdatingForm": "Error updating form",
"errorUpdatingQuestion": "Error updating question",
"expandSectionExplainer": "Below are the sections linked to this page. Expand each section to add questions to it.",
"filterBy": "Filter by",
"formBuilder": "Form Builder",
@@ -138,6 +144,7 @@
"pageExplainer": "Pages typically have one or more sections. Click the button below to add a section to your page.",
"pageRenamed": "Page renamed",
"patientIdentifierTypeHelperText": "Patient identifier type fields must be linked to a patient identifier type",
"personAttributeTypeHelperText": "Person attribute type fields must be linked to a person attribute type",
"pleaseTryAgain": "Please try again.",
"preview": "Preview",
"problemLoadingPreview": "There was a problem loading the schema preview",
@@ -153,6 +160,8 @@
"questionDeleted": "Question deleted",
"questionDeletedMessage": "The question labelled \"{{- questionLabel}}\" has been deleted.",
"questionDuplicated": "Question duplicated. Please change the duplicated question's ID to a unique, camelcased value",
"questionEdited": "Question edited",
"questionEditedMessage": "The question labelled \"{{- questionLabel}}\" has been edited.",
"questionId": "Question ID (prefer using camel-case for IDs). Each field should have a unique ID.",
"questionIdExists": "This question ID already exists in your schema",
"questionIdPlaceholder": "Enter a unique ID e.g. \"anaesthesiaType\" for a question asking about the type of anaesthesia.",
@@ -192,6 +201,7 @@
"searchForAnswerConcept": "Search for a concept to add as an answer",
"searchForBackingConcept": "Search for a backing concept",
"searchForBackingPatientIdentifierType": "Search for a backing patient identifier type",
"searchForBackingPersonAttributeType": "Search for a backing person attribute type",
"searching": "Searching",
"searchInOCL": "Search in OCL",
"searchThisList": "Search this list",
@@ -220,6 +230,7 @@
"validationErrors_one": "Validation found {{count}} errors",
"validationErrors_other": "Validation found {{count}} errors",
"ValidationSuccessful": "Validation Successful",
"validFieldTypeRequired": "A valid field type value is required",
"validRenderingTypeRequired": "A valid rendering type value is required",
"version": "Version",
"viewErrors": "View the errors in the interactive builder",

0 comments on commit d76aad3

Please sign in to comment.