Skip to content
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 feedback #557

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading