Skip to content

Commit

Permalink
feat: add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
baptou12 committed Aug 17, 2023
1 parent 91329d2 commit f66bd35
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions components/defaultFunnelChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ function findKeysFromData(data) {
}, [])
}

export const DefaultFunnelChart = ({ data }) => {
export const DefaultFunnelChart = ({ data, dataTestid }) => {
const keys = findKeysFromData(data)

return (
<div className="responsive-chart">
<div className="responsive-chart" data-testid={dataTestid}>
<ResponsiveBar
data={data}
indexBy={xAxisKey}
Expand Down
19 changes: 19 additions & 0 deletions cypress/e2e/funnel.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { interceptAidesJeunesStatistics } from "../support/utils.js"

describe("Funnel Page", () => {
beforeEach(() => {
const interceptIdentifier = interceptAidesJeunesStatistics()
cy.visitFromHome("/funnel")
cy.wait(interceptIdentifier)
})

it("displays the menu and title", () => {
cy.checkMenu()
cy.checkTitle()
})

it("displays funnel results chart", () => {
cy.get(".responsive-chart").should("be.visible")
cy.checkGraph("funnel-visits", "Visites", "125821")
})
})
13 changes: 13 additions & 0 deletions cypress/fixtures/aidesJeunesStatistics.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,18 @@
"nothing": 9
}
}
},
"funnel": {
"2023-06": {
"visits": 125821,
"nbUniqVisitors": 97525,
"simulationCount": 25,
"followupWithOptinCount": 16,
"followupWithoutOptinCount": 0,
"followupWithSurveyCount": 2,
"followupWithSurveyRepliedCount": 2,
"showAccompanimentCount": 66,
"clickAccompanimentCount": 37
}
}
}
7 changes: 6 additions & 1 deletion pages/funnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ class Funnel extends Component {
<div className="funnel-charts">
<div className="funnel-chart">
<h2>Visites - Emails Récapitulatifs</h2>
{visitToRecap && <DefaultFunnelChart data={visitToRecap} />}
{visitToRecap && (
<DefaultFunnelChart
data={visitToRecap}
dataTestid="funnel-visits"
/>
)}
</div>

<div className="funnel-chart">
Expand Down

0 comments on commit f66bd35

Please sign in to comment.