Skip to content

Commit d38933d

Browse files
fix(REGISTRY-2731): Improve tabs on Organisation profile (#850)
2 parents 1c8129c + c3dadc0 commit d38933d

25 files changed

Lines changed: 591 additions & 211 deletions

File tree

cypress/e2e/user-journeys/admin/sro.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe("SRO journey", () => {
2020
describe("Organisation not approved", () => {
2121
beforeEach(() => {
2222
loginUnapprovedOrganisation();
23-
cy.visitFirst(ROUTES.profileOrganisationDetailsNameAndAddress.path);
23+
cy.visitFirst(ROUTES.profileOrganisationDetailsNameAndSRO.path);
2424
});
2525

2626
after(() => {
@@ -67,7 +67,7 @@ describe("SRO journey", () => {
6767
beforeEach(() => {
6868
loginUnapprovedOrganisation();
6969

70-
cy.visitFirst(ROUTES.profileOrganisationDetailsNameAndAddress.path);
70+
cy.visitFirst(ROUTES.profileOrganisationDetailsNameAndSRO.path);
7171
});
7272

7373
after(() => {

cypress/e2e/user-journeys/organisations/subsidiaries.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("Subsidiaries journey", () => {
2727
beforeEach(() => {
2828
loginOrganisation();
2929

30-
cy.visitFirst(ROUTES.profileOrganisationDetailsNameAndAddress.path);
30+
cy.visitFirst(ROUTES.profileOrganisationDetailsOrganisationDetails.path);
3131
});
3232

3333
after(() => {

mocks/data/cms.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,10 @@ export type ProfileGuidance = Record<string, TabGuidance>;
435435

436436
export const mockedOrganisationProfileGuidance: TabGuidance = {
437437
details: {
438-
"name-and-address": {
439-
infoTitle: "Why are we asking for this information?",
438+
"name-and-sro": {
439+
infoTitle: "What’s a Senior Responsible Officer?",
440440
info: (
441441
<>
442-
<Typography mb={5}>
443-
Providing the Safe People Registry with full Organisation
444-
information helps Data Custodians validate your Organisation. The
445-
more information you provide, the faster and easier the validation
446-
process becomes for Users (an employee or student of an
447-
Organisation) to gain access to sensitive data.
448-
</Typography>
449-
450442
<Typography mb={3}>
451443
<strong>Senior Responsible Officers (SROs)</strong> are responsible
452444
for:
@@ -479,30 +471,44 @@ export const mockedOrganisationProfileGuidance: TabGuidance = {
479471
</>
480472
),
481473
},
482-
"digital-identifiers": {
483-
infoTitle: "More information, faster validation",
474+
address: {
475+
infoTitle: "Why are we asking for this information?",
484476
info: (
485477
<>
486478
<Typography mb={5}>
487-
Providing the Safe People Registry with your Organisation's
488-
persistent digital identifiers enables Data Custodians to rapidly
489-
validate your Organisation.
479+
Providing the Safe People Registry with full Organisation
480+
information helps Data Custodians validate your Organisation. The
481+
more information you provide, the faster and easier the validation
482+
process becomes for Users (an employee or student of an
483+
Organisation) to gain access to sensitive data.
490484
</Typography>
491485
<Typography mb={5}>
492-
If your Organisation’s headquarters is based in the UK, your
493-
Organisation legal name and address should align with your
494-
Organisation's listing on Companies House.
486+
If your Organisation headquarters is based within the UK, your
487+
Organisation legal name and address information should align with
488+
your Organisations listing on Companies House.
495489
</Typography>
496490
</>
497491
),
498492
},
499-
"sector-size-and-website": {
493+
"organisation-details": {
500494
infoTitle: "More facts, quicker access",
495+
info: (
496+
<>
497+
<Typography mb={5}>
498+
Providing the Safe People Registry with information on your
499+
Organisation’s sector, size and website accelerates Organisation
500+
validation by Data Custodians.
501+
</Typography>
502+
</>
503+
),
504+
},
505+
"digital-identifiers": {
506+
infoTitle: "More information, faster validation",
501507
info: (
502508
<Typography mb={5}>
503-
Providing the Safe People Registry with information on your
504-
Organisation’s sector, size and website accelerates Organisation
505-
validation by Data Custodians.
509+
Providing the Safe People Registry with your Organisation's persistent
510+
digital identifiers enables Data Custodians to rapidly validate your
511+
Organisation.
506512
</Typography>
507513
),
508514
},

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const nextConfig = withNextIntl({
6565
},
6666
{
6767
source: "/:locale/organisation/profile/details",
68-
destination: `/:locale/organisation/profile/details/name-and-address`,
68+
destination: `/:locale/organisation/profile/details/name-and-sro`,
6969
},
7070
{
7171
source: "/:locale/organisation/profile/user-administration",

src/app/[locale]/(logged-in)/data-custodian/profile/components/Webhooks/Webhooks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export default function Webhooks() {
272272
<FormActions>
273273
<ProfileNavigationFooter
274274
previousHref={
275-
ROUTES.profileOrganisationDetailsSectorSizeAndWebsite
275+
ROUTES.profileOrganisationDetailsOrganisationDetails
276276
.path
277277
}
278278
isLoading={isPostLoading || isDeleteLoading}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { mockedOrganisation } from "@/mocks/data/organisation";
2+
import { fireEvent, render, screen, waitFor } from "@/utils/testUtils";
3+
import Address from "./Address";
4+
5+
const putProps = {
6+
isError: false,
7+
isPending: false,
8+
error: null,
9+
onSubmit: jest.fn().mockResolvedValue(null),
10+
};
11+
12+
jest.mock("../../hooks/useUpdateOrganisation", () => ({
13+
__esModule: true,
14+
default: () => putProps,
15+
}));
16+
17+
function setupTest() {
18+
return render(<Address />);
19+
}
20+
21+
const userData = {
22+
id: 1,
23+
first_name: "first",
24+
last_name: "last",
25+
email: "email@example.com",
26+
role: "SRO",
27+
departments: [{ id: 123, name: "Research" }],
28+
};
29+
30+
function getAllInputs() {
31+
return [/Address 1/, /Address 2/, /Town/, /County/, /Country/, /Postcode/];
32+
}
33+
34+
const organisation = mockedOrganisation();
35+
36+
describe("<Address />", () => {
37+
beforeEach(() => {
38+
mockUseStore({
39+
config: { organisation, user: userData },
40+
});
41+
// mutateUserMock.mockClear();
42+
putProps.onSubmit.mockClear();
43+
});
44+
45+
afterEach(() => {
46+
jest.clearAllMocks();
47+
});
48+
49+
it("renders all address fields", () => {
50+
setupTest();
51+
52+
const inputs = getAllInputs();
53+
54+
inputs.forEach(selector => {
55+
expect(screen.getAllByLabelText(selector)[0]).toBeInTheDocument();
56+
});
57+
});
58+
59+
it("submits the form when values are filled", async () => {
60+
setupTest();
61+
62+
const form = await screen.findByRole("form", { name: "Address" });
63+
fireEvent.submit(form);
64+
65+
const { address_1, address_2, county, country, town, postcode } =
66+
organisation;
67+
68+
await waitFor(() => {
69+
expect(putProps.onSubmit).toHaveBeenCalledWith({
70+
address_1,
71+
address_2,
72+
county,
73+
country,
74+
town,
75+
postcode,
76+
});
77+
});
78+
});
79+
80+
it("does not submit the form when values are cleared", async () => {
81+
setupTest();
82+
83+
clearInputsByLabelText(getAllInputs());
84+
85+
const form = await screen.findByRole("form", { name: "Address" });
86+
fireEvent.submit(form);
87+
88+
await waitFor(() => {
89+
expect(putProps.onSubmit).not.toHaveBeenCalled();
90+
});
91+
});
92+
});

0 commit comments

Comments
 (0)