-
Notifications
You must be signed in to change notification settings - Fork 59
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
(test) O3-3937 Add test coverage around form readonly mode #401
base: main
Are you sure you want to change the base?
Conversation
Size Change: 0 B Total Size: 1.22 MB ℹ️ View Unchanged
|
src/form-engine.test.tsx
Outdated
describe('Read only mode', () => { | ||
it('should ascertain that each field with readonly = true passed will not be editable', async () => { | ||
await act(async () => { | ||
renderForm(null, readOnlyValidationForm); | ||
}); | ||
|
||
const visitTypeDropdown = screen.getByRole('combobox', { | ||
name: /visit type/i, | ||
}); | ||
const visitPunctualityTextbox = screen.getByLabelText(/visit punctuality/i); | ||
|
||
expect(visitTypeDropdown).toBeInTheDocument(); | ||
expect(visitTypeDropdown).toHaveClass('cds--list-box__field'); | ||
|
||
const visitTypeWrapper = visitTypeDropdown.closest('.cds--dropdown'); | ||
expect(visitTypeWrapper).toHaveClass('cds--dropdown cds--dropdown--readonly cds--list-box'); | ||
|
||
expect(visitPunctualityTextbox).toBeInTheDocument(); | ||
expect(visitPunctualityTextbox).toHaveClass('cds--text-input'); | ||
|
||
const visitPunctualityWrapper = visitPunctualityTextbox.closest('.cds--text-input-wrapper'); | ||
expect(visitPunctualityWrapper).toHaveClass( | ||
'cds--form-item cds--text-input-wrapper cds--text-input-wrapper--readonly', | ||
); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love tests but this test is supposed to be testing a form rendered in "view" mode. I've updated the ticket to clearly reflect this. (sorry for the confusion)
The form-engine supports three major modes: enter (new), edit and view (readonly). This ticket is meant for adding test coverage of the form’s behaviour while in view mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, let me do a rework
7a498c2
to
8f30422
Compare
src/form-engine.test.tsx
Outdated
@@ -842,15 +844,68 @@ describe('Form engine component', () => { | |||
}); | |||
}); | |||
|
|||
function renderForm(formUUID, formJson, intent?: string) { | |||
describe('Read only mode', () => { | |||
it('should ascertain that each field with readonly = true passed will not be editable', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('should ascertain that each field with readonly = true passed will not be editable', async () => { | |
it('should ensure that each read-only field is not editable', async () => {', async () => { |
src/form-engine.test.tsx
Outdated
}); | ||
|
||
describe('Form view mode', () => { | ||
it('should ascertain that fields cannot be edited on view mode', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it('should ascertain that fields cannot be edited on view mode', async () => { | |
it('should ensure that the form isn't editable in view mode', async () => { |
inputs.forEach((input) => { | ||
expect(input).toHaveAttribute('readonly'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also assert that the "Save" button is disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it on line 884
{ | ||
id: 'sampleQuestion', | ||
label: 'Question title', | ||
questionOptions: { | ||
concept: '193e8a03-1581-46e9-b0a4-17c55fa2649f', | ||
rendering: 'text', | ||
}, | ||
type: 'obs', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this?
{ | ||
id: 'sampleQuestion', | ||
label: 'Question title', | ||
questionOptions: { | ||
concept: '193e8a03-1581-46e9-b0a4-17c55fa2649f', | ||
rendering: 'text', | ||
}, | ||
type: 'obs', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/form-engine.test.tsx
Outdated
expect(visitTypeDropdown).toHaveClass('cds--list-box__field'); | ||
|
||
const visitTypeWrapper = visitTypeDropdown.closest('.cds--dropdown'); | ||
expect(visitTypeWrapper).toHaveClass('cds--dropdown cds--dropdown--readonly cds--list-box'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the CSS names change? Can you use attributes instead?
Requirements
Summary
O3-3937 Add test coverage around form readonly mode
Screenshots
Related Issue
https://openmrs.atlassian.net/browse/O3-3937
Other