diff --git a/app/javascript/components/form/components/form-section-field.jsx b/app/javascript/components/form/components/form-section-field.jsx index dace0f7194..6814fa730d 100644 --- a/app/javascript/components/form/components/form-section-field.jsx +++ b/app/javascript/components/form/components/form-section-field.jsx @@ -49,7 +49,7 @@ const FormSectionField = ({ checkErrors, field, formMethods, formMode, disableUn return ( handleVisibility() || ( -
+
{renderField}
diff --git a/app/javascript/components/page-navigation/component.jsx b/app/javascript/components/page-navigation/component.jsx index 5519bdfaaa..94b0fed50e 100644 --- a/app/javascript/components/page-navigation/component.jsx +++ b/app/javascript/components/page-navigation/component.jsx @@ -47,7 +47,9 @@ const Component = ({ handleToggleNav, menuList = [], mobileDisplay = false, sele return ( - {renderList} + + {renderList} + ); }; diff --git a/app/javascript/components/pages/admin/form-builder/components/translations-form/components/field-translation-row/component.spec.js b/app/javascript/components/pages/admin/form-builder/components/translations-form/components/field-translation-row/component.spec.js new file mode 100644 index 0000000000..3c12d492cd --- /dev/null +++ b/app/javascript/components/pages/admin/form-builder/components/translations-form/components/field-translation-row/component.spec.js @@ -0,0 +1,48 @@ +// Copyright (c) 2014 - 2023 UNICEF. All rights reserved. + +import { fromJS } from "immutable"; + +import { mountedFormComponent, screen } from "../../../../../../../../test-utils"; + +import FieldTranslationRow from "./component"; + +describe("", () => { + + const field1 = { + name: "field_1", + display_name: { fr: "Field 1", ar: "Field 1", en: "Field 1" }, + type: "text_field" + }; + + const state = fromJS({ + application: { primero: { locales: ["en", "fr", "ar"] } }, + records: { + admin: { + forms: { + selectedFields: [ + field1, + { + name: "field_2", + display_name: { en: "Field 2" } + } + ] + } + } + } + }); + + const props = { field: fromJS(field1), selectedLocaleId: "fr", formMode: {}, formMethods: {} }; + + it("should render the for the fr language", () => { + mountedFormComponent(, { state }); + expect(document.getElementById('fields.field_1.display_name.en')).toBeInTheDocument(); + expect(document.getElementById('fields.field_1.display_name.fr')).toBeInTheDocument(); + }); + + it("should render the for the ar language", () => { + const arProps = { field: fromJS(field1), selectedLocaleId: "ar", formMode: {}, formMethods: {} }; + mountedFormComponent(, { state }); + expect(document.getElementById('fields.field_1.display_name.en')).toBeInTheDocument(); + expect(document.getElementById('fields.field_1.display_name.ar')).toBeInTheDocument(); + }); +}); diff --git a/app/javascript/components/pages/admin/form-builder/components/translations-form/components/field-translation-row/component.unit.test.js b/app/javascript/components/pages/admin/form-builder/components/translations-form/components/field-translation-row/component.unit.test.js deleted file mode 100644 index 2afbd246fa..0000000000 --- a/app/javascript/components/pages/admin/form-builder/components/translations-form/components/field-translation-row/component.unit.test.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2014 - 2023 UNICEF. All rights reserved. - -import { fromJS } from "immutable"; - -import { FormSectionField } from "../../../../../../../form"; -import { setupMockFormComponent } from "../../../../../../../../test"; - -import FieldTranslationRow from "./component"; - -describe("", () => { - let component; - const field1 = { - name: "field_1", - display_name: { en: "Field 1" } - }; - const state = fromJS({ - application: { primero: { locales: ["en", "fr", "ar"] } }, - records: { - admin: { - forms: { - selectedFields: [ - field1, - { - name: "field_2", - display_name: { en: "Field 2" } - } - ] - } - } - } - }); - - beforeEach(() => { - ({ component } = setupMockFormComponent(FieldTranslationRow, { - props: { field: fromJS(field1), selectedLocaleId: "fr" }, - state - })); - }); - - it("should render ", () => { - expect(component.find(FieldTranslationRow)).to.have.lengthOf(1); - }); - - it("should render the for the available languages", () => { - const expectedNames = [ - "fields.field_1.display_name.en", - "fields.field_1.display_name.fr", - "fields.field_1.display_name.ar" - ]; - - const fields = component.find(FormSectionField).map(f => f.props().field.get("name")); - - expect(fields).to.deep.equal(expectedNames); - }); -}); diff --git a/app/javascript/components/pages/admin/lookups-form/components/draggable-row/component.jsx b/app/javascript/components/pages/admin/lookups-form/components/draggable-row/component.jsx index 713882b89b..8c8454b087 100644 --- a/app/javascript/components/pages/admin/lookups-form/components/draggable-row/component.jsx +++ b/app/javascript/components/pages/admin/lookups-form/components/draggable-row/component.jsx @@ -53,7 +53,13 @@ const Component = ({ ); return ( - + {provider => { return (
diff --git a/app/javascript/components/pages/admin/roles-form/forms/action-buttons.spec.js b/app/javascript/components/pages/admin/roles-form/forms/action-buttons.spec.js index 888764258f..0f3f834b4d 100644 --- a/app/javascript/components/pages/admin/roles-form/forms/action-buttons.spec.js +++ b/app/javascript/components/pages/admin/roles-form/forms/action-buttons.spec.js @@ -1,5 +1,4 @@ import { fromJS } from "immutable"; -import { Button } from "@material-ui/core"; import { ACTIONS } from "../../../../permissions"; import { mountedComponent, screen } from "../../../../../test-utils"; @@ -16,50 +15,45 @@ describe("", () => { describe("when isShow mode", () => { describe("when the user has write permissions on roles", () => { - - it("should render the edit button only", () => { - mountedComponent(, fromJS({ + mountedComponent( + , + fromJS({ user: { permissions: { roles: [ACTIONS.WRITE] } } - })) - expect(screen.getByRole('button')).toBeInTheDocument(); - expect(screen.getByText('buttons.edit')).toBeInTheDocument(); - + }) + ); + expect(screen.getByRole("button")).toBeInTheDocument(); + expect(screen.getByText("buttons.edit")).toBeInTheDocument(); }); }); describe("when the user doesn't have write permissions on roles", () => { - it("should not render the edit button", () => { - mountedComponent(, fromJS({})) - expect(screen.queryAllByRole('button')).toHaveLength(0); + mountedComponent(, fromJS({})); + expect(screen.queryAllByRole("button")).toHaveLength(0); }); }); }); describe("when isEdit mode", () => { - it("should render cancel and save buttons only", () => { - mountedComponent(, fromJS({})) - expect(screen.getAllByRole('button')).toHaveLength(2); - expect(screen.getByText('buttons.cancel')).toBeInTheDocument(); - expect(screen.getByText('buttons.save')).toBeInTheDocument(); - - + mountedComponent(, fromJS({})); + expect(screen.getAllByRole("button")).toHaveLength(2); + expect(screen.getByText("buttons.cancel")).toBeInTheDocument(); + expect(screen.getByText("buttons.save")).toBeInTheDocument(); }); }); describe("when isNew mode", () => { - it("should render cancel and save buttons", () => { - mountedComponent(, fromJS({})) - expect(screen.getAllByRole('button')).toHaveLength(2); - expect(screen.getByText('buttons.cancel')).toBeInTheDocument(); - expect(screen.getByText('buttons.save')).toBeInTheDocument(); + mountedComponent(, fromJS({})); + expect(screen.getAllByRole("button")).toHaveLength(2); + expect(screen.getByText("buttons.cancel")).toBeInTheDocument(); + expect(screen.getByText("buttons.save")).toBeInTheDocument(); }); }); }); diff --git a/app/javascript/components/pages/admin/roles-form/forms/associated-roles.spec.js b/app/javascript/components/pages/admin/roles-form/forms/associated-roles.spec.js index d8f0b24c58..576e1cae0e 100644 --- a/app/javascript/components/pages/admin/roles-form/forms/associated-roles.spec.js +++ b/app/javascript/components/pages/admin/roles-form/forms/associated-roles.spec.js @@ -9,6 +9,7 @@ describe("pages/admin//forms - AssociatedRolesForm", () => { it("returns the AssociatedRolesForm with fields", () => { const roleForms = AssociatedRolesForm(fromJS([]), i18n); + expect(roleForms.fields).toHaveLength(2); }); }); diff --git a/app/javascript/components/pages/errors/not-authorized/component.spec.js b/app/javascript/components/pages/errors/not-authorized/component.spec.js index 2d94bf2f9a..ce685fd6d4 100644 --- a/app/javascript/components/pages/errors/not-authorized/component.spec.js +++ b/app/javascript/components/pages/errors/not-authorized/component.spec.js @@ -3,7 +3,6 @@ import { mountedComponent, screen } from "../../../../test-utils"; import NotAuthorized from "./component"; describe("", () => { - it("renders h1 tag", () => { mountedComponent(, {}); expect(screen.getByText(/error_page.not_authorized.code/i)).toBeInTheDocument(); diff --git a/app/javascript/components/pages/errors/not-found/component.spec.js b/app/javascript/components/pages/errors/not-found/component.spec.js index c0790c5a30..f591d82283 100644 --- a/app/javascript/components/pages/errors/not-found/component.spec.js +++ b/app/javascript/components/pages/errors/not-found/component.spec.js @@ -3,7 +3,6 @@ import { mountedComponent, screen } from "../../../../test-utils"; import NotFound from "./component"; describe("", () => { - it("renders h1 tag", () => { mountedComponent(, {}); expect(screen.getByText(/error_page.not_found.code/i)).toBeInTheDocument(); diff --git a/app/javascript/components/record-actions/toggle-open/component.spec.js b/app/javascript/components/record-actions/toggle-open/component.spec.js index 6460bf3d5f..dd8c32d3b5 100644 --- a/app/javascript/components/record-actions/toggle-open/component.spec.js +++ b/app/javascript/components/record-actions/toggle-open/component.spec.js @@ -8,7 +8,6 @@ import { RECORD_PATH } from "../../../config"; import ToggleOpen from "./component"; describe("", () => { - const record = fromJS({ id: "03cdfdfe-a8fc-4147-b703-df976d200977", case_id: "1799d556-652c-4ad9-9b4c-525d487b5e7b", @@ -27,17 +26,17 @@ describe("", () => { }; it("renders ToggleOpen", () => { - mountedComponent() + mountedComponent(); expect(screen.getByText(/cases.reopen_dialog_title/i)).toBeInTheDocument(); }); it("renders ActionDialog", () => { - mountedComponent() - expect(screen.getByRole('dialog')).toBeInTheDocument(); + mountedComponent(); + expect(screen.getByRole("dialog")).toBeInTheDocument(); }); it("renders component with valid props", () => { - mountedComponent() - expect(screen.getByRole('dialog')).toBeInTheDocument(); + mountedComponent(); + expect(screen.getByRole("dialog")).toBeInTheDocument(); }); }); diff --git a/app/javascript/components/record-form/form/subforms/subform-drawer/component.jsx b/app/javascript/components/record-form/form/subforms/subform-drawer/component.jsx index 84e6073dff..ed62dab1e1 100644 --- a/app/javascript/components/record-form/form/subforms/subform-drawer/component.jsx +++ b/app/javascript/components/record-form/form/subforms/subform-drawer/component.jsx @@ -12,7 +12,13 @@ import css from "./styles.css"; const Component = ({ open, cancelHandler, children, title }) => { return ( - +

{title}

diff --git a/app/javascript/components/record-form/form/subforms/subform-drawer/component.spec.js b/app/javascript/components/record-form/form/subforms/subform-drawer/component.spec.js index dcc74dc02e..53dfdddc9c 100644 --- a/app/javascript/components/record-form/form/subforms/subform-drawer/component.spec.js +++ b/app/javascript/components/record-form/form/subforms/subform-drawer/component.spec.js @@ -3,7 +3,6 @@ import { mountedComponent, screen } from "../../../../../test-utils"; import SubformDrawer from "./component"; describe("/form/subforms/", () => { - const props = { open: true, children: "" }; it("should render the subform drawer", () => { diff --git a/app/javascript/components/record-form/form/subforms/subform-fields/components/violation-item/component.spec.js b/app/javascript/components/record-form/form/subforms/subform-fields/components/violation-item/component.spec.js index a2eb1726c4..949a2447ff 100644 --- a/app/javascript/components/record-form/form/subforms/subform-fields/components/violation-item/component.spec.js +++ b/app/javascript/components/record-form/form/subforms/subform-fields/components/violation-item/component.spec.js @@ -58,6 +58,5 @@ describe("/form/subforms//components/, initialState); expect(screen.getByTestId("violation-item")).toBeInTheDocument(); - }); }); diff --git a/app/javascript/components/reports-form/container.spec.js b/app/javascript/components/reports-form/container.spec.js index a246bcd8a2..1cb4e28b9c 100644 --- a/app/javascript/components/reports-form/container.spec.js +++ b/app/javascript/components/reports-form/container.spec.js @@ -98,6 +98,7 @@ describe(" - Container", () => { beforeEach(() => { const props = { mode: "new" }; + mountedComponent(, initialState); }); diff --git a/app/javascript/components/transitions/assignments/AssignmentsSummary.jsx b/app/javascript/components/transitions/assignments/AssignmentsSummary.jsx index 5ae11c1937..e7898e9a00 100644 --- a/app/javascript/components/transitions/assignments/AssignmentsSummary.jsx +++ b/app/javascript/components/transitions/assignments/AssignmentsSummary.jsx @@ -21,7 +21,9 @@ const AssignmentsSummary = ({ transition, classes }) => {
-
{i18n.localizeDate(transition.created_at)}
+
+ {i18n.localizeDate(transition.created_at)} +
{i18n.t("transition.type.assign")}
diff --git a/app/javascript/components/user-actions/component.spec.js b/app/javascript/components/user-actions/component.spec.js index 4c53b2e991..8a6c7be7af 100644 --- a/app/javascript/components/user-actions/component.spec.js +++ b/app/javascript/components/user-actions/component.spec.js @@ -22,7 +22,6 @@ describe("", () => { }); describe("when idp is used", () => { - const props = { id: "1" }; it("should render the Menu", () => {