Skip to content

Commit

Permalink
Merge pull request #309 from bcgov/Dependabot/frontend/AIR-290
Browse files Browse the repository at this point in the history
Dependabot/frontend/air 290
  • Loading branch information
TayGov authored Feb 15, 2023
2 parents e86022c + 4e42fd4 commit 1c7a3f5
Show file tree
Hide file tree
Showing 5 changed files with 5,350 additions and 6,699 deletions.
1 change: 1 addition & 0 deletions src/frontend/ai-reviewer-admin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
"react/jsx-curly-brace-presence": "off",
"react/jsx-filename-extension": "off",
"react/jsx-wrap-multilines": "off",
"react/prop-types": "off"
},
settings: {
react: {
Expand Down
8 changes: 6 additions & 2 deletions src/frontend/ai-reviewer-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react-dom": "^17.0.2",
"react-dropzone": "^11.3.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-scripts": "5.0.1",
"shared-components": "https://github.com/bcgov/react-shared-components/releases/download/v1.2.3/shared-components-1.2.3.tgz",
"web-vitals": "^1.1.2"
},
Expand Down Expand Up @@ -61,5 +61,9 @@
"!src/**/test-data.js",
"!src/domain/authentication/*.js"
]
}
},
"resolutions": {
"minimatch":"^3.0.5",
"json5": "^2.2.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,24 @@ function SimulateTransaction() {

const submitDocument = () => {
submitFileForExtraction(files[0], transactionId)
.then((res) => {
setShowLoader(true);
setTimeout(() => {
getProcessedDocument(
res.document.documentId,
res.extract.transactionId
)
.then((res) => {
setShowProcessedToast(true);
setShowLoader(false);
})
.catch((err) => {
showError(err.message);
setShowLoader(false);
});
}, 5000);
})
.catch((err) => showError(err.message));
.then((res) => {
setShowLoader(true);
setTimeout(() => {
getProcessedDocument(
res.document.documentId,
res.extract.transactionId
)
.then((res) => {
setShowProcessedToast(true);
setShowLoader(false);
})
.catch((err) => {
showError(err.message);
setShowLoader(false);
});
}, 100);
})
.catch((err) => showError(err.message));
};

const generateDisplayBoxElement = (file) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,25 @@ describe("Simulate Transaction Test Suite", () => {
expect(getByText("fakeFile.pdf")).toBeInTheDocument();
});

test("Get Document Types - failure", async () => {
mockApi.onGet("/documentTypeConfigurations").reply(400);
const { container, getByText } = render(<SimulateTransaction />);
const dropzone = container.querySelector('[data-testid="dropdownzone"]');

dispatchEvt(dropzone, "drop", data);
await waitFor(() => {
getByText("Error: Could not load configurations.");
});

expect(
getByText("Error: Could not load configurations.")
).toBeInTheDocument();
});

test("Submit file for extraction - success", async () => {
mockApi.onGet("/documentTypeConfigurations").reply(200, configurations);
mockApi.onPost("/documents/extract").reply(200, resolveExtract);
mockApi.onGet("/documents/processed/1234").reply(200, resolveProcessed);
setTimeout = jest.fn();
test("Get Document Types - failure", async () => {
mockApi.onGet("/documentTypeConfigurations").reply(400);
const { container, getByText } = render(<SimulateTransaction />);
const dropzone = container.querySelector('[data-testid="dropdownzone"]');

dispatchEvt(dropzone, "drop", data);
await waitFor(() => {
getByText("Error: Could not load configurations.");
});

expect(
getByText("Error: Could not load configurations.")
).toBeInTheDocument();
});

test("Submit file for extraction - success", async () => {
mockApi.onGet("/documentTypeConfigurations").reply(200, configurations);
mockApi.onPost("/documents/extract").reply(200, resolveExtract);
mockApi.onGet("/documents/processed/1234").reply(200, resolveProcessed);

const { container, getByText, getByTestId } = render(
<SimulateTransaction />
Expand All @@ -144,11 +143,10 @@ describe("Simulate Transaction Test Suite", () => {
expect(getByText("Document Processed Successfuly")).toBeInTheDocument();
});

test("Submit file for extraction - failure", async () => {
test("Submit file for extraction - failure", async () => {
mockApi.onGet("/documentTypeConfigurations").reply(200, configurations);
mockApi.onPost("/documents/extract").reply(400);
mockApi.onGet("/documents/processed/1234").reply(200, resolveProcessed);
setTimeout = jest.fn();

const { container, getByText, getByTestId, queryByText } = render(
<SimulateTransaction />
Expand Down Expand Up @@ -176,7 +174,7 @@ describe("Simulate Transaction Test Suite", () => {
test("Get Processed Document - failure", async () => {
mockApi.onGet("/documentTypeConfigurations").reply(200, configurations);
mockApi.onPost("/documents/extract").reply(200, resolveExtract);
mockApi.onGet("/documents/processed/1234").reply(400, {error: {message: "error"}});
mockApi.onGet("/documents/processed/1234").reply(404, {error: {message: "error"}});

const { container, getByText, getByTestId, queryByText } = render(
<SimulateTransaction />
Expand All @@ -194,7 +192,7 @@ describe("Simulate Transaction Test Suite", () => {

const button = getByText("Submit");
fireEvent.click(button);
await waitFor(() => {getByText("Request failed with status code 400")})
await waitFor(() => {getByText("Request failed with status code 404")})

expect(
queryByText("Document Processed Successfuly")
Expand Down
Loading

0 comments on commit 1c7a3f5

Please sign in to comment.