Skip to content

Commit 469cf18

Browse files
committed
[UGN-353] Fix tests
1 parent a1febaa commit 469cf18

8 files changed

Lines changed: 3108 additions & 3098 deletions

File tree

package-lock.json

Lines changed: 3061 additions & 3057 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@emotion/react": "^11.11.0",
5555
"@emotion/styled": "^11.11.0",
5656
"chakra-react-select": "^4.6.0",
57-
"chakra-ui-steps": "^2.1.0",
57+
"chakra-ui-steps": "2.0.4",
5858
"framer-motion": "^7.0.0",
5959
"js-levenshtein": "1.1.6",
6060
"lodash": "4.17.21",
@@ -70,7 +70,7 @@
7070
"@babel/preset-react": "7.18.6",
7171
"@babel/preset-typescript": "7.21.5",
7272
"@emotion/jest": "11.11.0",
73-
"@jest/types": "29.5.0",
73+
"@jest/types": "27.5.1",
7474
"@storybook/addon-essentials": "7.0.14",
7575
"@storybook/addon-interactions": "7.0.14",
7676
"@storybook/addon-links": "7.0.14",
@@ -83,12 +83,12 @@
8383
"@testing-library/jest-dom": "5.16.5",
8484
"@testing-library/react": "14.0.0",
8585
"@testing-library/user-event": "14.4.3",
86-
"@types/jest": "29.5.1",
86+
"@types/jest": "27.4.1",
8787
"@types/js-levenshtein": "1.1.1",
8888
"@types/react": "18.2.6",
8989
"@types/react-dom": "18.2.4",
9090
"@types/styled-system": "5.1.16",
91-
"@types/uuid": "^9.0.1",
91+
"@types/uuid": "9.0.1",
9292
"@typescript-eslint/eslint-plugin": "5.59.7",
9393
"@typescript-eslint/parser": "5.59.7",
9494
"babel-loader": "9.1.2",
@@ -97,22 +97,25 @@
9797
"eslint-plugin-prettier": "4.2.1",
9898
"eslint-plugin-react": "7.32.2",
9999
"eslint-plugin-react-hooks": "4.6.0",
100-
"jest": "29.5.0",
101-
"jest-watch-typeahead": "2.2.2",
100+
"jest": "27.5.1",
101+
"jest-watch-typeahead": "1.0.0",
102102
"lint-staged": "13.2.2",
103103
"prettier": "2.8.8",
104104
"prop-types": "15.8.1",
105105
"react": "18.2.0",
106106
"react-dom": "18.2.0",
107107
"react-select-event": "5.5.1",
108-
"rollup": "3.23.0",
109-
"rollup-plugin-typescript2": "0.34.1",
108+
"rollup": "2.70.1",
109+
"rollup-plugin-typescript2": "0.31.2",
110110
"storybook": "7.0.14",
111111
"ts-essentials": "9.3.2",
112-
"ts-jest": "29.1.0",
112+
"ts-jest": "27.1.4",
113113
"ttypescript": "1.5.15",
114-
"typescript": "5.0.4",
115-
"typescript-transform-paths": "^3.4.6"
114+
"typescript": "4.9.5",
115+
"typescript-transform-paths": "3.4.6"
116+
},
117+
"overrides": {
118+
"nwsapi": "2.2.2"
116119
},
117120
"lint-staged": {
118121
"*.{ts,tsx}": "eslint",
@@ -131,38 +134,33 @@
131134
"ts",
132135
"tsx",
133136
"js",
134-
"jsx"
137+
"jsx",
138+
"mjs"
135139
],
136140
"transform": {
137-
"^.+\\.(ts|tsx)?$": "ts-jest/dist"
141+
"^.+\\.(ts|tsx)?$": "ts-jest/dist",
142+
"^.+\\.mjs$": "ts-jest/dist"
138143
},
139144
"moduleNameMapper": {
140145
"~/(.*)": "<rootDir>/src/$1"
141146
},
142147
"transformIgnorePatterns": [
143-
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
148+
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
144149
],
145150
"setupFiles": [
146151
"./src/tests/setup.ts"
147152
],
148153
"setupFilesAfterEnv": [
149154
"@testing-library/jest-dom/extend-expect"
150155
],
156+
"globals": {
157+
"ts-jest": {
158+
"tsconfig": "tsconfig.json"
159+
}
160+
},
151161
"watchPlugins": [
152162
"jest-watch-typeahead/filename",
153163
"jest-watch-typeahead/testname"
154-
],
155-
"browserslist": {
156-
"production": [
157-
">0.2%",
158-
"not dead",
159-
"not op_mini all"
160-
],
161-
"development": [
162-
">0.2%",
163-
"not dead",
164-
"not op_mini all"
165-
]
166-
}
164+
]
167165
}
168166
}

src/steps/MatchColumnsStep/components/MatchIcon.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type MatchIconProps = {
2020
export const MatchIcon = (props: MatchIconProps) => {
2121
const style = useStyleConfig("MatchIcon", props)
2222

23-
console.log(props.isChecked)
2423
return (
2524
<chakra.div
2625
__css={style}

src/steps/MatchColumnsStep/tests/MatchColumnsStep.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ describe("Match Columns general tests", () => {
582582
container: document.getElementById(SELECT_DROPDOWN_ID)!,
583583
})
584584

585-
expect(screen.queryByText(translations.matchColumnsStep.duplicateColumnWarningDescription)).toBeInTheDocument()
585+
const toasts = await screen.queryAllByText(translations.matchColumnsStep.duplicateColumnWarningDescription)
586+
587+
expect(toasts?.[0]).toBeInTheDocument()
586588
})
587589

588590
test("matchColumnsStepHook should be called after columns are matched", async () => {
@@ -676,7 +678,7 @@ describe("Match Columns general tests", () => {
676678
const continueButton = screen.getByText(CONTINUE_BUTTON)
677679
await userEvent.click(continueButton)
678680

679-
const errorToast = await screen.findByText(ERROR_MESSAGE, undefined, { timeout: 5000 })
680-
expect(errorToast).toBeInTheDocument()
681+
const errorToast = await screen.findAllByText(ERROR_MESSAGE, undefined, { timeout: 5000 })
682+
expect(errorToast?.[0]).toBeInTheDocument()
681683
})
682684
})

src/steps/SelectHeaderStep/tests/SelectHeaderStep.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,9 @@ describe("Select header step tests", () => {
132132
)
133133
const continueButton = screen.getByText(CONTINUE_BUTTON)
134134
await userEvent.click(continueButton)
135-
const errorToast = await screen.getByText(ERROR_MESSAGE)
136135

137-
await waitFor(() => {
138-
expect(errorToast).toBeInTheDocument()
139-
})
136+
const errorToast = await screen.findAllByText(ERROR_MESSAGE, undefined, { timeout: 5000 })
137+
expect(errorToast?.[0]).toBeInTheDocument()
140138
})
141139

142140
test("dateFormat property should NOT be applied to dates read from csv files IF parseRaw=true", async () => {

src/steps/SelectSheetStep/tests/SelectSheetStep.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ test("Should show error toast if error is thrown in uploadStepHook", async () =>
113113

114114
await userEvent.click(nextButton)
115115

116-
const errorToast = await screen.findByText(ERROR_MESSAGE, undefined, { timeout: 5000 })
117-
expect(errorToast).toBeInTheDocument()
116+
const errorToast = await screen.findAllByText(ERROR_MESSAGE, undefined, { timeout: 5000 })
117+
expect(errorToast?.[0]).toBeInTheDocument()
118118
})

src/steps/UploadStep/tests/UploadStep.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Providers } from "../../../components/Providers"
77
import { ModalWrapper } from "../../../components/ModalWrapper"
88

99
const MUTATED_RAW_DATA = "Bye"
10-
const ERROR_MESSAGE = "Something happened"
10+
const ERROR_MESSAGE = "Something happened while uploading"
1111

1212
test("Upload a file", async () => {
1313
const file = new File(["Hello, Hello, Hello, Hello"], "test.csv", { type: "text/csv" })
@@ -81,6 +81,6 @@ test("Should show error toast if error is thrown in uploadStepHook", async () =>
8181
target: { files: [file] },
8282
})
8383

84-
const errorToast = await screen.findByText(ERROR_MESSAGE, undefined, { timeout: 5000 })
85-
expect(errorToast).toBeInTheDocument()
84+
const errorToast = await screen.findAllByText(ERROR_MESSAGE, undefined, { timeout: 5000 })
85+
expect(errorToast?.[0]).toBeInTheDocument()
8686
})

src/stories/Default.stories.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ export const Basic = () => {
2222
<Link href="./exampleFile.csv" border="2px solid #718096" p="8px" borderRadius="8px" download="exampleCSV">
2323
Download example file
2424
</Link>
25-
<ReactSpreadsheetImport {...mockRsiValues} isOpen={isOpen} onClose={onClose} onSubmit={setData} />
25+
<ReactSpreadsheetImport
26+
{...mockRsiValues}
27+
isOpen={isOpen}
28+
onClose={onClose}
29+
onSubmit={setData}
30+
uploadStepHook={async () => {
31+
throw new Error("Hello")
32+
return undefined as any
33+
}}
34+
/>
2635
{!!data && (
2736
<Box pt={64} display="flex" gap="8px" flexDirection="column">
2837
<b>Returned data (showing first 100 rows):</b>

0 commit comments

Comments
 (0)