Skip to content
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

(feat) O3-3230: add rule builder to form builder #279

Open
wants to merge 138 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
94dda56
Optimize useCallback dependencies
senthil-athiban May 25, 2024
dc32c60
fix: Add "and" and "then" translations
senthil-athiban May 25, 2024
28f26ac
(feat): register rule builder as feature flag
senthil-athiban May 28, 2024
5e9d17c
(enhance): improve handler function logic & add fails action
senthil-athiban May 28, 2024
88720a2
(feat): create global state for storing the rules
senthil-athiban May 29, 2024
cc8823b
(chore): Refactor rule types and handler functions
senthil-athiban May 29, 2024
3224f79
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban May 29, 2024
2b390a7
(chore): optimize handler functions and use debounce mechanism for er…
senthil-athiban May 30, 2024
24f43b4
(chore): remove rule from global state and fixing infinite re-renders
senthil-athiban May 30, 2024
b6f9d85
(chore): Refactor condition, and action selection logic in dropdown
senthil-athiban May 30, 2024
1743162
(fix): fixed handleElementChange logic
senthil-athiban May 31, 2024
dd42b37
(feat): ability to add multiple logics for same question field
senthil-athiban Jun 1, 2024
7145a3d
(chore): update translation
senthil-athiban Jun 1, 2024
9ac8919
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 1, 2024
096643c
(chore): optimize the global state rules
senthil-athiban Jun 3, 2024
077579e
(chore): update conditional rendering logic of rule builder
senthil-athiban Jun 3, 2024
cd17eb7
(chore): refactor RuleHeader component in rule-builder
senthil-athiban Jun 3, 2024
c26c549
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 3, 2024
35ba21a
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 4, 2024
41989d6
(chore): update translation
senthil-athiban Jun 4, 2024
820356a
(feat): add unit test for rule header component
senthil-athiban Jun 6, 2024
b4497ab
(feat): add unit test for rule-builder component
senthil-athiban Jun 6, 2024
f1f9da5
(refactor): Refactor mockup values for unit testing
senthil-athiban Jun 7, 2024
fb0aab6
(feat): add unit test in rule-header
senthil-athiban Jun 7, 2024
d813e75
(feat): add link to docs
senthil-athiban Jun 7, 2024
d822ed3
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 7, 2024
be524dc
(refactor): enhance conditional rendering of docs link
senthil-athiban Jun 10, 2024
07f8108
(feat): Improve performance by memoizing React components
senthil-athiban Jun 10, 2024
9b08cea
(feat): add delete conditional logic modal
senthil-athiban Jun 10, 2024
76f5dd6
(feat): add translation
senthil-athiban Jun 10, 2024
3e7833f
(fix): enhance id of delete conditional logic
senthil-athiban Jun 10, 2024
9150ac5
(refactor): enhance naming conventions
senthil-athiban Jun 10, 2024
c5cb9d9
(feat): add translation
senthil-athiban Jun 10, 2024
9acd3b0
(feat): improve conditional logic delete modal
senthil-athiban Jun 11, 2024
4190601
(feat): add translation
senthil-athiban Jun 11, 2024
2ff4bb8
(feat): add delete conditions or actions modal
senthil-athiban Jun 12, 2024
6e67346
(feat): add custom combo box for target value
senthil-athiban Jun 12, 2024
1df0a08
(feat): add translation
senthil-athiban Jun 12, 2024
2eb2edc
(feat): add toggle functionality for allowing future dates
senthil-athiban Jun 12, 2024
922575f
(feat): add disallow decimal value toggle functionality
senthil-athiban Jun 12, 2024
ccd2010
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 12, 2024
b5b39b3
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 13, 2024
5328707
(fix): delete the specified conditional logic
senthil-athiban Jun 13, 2024
7f628bf
(fix): Remove duplicate errorMessageBox entry in translations
senthil-athiban Jun 13, 2024
d0decb8
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 13, 2024
10f1de0
(feat): update trigger actions with calculate expression
senthil-athiban Jun 18, 2024
7cb5416
(feat): add hideWhenExpression and calculateExpression logics
senthil-athiban Jun 19, 2024
ddf6443
merge main
senthil-athiban Jun 19, 2024
ef3028d
(fix): review changes
senthil-athiban Jun 19, 2024
b256194
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 20, 2024
19493ad
(feat): add ability to remove the deleted logics from schema
senthil-athiban Jun 20, 2024
aa8efbd
(feat): add translation
senthil-athiban Jun 20, 2024
543fc03
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 24, 2024
4b4b8ca
(feat): add date calculation logic
senthil-athiban Jun 24, 2024
0c78993
(feat): add doesNotMatchExpression logic
senthil-athiban Jun 24, 2024
19b8862
(refactor): add enums and interface for rule-builder
senthil-athiban Jun 24, 2024
f2b0aef
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jun 27, 2024
73dfede
merge main
senthil-athiban Jun 27, 2024
383fb1c
(fix): rename modal file
senthil-athiban Jun 27, 2024
e63f685
(feat): add arrContains and arrContainsAny logic
senthil-athiban Jun 27, 2024
3ad21ca
(feat): add translation
senthil-athiban Jun 27, 2024
8bfa0c6
(test): unit test coverage for calculate expression and arrContains l…
senthil-athiban Jun 28, 2024
1c0d695
(fix): build issue
senthil-athiban Jul 2, 2024
7d022af
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jul 2, 2024
c03b150
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jul 4, 2024
bf1de37
(feat): add hidingRule for pages, and sections
senthil-athiban Jul 4, 2024
51cae44
(feat): add disableWhenExpression logic
senthil-athiban Jul 4, 2024
c0dbdcd
(test): add unit test for dynamic rendering of action fields
senthil-athiban Jul 4, 2024
4a72f18
(feat): add translation
senthil-athiban Jul 4, 2024
84eea7c
(fix): fix typo in arrContains logic
senthil-athiban Jul 4, 2024
39ac493
(fix): typo
senthil-athiban Jul 5, 2024
f805daa
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jul 8, 2024
6352a12
(fix): fixed renderingType in date validation
senthil-athiban Jul 10, 2024
cd7e0ae
(fix): avoided direct access of DOM element
senthil-athiban Jul 10, 2024
09ebd85
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jul 10, 2024
7137600
(feat): add calcTimeDifference helper function
senthil-athiban Jul 11, 2024
92f297f
(feat): add includes helper function
senthil-athiban Jul 11, 2024
d25c4a4
(feat): add viral load status helper function
senthil-athiban Jul 11, 2024
766d2b5
(fix): add calcTimeDifference in months
senthil-athiban Jul 11, 2024
70610e4
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jul 11, 2024
45cfda8
(feat): add dayjs
senthil-athiban Jul 13, 2024
a4164d4
(feat): add date validation
senthil-athiban Jul 13, 2024
9b0b57e
(test): unit test coverage for date validation
senthil-athiban Jul 13, 2024
9c6c8fd
(feat): add translation
senthil-athiban Jul 13, 2024
6616d72
(feat): add mechanism for processing Calculate()
senthil-athiban Jul 19, 2024
79f5727
(feat): add calcNextVisitDate helper function
senthil-athiban Jul 19, 2024
3ce1757
(feat): add calcTreatmentEndDate()
senthil-athiban Jul 19, 2024
e60a2ca
(feat): add calcGravida()
senthil-athiban Jul 19, 2024
a06d1e3
(fix): use today()
senthil-athiban Jul 19, 2024
974f5ae
Merge branch 'main' into feat/validation-rule-builder
denniskigen Jul 21, 2024
633192b
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Jul 26, 2024
471632a
Merge branch 'feat/validation-rule-builder' of https://github.com/sen…
senthil-athiban Jul 26, 2024
371cd7e
(feat): enable historical expression using toggle functionality
senthil-athiban Jul 26, 2024
2183658
(test): add unit test for historical expression
senthil-athiban Jul 26, 2024
e317618
(feat): add translation
senthil-athiban Jul 26, 2024
db95674
(feat): add helper function for historical Expression
senthil-athiban Jul 26, 2024
cdbb655
(feat): move findQuestionIndex() to utils
senthil-athiban Jul 26, 2024
8d233e7
(fix): typo
senthil-athiban Jul 26, 2024
a7158e4
(refactor): review feedback
senthil-athiban Jul 27, 2024
f8c6751
(fix): hide logic
senthil-athiban Jul 27, 2024
f27b871
(fix): disable the deletePreviousAction()
senthil-athiban Jul 27, 2024
b620610
(feat): add e2e test for toggle functionality
senthil-athiban Aug 2, 2024
bad01da
(fix): remove log
senthil-athiban Aug 2, 2024
8ecb4fe
(fix): typo in e2e test
senthil-athiban Aug 2, 2024
ae3c263
(fix): rename file
senthil-athiban Aug 2, 2024
8b5d274
(feat): add e2e for hiding logic
senthil-athiban Aug 2, 2024
e0dda3b
(feat): add e2e test for calculation logic
senthil-athiban Aug 2, 2024
911493e
(feat): add e2e test for calculating EDD
senthil-athiban Aug 2, 2024
f154619
(feat): add e2e test for calculate viral load status
senthil-athiban Aug 2, 2024
db848f5
(feat): add e2e test for date validation
senthil-athiban Aug 3, 2024
22bf5af
(test): replace string with regex in e2e test
senthil-athiban Aug 3, 2024
800e66d
(test): refactor the e2e test with test.step()
senthil-athiban Aug 3, 2024
f35b87b
(fix): use renderSWR in test
senthil-athiban Aug 10, 2024
98d4527
(fix): change DOM element in test
senthil-athiban Aug 10, 2024
78778f0
(fix): use conditional rendering
senthil-athiban Aug 10, 2024
830d0b2
(refactor): improve handling statement
senthil-athiban Aug 10, 2024
22adbb6
(chore): add descriptive commands
senthil-athiban Aug 10, 2024
de22f16
(feat): add new hide type
senthil-athiban Aug 10, 2024
799738a
(refactor): remove unused deletePreviousAction function
senthil-athiban Aug 10, 2024
afc8fe0
(refactor): add descriptive commands for handler functions
senthil-athiban Aug 11, 2024
0896c4b
(fix): avoid direct mutation
senthil-athiban Aug 11, 2024
03130b1
(fix): adjust css of combo box
senthil-athiban Aug 11, 2024
9a1d0b4
(fix): increase padding in combobx
senthil-athiban Aug 11, 2024
4138f84
(fix): typo
senthil-athiban Aug 15, 2024
ccdfdc9
(fix): use const assertions over enums
senthil-athiban Aug 15, 2024
3fcb509
(feat): remove enum and declare const assertions
senthil-athiban Aug 15, 2024
8f624e5
(fix): update validatorIndex in formRule interface instead of setState
senthil-athiban Aug 15, 2024
f89b764
(fix): delete conditional logic
senthil-athiban Aug 15, 2024
cc5bd0d
(fix): update isNewRule when first rule gets deleted
senthil-athiban Aug 15, 2024
4a4720a
(fix): delete all conditional logic and update schema
senthil-athiban Aug 17, 2024
da7fa2d
(fix): delete previous action
senthil-athiban Aug 17, 2024
52026cd
(feat): add (calculate, disable) action types in deletePreviousAction
senthil-athiban Aug 17, 2024
23e518d
(feat): add descriptive comments in handleElementChange()
senthil-athiban Aug 17, 2024
4c9de04
(feat): add delete functionality to remove mistakenly chosen actions
senthil-athiban Aug 17, 2024
1254a40
(fix): apply DRY principle
senthil-athiban Aug 17, 2024
97f7f43
(fix): remove delete keyword
senthil-athiban Aug 18, 2024
8a6f1be
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-form-bu…
senthil-athiban Aug 29, 2024
7b20ea4
merge main
senthil-athiban Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions __mocks__/rule-builder.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { type FormRule } from '../src/components/rule-builder/rule-builder.component';
import { type Schema, type Question } from '../src/types';

interface UseFormMockValues {
rules: Array<FormRule>;
setRules: () => jest.Mock;
}

export const useFormMockValues: UseFormMockValues = { rules: [], setRules: () => jest.fn() };

export const numberRenderingQuestion: Question = {
label: 'Age',
type: 'obs',
required: true,
id: 'age',
questionOptions: {
rendering: 'number',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
answers: [
{
concept: 'a899b35c-1350-11df-a1f1-0026b9348838',
label: 'Yes',
},
{
concept: 'a899b42e-1350-11df-a1f1-0026b9348838',
label: 'No',
},
]
},
validators: [],
};

export const dateRenderingQuestion: Question = {
label: 'date',
type: 'obs',
required: false,
id: 'date',
questionOptions: {
rendering: 'date',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
answers: [],
},
validators: [],
};

export const schema: Schema = {
name: 'form1',
pages: [
{
label: 'page1',
sections: [
{
label: 'section1',
isExpanded: 'true',
questions: [
{
label: 'Name',
type: 'obs',
required: true,
id: 'name',
questionOptions: {
rendering: 'text',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
},
validators: [],
},
{
label: 'Are you currently in HIV care or under ART?',
id: 'currentlyOnArt',
type: 'obs',
questionOptions: {
rendering: 'select',
concept: 'a8afba58-1350-11df-a1f1-0026b9348838',
answers: [
{
concept: 'a899b35c-1350-11df-a1f1-0026b9348838',
label: 'Yes',
},
{
concept: 'a899b42e-1350-11df-a1f1-0026b9348838',
label: 'No',
},
],
},
validators: [],
},
],
},
],
},
{
label: 'page2',
sections: [
{
label: 'section2',
isExpanded: 'true',
questions: [
{
label: 'Age',
type: 'obs',
required: true,
id: 'age',
questionOptions: {
rendering: 'text',
concept: '162370AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
conceptMappings: [
{
relationship: 'SAME-AS',
type: 'CIEL',
value: '162370',
},
{
relationship: 'SAME-AS',
type: 'SNOMED CT',
value: '419702001',
},
],
},
validators: [],
},
],
},
],
},
],
processor: 'EncounterFormProcessor',
encounterType: '',
referencedForms: [],
uuid: '',
description: 'desc1',
};
21 changes: 20 additions & 1 deletion e2e/pages/form-builder-page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';

import customSchema from '../support/validation-custom-schema.json';
export class FormBuilderPage {
constructor(readonly page: Page) {}

Expand Down Expand Up @@ -55,6 +55,16 @@ export class FormBuilderPage {
readonly questionCreatedMessage = () => this.page.getByText(/new question created/i);
readonly saveQuestionButton = () => this.page.getByRole('button', { name: /^save$/i, exact: true });

readonly implementorTools = () => this.page.getByTestId('globalImplementerToolsButton').getByRole('button');
readonly featureFlags = () => this.page.getByRole('tab', { name: 'Feature flags' });
readonly validationRuleBuilder = () =>
this.page
.getByRole('row', { name: 'Validation Rule Builder' })
.getByRole('cell')
.nth(2)
.locator('.cds--toggle > .cds--toggle__label > .cds--toggle__appearance > .cds--toggle__switch');
readonly closeImplementorTools = () => this.page.getByRole('button', { name: 'Close', exact: true });

async gotoFormBuilder() {
await this.page.goto('form-builder');
}
Expand Down Expand Up @@ -105,6 +115,15 @@ export class FormBuilderPage {
await this.formSaveButton().click();
}

async formBuilderSetupForRuleBuilder() {
await this.createNewFormButton().click();
await this.implementorTools().click();
await this.featureFlags().click();
await this.validationRuleBuilder().click();
await this.closeImplementorTools().click();
await this.schemaInput().fill(JSON.stringify(customSchema, null, 2));
await this.renderChangesButton().click();
}
async searchForForm(formName: string) {
await this.page.getByRole('searchbox').fill(formName);
}
Expand Down
Loading
Loading