Skip to content

Commit

Permalink
Merge pull request #557 from logion-network/feature/test-feedback
Browse files Browse the repository at this point in the history
Test feedback
  • Loading branch information
benoitdevos authored Mar 28, 2024
2 parents 828edf6 + b182e1b commit 4462a76
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
24 changes: 11 additions & 13 deletions src/loc/CollectionLocRequest.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("CollectionLocRequest", () => {

await selectLegalOfficer();
await fillInForm();
await clickByName("Submit");
await clickByName("Create Draft");

await waitFor(() => expect(navigate).toBeCalledWith(`/user/loc/collection/${locId.toString()}`));
});
Expand All @@ -33,35 +33,33 @@ describe("CollectionLocRequest", () => {

setupLocsState([]);
render(<CollectionLocRequest backPath="back" />);
await waitFor(() => {
expect(screen.getByRole("button", { name: "Submit" })).toBeDisabled();
expect(screen.getByRole("button", { name: "Request an Identity Protection" })).toBeEnabled();
});
await checkFormDisabled();
});

it("should disable form submission when no legal officer selected", async () => {

setupLocsState(twoLegalOfficers);
render(<CollectionLocRequest backPath="back" />);
await waitFor(() => {
expect(screen.getByRole("button", { name: "Submit" })).toBeDisabled();
expect(screen.getByRole("button", { name: "Request an Identity Protection" })).toBeEnabled();
});
await checkFormDisabled();
});

it("should disable form submission when no collection limit selected", async () => {

setupLocsState(twoLegalOfficers);
render(<CollectionLocRequest backPath="back" />);
await selectLegalOfficer();
await waitFor(() => {
expect(screen.getByRole("button", { name: "Submit" })).toBeDisabled();
expect(screen.getByRole("button", { name: "Request an Identity Protection" })).toBeEnabled();
});
await checkFormDisabled();
});

})

async function checkFormDisabled() {
await waitFor(() => {
expect(screen.getByRole("button", { name: "Create Draft" })).toBeDisabled();
expect(screen.getByRole("button", { name: "Request an Identity Protection" })).toBeEnabled();
});
}

function setupLocsState(legalOfficersWithValidIdentityLoc: LegalOfficerClass[]) {
const draftRequest = {
locId,
Expand Down
2 changes: 1 addition & 1 deletion src/loc/CollectionLocRequestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default function CollectionLocRequestForm(props: Props) {

<ButtonGroup>
<Button disabled={ props.legalOfficer === undefined || !limits.areValid() } type="submit"
onClick={ handleSubmit(submit) }>Submit</Button>
onClick={ handleSubmit(submit) }>Create Draft</Button>
</ButtonGroup>

</>
Expand Down
3 changes: 1 addition & 2 deletions src/loc/LocDetailsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,12 @@ export function LocDetailsTabContent(props: ContentProps) {
await mutateLocState(async current => {
if(current instanceof RejectedRequest) {
const next = await current.rework();
navigate(backPath);
return next.locsState();
} else {
return current;
}
});
}, [ mutateLocState, navigate, backPath ]);
}, [ mutateLocState ]);

if(!loc) {
return null;
Expand Down

0 comments on commit 4462a76

Please sign in to comment.