-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #567 from ONSdigital/BLAIS5-3956-james
Promote from BLAIS5-3956-james to main
- Loading branch information
Showing
9 changed files
with
125 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Cati dashboard link | ||
|
||
Scenario: Following the Cati dashboard link takes a user to the case info page | ||
Given I access the Telephone Operations Blaise Interface URL | ||
When the link to the CATI dashboard is present | ||
Then it will take me to the CATI dashboard |
71 changes: 71 additions & 0 deletions
71
src/features/step_definitions/CATI_Dashboard_Link.test.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,71 @@ | ||
import React from "react"; | ||
import { defineFeature, loadFeature } from "jest-cucumber"; | ||
import {cleanup, render, screen, waitFor} from "@testing-library/react"; | ||
import { act } from "react-dom/test-utils"; | ||
import { createMemoryHistory } from "history"; | ||
import { Router } from "react-router-dom"; | ||
import flushPromises from "../../tests/utils"; | ||
|
||
|
||
import App from "../../App"; | ||
import {survey_list_with_OPN_and_LMS_with_one_active_instrument_each} from "./API_Mock_Objects"; | ||
import {Survey} from "blaise-api-node-client"; | ||
|
||
const feature = loadFeature( | ||
"./src/features/CATI_Dashboard_Link.feature", | ||
); | ||
|
||
|
||
function mock_server_request(returnedStatus: number, returnedJSON: Survey[]) { | ||
global.fetch = jest.fn(() => | ||
Promise.resolve({ | ||
status: returnedStatus, | ||
json: () => Promise.resolve(returnedJSON), | ||
}) | ||
) as jest.Mock; | ||
} | ||
|
||
defineFeature(feature, test => { | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
cleanup(); | ||
jest.resetModules(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cleanup(); | ||
}); | ||
|
||
|
||
test("Following the Cati dashboard link takes a user to the case info page", ({ given, when, then }) => { | ||
given("I access the Telephone Operations Blaise Interface URL", async () => { | ||
mock_server_request( | ||
200, | ||
survey_list_with_OPN_and_LMS_with_one_active_instrument_each | ||
); | ||
|
||
const history = createMemoryHistory(); | ||
render( | ||
<Router history={history}> | ||
<App/> | ||
</Router> | ||
); | ||
await act(async () => { | ||
await flushPromises(); | ||
}); | ||
}); | ||
|
||
when("the link to the CATI dashboard is present", async () => { | ||
await waitFor(() => { | ||
expect(screen.getByText(/Link to CATI dashboard/i)); | ||
}); | ||
}); | ||
|
||
then("it will take me to the CATI dashboard", async () => { | ||
await waitFor(() => { | ||
expect(screen.getByText(/Link to CATI dashboard/i).getAttribute("href")).toContain("/Blaise/CaseInfo"); | ||
}); | ||
}); | ||
}); | ||
}); |