-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use data attributes to 'sanity-test' the time series charts #99
Changes from 2 commits
8ae603e
422c8f6
4eb01ef
5b5df64
aab00a4
38096e3
7663d11
c90af6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,6 @@ export default defineNuxtConfig({ | |
rApiBase: "", // https://nuxt.com/docs/getting-started/testing#registerendpoint | ||
}, | ||
}, | ||
|
||
compatibilityDate: "2024-12-11", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm mainly adding this in to silence the warning about it that happens on starting up the dev server, on the theory that not doing so causes it to be added dynamically, which possibly triggers a full app re-load on start-up (as updating this config normally does), which would slow down the development experience. Docs: https://nuxt.com/docs/api/nuxt-config#compatibilitydate |
||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Locator } from "playwright/test"; | ||
import type { TimeSeriesDataPoint } from "~/types/dataTypes"; | ||
import { checkValueIsInRange } from "./checkValueIsInRange"; | ||
|
||
export const checkTimeSeriesDataPoints = async ( | ||
locator: Locator, | ||
expectedFirstDataPoint: TimeSeriesDataPoint, | ||
expectedLastDataPoint: TimeSeriesDataPoint, | ||
tolerance = 0.5, | ||
) => { | ||
const dataString = await locator.getAttribute("data-test"); | ||
const data = JSON.parse(dataString!); | ||
|
||
const [firstX, firstY] = data.firstDataPoint; | ||
const [lastX, lastY] = data.lastDataPoint; | ||
|
||
checkValueIsInRange(firstX, expectedFirstDataPoint[0], tolerance); | ||
checkValueIsInRange(firstY, expectedFirstDataPoint[1], tolerance); | ||
checkValueIsInRange(lastX, expectedLastDataPoint[0], tolerance); | ||
checkValueIsInRange(lastY, expectedLastDataPoint[1], tolerance); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { expect } from "@playwright/test"; | ||
|
||
export const checkValueIsInRange = (value: number, expected: number, tolerance: number) => { | ||
expect(value).toBeGreaterThanOrEqual(expected * (1 - tolerance)); | ||
expect(value).toBeLessThanOrEqual(expected * (1 + tolerance)); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type TimeSeriesDataPoint = [number, number]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe call this something a bit less generic -
data-summary
?