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 5 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 @@ -84,7 +84,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 @@ -101,7 +100,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()
})
28 changes: 18 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3263,12 +3263,20 @@
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.12.tgz#0307536218d32e6b970bccd1d148b9c4e5b6f10d"
integrity sha512-uK2z1ZHJyC0nQRbuovXFt4mzXDwf27vQeUWNhfKGwRcWW429GOhP8HxUHlM6TLH4bzmlv/HlEjpvJh3JfmGsAA==

"@types/geolib@^2.0.23":
version "2.0.23"
resolved "https://registry.yarnpkg.com/@types/geolib/-/geolib-2.0.23.tgz#83aa8d2772f3898daec211eac176583bd466b418"
integrity sha512-afIUEoDag0RdcaeQ965SlGRZA361Ngz2OthkkxAVMlvYPVn/5wm/9dYl5yPXteTyjSYxkhKUhWdFyJdVG87hJg==
"@types/glob@^7.1.3":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
dependencies:
geolib "*"
"@types/minimatch" "*"
"@types/node" "*"

"@types/graceful-fs@^4.1.3":
version "4.1.9"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4"
integrity sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==
dependencies:
"@types/node" "*"

"@types/glob@^7.1.3":
version "7.2.0"
Expand Down Expand Up @@ -6043,7 +6051,7 @@ gensync@^1.0.0-beta.2:
resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==

geolib@*, geolib@^3.3.3:
geolib@^3.3.3:
version "3.3.4"
resolved "https://registry.yarnpkg.com/geolib/-/geolib-3.3.4.tgz#09883ba2fdab84d2764cf3615dbafb9bce3c54d0"
integrity sha512-EicrlLLL3S42gE9/wde+11uiaYAaeSVDwCUIv2uMIoRBfNJCn8EsSI+6nS3r4TCKDO6+RQNM9ayLq2at+oZQWQ==
Expand Down Expand Up @@ -7997,10 +8005,10 @@ pkg-types@^1.0.3:
mlly "^1.2.0"
pathe "^1.1.0"

playwright-advanced-har@^1.0.2:
version "1.0.6"
resolved "https://registry.yarnpkg.com/playwright-advanced-har/-/playwright-advanced-har-1.0.6.tgz#82fda6842f277a1a04187cd09f826f803f5f1184"
integrity sha512-XJTQYeZTuMezLRjzrEVPXt813wmByYvgoBlbOCb87OlXvC5TXHTFKqRJ6EP1EA1UPcKhwdouv86vUGhSevSrBw==
playwright-advanced-har@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/playwright-advanced-har/-/playwright-advanced-har-1.2.1.tgz#3c25a606c0706a8020f15b4362f27e0f98252291"
integrity sha512-807gAUUnYK7QIcm7GzPiKtz81ziYy13YA9cvtvOE8cduEd65xGKJCcIBwRnJABpPlr19OJQZqicZJk1b5mqDhA==
dependencies:
"@types/har-format" "^1.2.14"

Expand Down
Loading