Skip to content

Commit

Permalink
936 error handling scorer api (passportxyz#977)
Browse files Browse the repository at this point in the history
* feat(app): remove handleAddStamp

* feat(database-client): switch singular stamp request for bulk request

* feat(app, database-client): use bulk delete request instead of individual requests

* fix(app): remove outdated card component

* feat(app): remove singular delete stamp method

* fix(app): show error message if error was thrown while verifying

* fix(app): add deleteStamp request back in

* feat(database-client): remove unused method
  • Loading branch information
Tim Schultz authored Feb 14, 2023
1 parent 844abe2 commit 299c58d
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 333 deletions.
2 changes: 0 additions & 2 deletions app/__test-fixtures__/contextTestHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,8 @@ export const makeTestCeramicContext = (initialState?: Partial<CeramicContextStat
},
},
passportLoadResponse: undefined,
handleAddStamp: jest.fn(),
handleAddStamps: jest.fn(),
handleCreatePassport: jest.fn(),
handleDeleteStamp: jest.fn(),
handleDeleteStamps: jest.fn(),
handleCheckRefreshPassport: () => Promise.resolve(true),
expiredProviders: [],
Expand Down
114 changes: 0 additions & 114 deletions app/__tests__/components/Card.test.tsx

This file was deleted.

24 changes: 23 additions & 1 deletion app/__tests__/components/GenericPlatform.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const mockUserContext: UserContextState = makeTestUserContext({

const mockCeramicContext: CeramicContextState = makeTestCeramicContext({
handleCreatePassport: mockCreatePassport,
handleAddStamp: mockHandleAddStamp,
});

// TODO
Expand Down Expand Up @@ -137,6 +136,29 @@ describe("Mulitple EVM plaftorms", () => {
});
});

it("should indicate that there was an error issuing the credential", async () => {
const drawer = () => (
<Drawer isOpen={true} placement="right" size="sm" onClose={() => {}}>
<DrawerOverlay />
<GenericPlatform platform={new Ens.EnsPlatform()} platFormGroupSpec={Ens.EnsProviderConfig} />
</Drawer>
);
renderWithContext(
mockUserContext,
{ ...mockCeramicContext, handleAddStamps: jest.fn().mockRejectedValue(500) },
drawer()
);

const firstSwitch = screen.queryByTestId("select-all");
await fireEvent.click(firstSwitch as HTMLElement);
const initialVerifyButton = screen.queryByTestId("button-verify-Ens");

await fireEvent.click(initialVerifyButton as HTMLElement);
await waitFor(() => {
expect(screen.getByText("There was an error verifying your stamp. Please try again.")).toBeInTheDocument();
});
});

// describe("when user attempts to re-verify their passport data point(s)", () => {
// beforeEach(() => {
// (fetchVerifiableCredential as jest.Mock).mockResolvedValue({
Expand Down
158 changes: 0 additions & 158 deletions app/components/Card.tsx

This file was deleted.

8 changes: 7 additions & 1 deletion app/components/GenericPlatform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export const GenericPlatform = ({ platFormGroupSpec, platform }: PlatformProps):
}
}
}

// Delete all stamps ...
await handleDeleteStamps(providerIds as PROVIDER_ID[]);

Expand Down Expand Up @@ -272,7 +273,12 @@ export const GenericPlatform = ({ platFormGroupSpec, platform }: PlatformProps):
setLoading(false);
} catch (e) {
datadogLogs.logger.error("Verification Error", { error: e, platform: platform.platformId });
throw e;
doneToast(
"Verification Failed",
"There was an error verifying your stamp. Please try again.",
"../../assets/verification-failed.svg",
platform.platformId as PLATFORM_ID
);
} finally {
setLoading(false);
}
Expand Down
Loading

0 comments on commit 299c58d

Please sign in to comment.