-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feature) Show message on UI when report was cleaned up
- Loading branch information
Showing
16 changed files
with
258 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
ui/src/TestResults/__tests__/TestResultsProcessingCheck.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import "@testing-library/jest-dom/extend-expect"; | ||
import React from "react"; | ||
import { render, waitFor } from "@testing-library/react"; | ||
import { axiosInstanceWithoutCache } from "../../service/AxiosService"; | ||
import MockAdapter from "axios-mock-adapter"; | ||
import { | ||
TestResultsProcessing, | ||
TestResultsProcessingStatus, | ||
} from "../../model/TestRunModel"; | ||
import TestResultsProcessingCheck from "../TestResultsProcessingCheck"; | ||
|
||
describe("TestResultsProcessingCheck", () => { | ||
let mockAxios; | ||
|
||
const publicId = "12345"; | ||
|
||
beforeEach(() => { | ||
// @ts-ignore | ||
mockAxios = new MockAdapter(axiosInstanceWithoutCache); | ||
}); | ||
|
||
afterEach(() => { | ||
mockAxios.restore(); | ||
}); | ||
|
||
const mockProcessingStatus = (status: TestResultsProcessingStatus) => { | ||
const processingStatus = { | ||
id: publicId, | ||
status, | ||
} as TestResultsProcessing; | ||
|
||
mockAxios | ||
.onGet(`http://localhost:8080/results/${publicId}/status`) | ||
.reply(200, processingStatus); | ||
}; | ||
|
||
it("should display message when results still processing", async () => { | ||
const succeededFunc = jest.fn(); | ||
|
||
mockProcessingStatus(TestResultsProcessingStatus.PROCESSING); | ||
|
||
const { findByTestId } = render( | ||
<TestResultsProcessingCheck | ||
publicId={publicId} | ||
processingSucceeded={succeededFunc} | ||
refreshInterval={5000} | ||
/> | ||
); | ||
|
||
await findByTestId("results-still-processing"); | ||
|
||
expect(succeededFunc).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should display failure message when results processing failed", async () => { | ||
const succeededFunc = jest.fn(); | ||
|
||
mockProcessingStatus(TestResultsProcessingStatus.ERROR); | ||
|
||
const { findByTestId } = render( | ||
<TestResultsProcessingCheck | ||
publicId={publicId} | ||
processingSucceeded={succeededFunc} | ||
refreshInterval={5000} | ||
/> | ||
); | ||
|
||
await findByTestId("results-processing-failed"); | ||
|
||
expect(succeededFunc).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should display message when results were deleted", async () => { | ||
const succeededFunc = jest.fn(); | ||
|
||
mockProcessingStatus(TestResultsProcessingStatus.DELETED); | ||
|
||
const { findByTestId } = render( | ||
<TestResultsProcessingCheck | ||
publicId={publicId} | ||
processingSucceeded={succeededFunc} | ||
refreshInterval={5000} | ||
/> | ||
); | ||
|
||
await findByTestId("results-deleted"); | ||
|
||
expect(succeededFunc).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should call success function when results successfully processed", async () => { | ||
const succeededFunc = jest.fn(); | ||
|
||
mockProcessingStatus(TestResultsProcessingStatus.SUCCESS); | ||
|
||
render( | ||
<TestResultsProcessingCheck | ||
publicId={publicId} | ||
processingSucceeded={succeededFunc} | ||
refreshInterval={5000} | ||
/> | ||
); | ||
|
||
await waitFor(() => expect(succeededFunc).toHaveBeenCalled()); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.