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

chore: replace test router with memoryrouter, update partially tests #8102

Merged
merged 35 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
17ffc19
chore: replace test router with memoryrouter, update partially tests
makelicious Nov 28, 2024
2e5f744
fix OfficeHome and ViewRecord test suites
rikukissa Nov 28, 2024
d21d694
WIP
rikukissa Nov 28, 2024
3ebb7c0
fix(tests): fix compile errors. use v6 route instead of history in tests
makelicious Nov 29, 2024
ad169d1
fix(tests): remove commented out code
makelicious Nov 29, 2024
5aaa6b5
fix(tests): add missing license header
makelicious Nov 29, 2024
0f8946d
fix(tests): remove history and use memory router instead on tests
makelicious Dec 2, 2024
3859638
fix: take off warning limit to run tests on CI
makelicious Dec 2, 2024
462b5ee
wip: continue updating router tests
makelicious Dec 2, 2024
e0a1563
update create new user tests
rikukissa Dec 2, 2024
e7feda7
fix: router tests
makelicious Dec 2, 2024
324c1a3
setup App.tsx as a router config object
rikukissa Dec 2, 2024
25d5e2f
Merge branch 'router-testing' of github.com:opencrvs/opencrvs-core in…
rikukissa Dec 2, 2024
912f53e
fix: update previewform tests
makelicious Dec 2, 2024
15799db
fix DeclationFormTest
rikukissa Dec 2, 2024
019b352
Merge branch 'router-testing' of github.com:opencrvs/opencrvs-core in…
rikukissa Dec 2, 2024
acf2845
fix SelectVitalEvent
rikukissa Dec 2, 2024
f9fc0a5
fix ReviewForm tests
rikukissa Dec 2, 2024
4ad904d
fix naming of withRouter
rikukissa Dec 2, 2024
195d4e1
fix(test): render selected path and node instead of routes
makelicious Dec 2, 2024
613dbda
fix: update imports
makelicious Dec 2, 2024
5fcd9ac
fix: fix missing paths and routes
makelicious Dec 2, 2024
3072765
fix two tests
rikukissa Dec 2, 2024
b536d38
Merge branch 'router-testing' of github.com:opencrvs/opencrvs-core in…
rikukissa Dec 2, 2024
1fd82c2
fix: add path to UserList tests
makelicious Dec 2, 2024
40a0126
fix: move dispatches to top on AdvancedSearchResult.test.tsx
makelicious Dec 2, 2024
20765e0
cleanup
rikukissa Dec 2, 2024
aeb1b9e
debug: skip two tests to see CI run
makelicious Dec 2, 2024
d470402
chore: change router hoc name
makelicious Dec 3, 2024
7339728
chore: clean up unused definitions
makelicious Dec 3, 2024
b1dbc54
fix: change collector form route in test
makelicious Dec 3, 2024
f0464eb
fix: flush promises on tests that fail on CI
makelicious Dec 3, 2024
61f76b9
fix: add back missing routes
makelicious Dec 3, 2024
bdd8f7e
fix: revert create new user component refactoring
makelicious Dec 3, 2024
abbef8a
fix: send actions through reducer rather than on component
makelicious Dec 3, 2024
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
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"open:cov": "yarn test && opener coverage/index.html",
"lint": "yarn lint:css && yarn lint:ts",
"lint:css": "stylelint 'src/**/*.{ts,tsx}'",
"lint:ts": "eslint --fix './src/**/*.{ts,tsx}' --max-warnings=349",
"lint:ts": "eslint --fix './src/**/*.{ts,tsx}' --max-warnings=1000",
"test:compilation": "tsc --noEmit",
"extract:translations": "bash extract-translations.sh",
"generate-gateway-types": "NODE_OPTIONS=--dns-result-order=ipv4first graphql-codegen --config codegen.ts && prettier --write src/utils/gateway.ts",
Expand Down
28 changes: 17 additions & 11 deletions packages/client/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ describe('when user has a valid token in url but an expired one in localStorage'
beforeEach(async () => {
getItem.mockReturnValue(expiredToken)
window.history.replaceState('', '', '?token=' + validToken)
await createTestApp()
})

it("doesn't redirect user to SSO", async () => {
await createTestApp()

expect(assign.mock.calls).toHaveLength(0)
})

Expand All @@ -72,7 +73,12 @@ describe('when user has a valid token in url but an expired one in localStorage'

window.history.replaceState({}, '', '?token=' + token)

await createTestApp()
const { app } = await createTestApp(
{ waitUntilOfflineCountryConfigLoaded: false },
['/?token=' + token]
)

app.debug()
expect(assign.mock.calls).toHaveLength(0)
})
})
Expand Down Expand Up @@ -130,36 +136,36 @@ describe('when user has a valid token in local storage', () => {

describe('it handles react errors', () => {
it('displays react error page', async () => {
const { store, history } = createStore()
const { store } = createStore()
function Problem(): JSX.Element {
throw new Error('Error thrown.')
}
const testComponent = await createTestComponent(
const { component } = await createTestComponent(
<StyledErrorBoundary>
<Problem />
</StyledErrorBoundary>,
{ store, history }
{ store }
)

expect(testComponent.find('#GoToHomepage').hostNodes()).toHaveLength(1)
expect(component.find('#GoToHomepage').hostNodes()).toHaveLength(1)
})
})

describe('it handles react unauthorized errors', () => {
it('displays react error page', async () => {
const { store, history } = createStore()
const { store } = createStore()
function Problem(): JSX.Element {
throw new Error('401')
}
const testComponent = await createTestComponent(
const { component } = await createTestComponent(
<StyledErrorBoundary>
<Problem />
</StyledErrorBoundary>,
{ store, history }
{ store }
)

expect(testComponent.find('#GoToHomepage').hostNodes()).toHaveLength(1)
expect(component.find('#GoToHomepage').hostNodes()).toHaveLength(1)

testComponent.find('#GoToHomepage').hostNodes().simulate('click')
component.find('#GoToHomepage').hostNodes().simulate('click')
})
})
Loading
Loading