Skip to content
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

test: improve dashboard and single-line tests #192

Merged
merged 7 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
"@types/geolib": "^2.0.23",
"@types/leaflet": "^1.7.11",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "^20.8.0",
Expand All @@ -102,7 +101,7 @@
"eslint-plugin-storybook": "^0.6.15",
"jsdom": "^22.1.0",
"openapi-typescript-codegen": "^0.23.0",
"playwright-advanced-har": "^1.0.2",
"playwright-advanced-har": "^1.2.1",
"prettier": "^2.7.1",
"storybook": "^7.5.3",
"vitest": "^0.34.6"
Expand Down
9,816 changes: 9,816 additions & 0 deletions tests/HAR/dashboard.har

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions tests/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import { customMatcher } from 'playwright-advanced-har'
import { test } from './utils'

test('dashboard is on homepage', async ({ page }) => {
test('dashboard is on homepage', async ({ page, advancedRouteFromHAR }) => {
advancedRouteFromHAR('tests/HAR/dashboard.har', {
updateContent: 'embed',
update: false,
notFound: 'abort',
url: /stride-api/,
matcher: customMatcher({
urlComparator(a, b) {
const fieldsToRemove = ['t', 'date_from', 'date_to']
;[a, b] = [a, b].map((url) => {
const urlObj = new URL(url)
fieldsToRemove.forEach((field) => urlObj.searchParams.delete(field))
return urlObj.toString()
})
return a === b
},
}),
})
await page.goto('/')
await page.getByText('לפי שעה').click()
await page.getByText('הקווים הגרועים ביותר').click()
const skeletons = await page.locator('.ant-skeleton').all()
await Promise.all(skeletons.map((skeleton) => skeleton.waitFor({ state: 'hidden' })))
})
11 changes: 11 additions & 0 deletions tests/singlelineTest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test } from './utils'

test('single line', async ({ page }) => {
await page.route('**stride-api**', (route) => route.abort())
await page.route('*.png', (route) => route.abort())
await page.goto('/')
await page.getByText('מפה לפי קו').click()
await page.getByPlaceholder('לדוגמא: 17א').fill('1')
await page.getByLabel('חברה מפעילה').click()
await page.getByRole('option', { name: 'אגד', exact: true }).click()
})
16 changes: 3 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4875,15 +4875,6 @@ __metadata:
languageName: node
linkType: hard

"@types/geolib@npm:^2.0.23":
version: 2.0.23
resolution: "@types/geolib@npm:2.0.23"
dependencies:
geolib: "npm:*"
checksum: aff4a2ec5fed9a8cfbeebf4e658306708e1ef3f82c38959d5496ceb55de75689bb4ad898b4e4751459bba3eea6aef18c99fee223317455e5e706e50e931df771
languageName: node
linkType: hard

"@types/glob@npm:^7.1.3":
version: 7.2.0
resolution: "@types/glob@npm:7.2.0"
Expand Down Expand Up @@ -8678,7 +8669,7 @@ __metadata:
languageName: node
linkType: hard

"geolib@npm:*, geolib@npm:^3.3.3":
"geolib@npm:^3.3.3":
version: 3.3.4
resolution: "geolib@npm:3.3.4"
checksum: 7e18b28c825ad1bd1e4d4166a991659caaf5c779b73818b8dd00c2d6c60b59b208116c22cb1f93830c03571ac498f09586e77173e223bf56615ddace22d8de51
Expand Down Expand Up @@ -11099,7 +11090,6 @@ __metadata:
"@testing-library/jest-dom": "npm:^6.1.3"
"@testing-library/react": "npm:^14.0.0"
"@testing-library/user-event": "npm:^14.5.1"
"@types/geolib": "npm:^2.0.23"
"@types/leaflet": "npm:^1.7.11"
"@types/leaflet.markercluster": "npm:^1.5.2"
"@types/lodash.debounce": "npm:^4.0.7"
Expand Down Expand Up @@ -11131,7 +11121,7 @@ __metadata:
moment-timezone: "npm:^0.5.43"
open-bus-stride-client: "npm:0.1.2"
openapi-typescript-codegen: "npm:^0.23.0"
playwright-advanced-har: "npm:^1.0.2"
playwright-advanced-har: "npm:^1.2.1"
prettier: "npm:^2.7.1"
react: "npm:^18.2.0"
react-dom: "npm:^18.2.0"
Expand Down Expand Up @@ -11499,7 +11489,7 @@ __metadata:
languageName: node
linkType: hard

"playwright-advanced-har@npm:^1.0.2":
"playwright-advanced-har@npm:^1.2.1":
version: 1.2.1
resolution: "playwright-advanced-har@npm:1.2.1"
dependencies:
Expand Down
Loading