-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into r2-2608-prevent-multiple-cases
Conflicts: spec/requests/api/v2/children_controller_spec.rb
- Loading branch information
Showing
10 changed files
with
181 additions
and
119 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
132 changes: 132 additions & 0 deletions
132
app/javascript/components/record-form/form/subforms/subform-fields/component.spec.js
This file contains 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,132 @@ | ||
import { mountedComponent, screen } from "test-utils"; | ||
|
||
import { FieldRecord, FormSectionRecord } from "../../../records"; | ||
|
||
import SubformFields from "./component"; | ||
|
||
describe("<SubformFields />", () => { | ||
const props = { | ||
arrayHelpers: {}, | ||
parentForm: { | ||
id: 33, | ||
unique_id: "family_details", | ||
description: { | ||
en: "Family Details" | ||
}, | ||
name: { | ||
en: "Family Details" | ||
}, | ||
visible: true, | ||
is_first_tab: false, | ||
order: 10, | ||
order_form_group: 30, | ||
parent_form: "case", | ||
editable: true, | ||
module_ids: ["primeromodule-cp"], | ||
form_group_id: "identification_registration", | ||
form_group_name: { | ||
en: "Identification / Registration" | ||
} | ||
}, | ||
field: FieldRecord({ | ||
name: "family_details_section", | ||
displayName: { en: "Family Details" }, | ||
subform_section_id: FormSectionRecord({ | ||
unique_id: "family_section", | ||
collapsed_field_names: ["relation_name"], | ||
fields: [ | ||
FieldRecord({ | ||
name: "relation_name", | ||
visible: true, | ||
type: "text_field" | ||
}), | ||
FieldRecord({ | ||
name: "relation_child_is_in_contact", | ||
visible: true, | ||
type: "text_field" | ||
}) | ||
] | ||
}) | ||
}), | ||
locale: "en", | ||
setDialogIsNew: () => {}, | ||
setOpen: () => {}, | ||
i18n: { t: value => value, locale: "en" }, | ||
values: [ | ||
{ | ||
relation_name: "Family1", | ||
relation_child_is_in_contact: "" | ||
} | ||
], | ||
mode: { | ||
isShow: true | ||
}, | ||
recordType: "cases" | ||
}; | ||
|
||
it("renders the subform fields", () => { | ||
mountedComponent(<SubformFields {...props} />); | ||
|
||
expect(screen.queryByText("Family1")).toBeTruthy(); | ||
}); | ||
|
||
describe("when is violation or violation association", () => { | ||
it("renders the Delete button disabled", () => { | ||
mountedComponent( | ||
<SubformFields | ||
{...props} | ||
isViolationSubform | ||
isViolationAssociation | ||
mode={{ isEdit: true }} | ||
values={["something"]} | ||
/> | ||
); | ||
|
||
expect(screen.queryAllByRole("button")[0]).toHaveAttribute("disabled"); | ||
}); | ||
}); | ||
|
||
describe("Family Detail subform", () => { | ||
describe("when is associated to a family", () => { | ||
it("renders the Delete button disabled", () => { | ||
mountedComponent( | ||
<SubformFields {...props} isFamilyDetail mode={{ isEdit: true }} formik={{ values: { family_id: "001" } }} /> | ||
); | ||
|
||
expect(screen.queryAllByRole("button")).toHaveLength(2); | ||
expect(screen.queryAllByRole("button")[0]).toHaveAttribute("disabled"); | ||
}); | ||
}); | ||
|
||
describe("when is not associated to a family", () => { | ||
it("renders the Delete button enabled", () => { | ||
mountedComponent(<SubformFields {...props} isFamilyDetail mode={{ isEdit: true }} formik={{ values: {} }} />); | ||
|
||
expect(screen.queryAllByRole("button")).toHaveLength(2); | ||
expect(screen.queryAllByRole("button")[0]).not.toHaveAttribute("disabled"); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Family Member subform", () => { | ||
describe("when is associated to a case", () => { | ||
it("renders the Delete button disabled", () => { | ||
mountedComponent( | ||
<SubformFields {...props} isFamilyMember mode={{ isEdit: true }} values={[{ case_id: "001" }]} /> | ||
); | ||
|
||
expect(screen.queryAllByRole("button")).toHaveLength(2); | ||
expect(screen.queryAllByRole("button")[0]).toHaveAttribute("disabled"); | ||
}); | ||
}); | ||
|
||
describe("when is not associated to a case", () => { | ||
it("renders the Delete button enabled", () => { | ||
mountedComponent(<SubformFields {...props} isFamilyMember mode={{ isEdit: true }} />); | ||
|
||
expect(screen.queryAllByRole("button")).toHaveLength(2); | ||
expect(screen.queryAllByRole("button")[0]).not.toHaveAttribute("disabled"); | ||
}); | ||
}); | ||
}); | ||
}); |
101 changes: 0 additions & 101 deletions
101
app/javascript/components/record-form/form/subforms/subform-fields/component.unit.test.js
This file was deleted.
Oops, something went wrong.
This file contains 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 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
Oops, something went wrong.