From ac51e8e8c547b10a5f5c105898cf5a4bfd174032 Mon Sep 17 00:00:00 2001 From: Prosvirin Vladimir Date: Tue, 30 Sep 2025 23:43:43 +0300 Subject: [PATCH] Delete testing toolkit --- .github/workflows/build_test_lint.yml | 1 - apps/smart-forms-app/package.json | 1 - package-lock.json | 31 +-- packages/testing-toolkit/.gitignore | 5 - packages/testing-toolkit/package.json | 29 --- packages/testing-toolkit/src/index.ts | 245 --------------------- packages/testing-toolkit/src/vite-env.d.ts | 27 --- packages/testing-toolkit/tsconfig.json | 22 -- packages/testing-toolkit/vite.config.ts | 28 --- 9 files changed, 10 insertions(+), 379 deletions(-) delete mode 100644 packages/testing-toolkit/.gitignore delete mode 100644 packages/testing-toolkit/package.json delete mode 100644 packages/testing-toolkit/src/index.ts delete mode 100644 packages/testing-toolkit/src/vite-env.d.ts delete mode 100644 packages/testing-toolkit/tsconfig.json delete mode 100644 packages/testing-toolkit/vite.config.ts diff --git a/.github/workflows/build_test_lint.yml b/.github/workflows/build_test_lint.yml index ef1065150..1495888f5 100644 --- a/.github/workflows/build_test_lint.yml +++ b/.github/workflows/build_test_lint.yml @@ -153,7 +153,6 @@ jobs: - name: Build workspace packages run: | npm run build -w packages/sdc-populate - npm run build -w packages/testing-toolkit - name: Install Playwright browsers run: npx playwright install --with-deps diff --git a/apps/smart-forms-app/package.json b/apps/smart-forms-app/package.json index cb51064fd..574ce2f7a 100644 --- a/apps/smart-forms-app/package.json +++ b/apps/smart-forms-app/package.json @@ -28,7 +28,6 @@ "@aehrc/sdc-populate": "^4.6.2", "@aehrc/sdc-template-extract": "^1.0.9", "@aehrc/smart-forms-renderer": "^1.0.0-alpha.107", - "@aehrc/testing-toolkit": "^1.0.0", "@dnd-kit/core": "^6.3.1", "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", diff --git a/package-lock.json b/package-lock.json index fae05c761..dff1c1d1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,6 @@ "@aehrc/sdc-populate": "^4.6.2", "@aehrc/sdc-template-extract": "^1.0.9", "@aehrc/smart-forms-renderer": "^1.0.0-alpha.107", - "@aehrc/testing-toolkit": "^1.0.0", "@dnd-kit/core": "^6.3.1", "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", @@ -1071,10 +1070,6 @@ "resolved": "packages/smart-forms-renderer", "link": true }, - "node_modules/@aehrc/testing-toolkit": { - "resolved": "packages/testing-toolkit", - "link": true - }, "node_modules/@algolia/abtesting": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@algolia/abtesting/-/abtesting-1.3.0.tgz", @@ -12118,6 +12113,7 @@ "version": "10.4.0", "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", + "dev": true, "peer": true, "dependencies": { "@babel/code-frame": "^7.10.4", @@ -12163,6 +12159,7 @@ "version": "16.3.0", "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.0.tgz", "integrity": "sha512-kFSyxiEDwv1WLl2fgsq6pPBbw5aWKrsY2/noi1Id0TK0UParSF62oFQFGHXIyaG4pp2tEub/Zlel+fjjZILDsw==", + "dev": true, "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5" @@ -12244,6 +12241,7 @@ "version": "5.0.4", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "dev": true, "peer": true }, "node_modules/@types/babel__core": { @@ -12797,7 +12795,7 @@ "version": "18.3.7", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz", "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==", - "devOptional": true, + "dev": true, "license": "MIT", "peerDependencies": { "@types/react": "^18.0.0" @@ -14143,6 +14141,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "dev": true, "dependencies": { "dequal": "^2.0.3" } @@ -18018,6 +18017,7 @@ "version": "0.5.16", "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "dev": true, "peer": true }, "node_modules/dom-converter": { @@ -25598,6 +25598,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "dev": true, "peer": true, "bin": { "lz-string": "bin/bin.js" @@ -32135,6 +32136,7 @@ "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "dev": true, "peer": true, "dependencies": { "ansi-regex": "^5.0.1", @@ -32149,6 +32151,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, "peer": true, "engines": { "node": ">=10" @@ -32161,6 +32164,7 @@ "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "dev": true, "peer": true }, "node_modules/pretty-time": { @@ -41210,21 +41214,6 @@ "url": "https://opencollective.com/unified" } }, - "packages/testing-toolkit": { - "name": "@aehrc/testing-toolkit", - "version": "1.0.0", - "license": "Apache-2.0", - "dependencies": { - "@testing-library/react": "^16.3.0" - }, - "devDependencies": { - "zustand": "^5.0.8" - }, - "peerDependencies": { - "react": "^18.0.0 || ^19.0.0", - "react-dom": "^18.0.0 || ^19.0.0" - } - }, "services/assemble-express": { "version": "2.0.0", "license": "Apache-2.0", diff --git a/packages/testing-toolkit/.gitignore b/packages/testing-toolkit/.gitignore deleted file mode 100644 index 945ef5a39..000000000 --- a/packages/testing-toolkit/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules -lib -dist -temp - diff --git a/packages/testing-toolkit/package.json b/packages/testing-toolkit/package.json deleted file mode 100644 index eb7132831..000000000 --- a/packages/testing-toolkit/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "@aehrc/testing-toolkit", - "version": "1.0.0", - "description": "Testing toolkit for Smart Forms", - "main": "lib/index.js", - "scripts": { - "compile": "tsc", - "watch": "tsc -w", - "build": "npm run compile", - "test": "jest", - "test:watch": "jest --watch", - "storybook": "storybook dev -p 6006", - "storybook-watch": "concurrently -n \"STORYBOOK,TSC\" -c \"cyan.bold,green.bold\" \"storybook dev -p 6006\" \"tsc -w\"", - "build-storybook": "storybook build", - "chromatic": "chromatic --exit-zero-on-changes" - }, - "license": "Apache-2.0", - "homepage": "https://github.com/aehrc/smart-forms#readme", - "dependencies": { - "@testing-library/react": "^16.3.0" - }, - "peerDependencies": { - "react": "^18.0.0 || ^19.0.0", - "react-dom": "^18.0.0 || ^19.0.0" - }, - "devDependencies": { - "zustand": "^5.0.8" - } -} diff --git a/packages/testing-toolkit/src/index.ts b/packages/testing-toolkit/src/index.ts deleted file mode 100644 index adf1f8078..000000000 --- a/packages/testing-toolkit/src/index.ts +++ /dev/null @@ -1,245 +0,0 @@ -import { fireEvent, screen, waitFor } from '@testing-library/react'; -import { userEvent } from '@testing-library/user-event'; - -export async function inputText( - canvasElement: HTMLElement, - linkId: string, - text: string | boolean | number -) { - const questionElement = await findByLinkId(canvasElement, linkId); - - const input = - questionElement?.querySelector('input') ?? questionElement?.querySelector('textarea'); - - if (!input) { - throw new Error(`Input or textarea was not found inside ${`[data-linkid=${linkId}] block`}`); - } - - fireEvent.change(input, { target: { value: text } }); - - // Here we await for debounced store update - await new Promise((resolve) => setTimeout(resolve, 500)); -} -export async function checkCheckBox(canvasElement: HTMLElement, linkId: string) { - const questionElement = await findByLinkId(canvasElement, linkId); - const input = - questionElement?.querySelector('input') ?? questionElement?.querySelector('textarea'); - - if (!input) { - throw new Error(`Input or textarea was not found inside ${`[data-linkid=${linkId}] block`}`); - } - - fireEvent.click(input); - - // Here we await for debounced store update - await new Promise((resolve) => setTimeout(resolve, 500)); -} - -export async function inputFile( - canvasElement: HTMLElement, - linkId: string, - files: File | File[], - url: string, - filename: string -) { - const questionElement = await findByLinkId(canvasElement, linkId); - const input = questionElement?.querySelector('input'); - - const textareaUrl = questionElement?.querySelector(`textarea[data-test="q-item-attachment-url"]`); - const textareaName = questionElement?.querySelector( - `textarea[data-test="q-item-attachment-file-name"]` - ); - - if (!input) { - throw new Error(`File input was not found inside [data-linkid=${linkId}] block`); - } - if (!textareaUrl) { - throw new Error(`File input was not found inside [data-linkid="URL"] block`); - } - if (!textareaName) { - throw new Error(`File input was not found inside [data-linkid="File name (optional)"] block`); - } - - const fileList = Array.isArray(files) ? files : [files]; - await userEvent.upload(input, fileList); - - fireEvent.change(textareaUrl, { target: { value: url } }); - fireEvent.change(textareaName, { target: { value: filename } }); - // Here we await for debounced store update - await new Promise((resolve) => setTimeout(resolve, 500)); -} - -export async function inputDate( - canvasElement: HTMLElement, - linkId: string, - text: string | boolean -) { - return await inputText(canvasElement, linkId, text); -} - -export async function inputTime( - canvasElement: HTMLElement, - linkId: string, - text: string | boolean -) { - return await inputText(canvasElement, linkId, text); -} - -export async function inputReference( - canvasElement: HTMLElement, - linkId: string, - text: string | boolean -) { - return await inputText(canvasElement, linkId, text); -} - -export async function inputDecimal(canvasElement: HTMLElement, linkId: string, text: number) { - return await inputText(canvasElement, linkId, text); -} - -export async function inputUrl(canvasElement: HTMLElement, linkId: string, text: string) { - return await inputText(canvasElement, linkId, text); -} - -export async function inputInteger(canvasElement: HTMLElement, linkId: string, text: number) { - return await inputText(canvasElement, linkId, text); -} - -export async function inputDateTime( - canvasElement: HTMLElement, - linkId: string, - date: string, - time: string, - amPm: string -) { - const questionElement = await findByLinkId(canvasElement, linkId); - console.log(questionElement, 777); - const inputDate = questionElement?.querySelector('div[data-test="date"] input'); - const inputTime = questionElement?.querySelector('div[data-test="time"] input'); - const inputAmPm = questionElement?.querySelector('div[data-test="ampm"] input'); - - if (!inputTime) { - throw new Error(`Input or textarea was not found inside ${`[data-linkid=${linkId}] block`}`); - } - if (!inputDate) { - throw new Error(`Input or textarea was not found inside ${`[data-linkid=${linkId}] block`}`); - } - if (!inputAmPm) { - throw new Error(`Input or textarea was not found inside ${`[data-linkid=${linkId}] block`}`); - } - - fireEvent.change(inputDate, { target: { value: date } }); - fireEvent.change(inputTime, { target: { value: time } }); - fireEvent.change(inputAmPm, { target: { value: amPm } }); - - // Here we await for debounced store update - await new Promise((resolve) => setTimeout(resolve, 500)); -} - -export async function checkRadioOption(canvasElement: HTMLElement, linkId: string, text: string) { - const questionElement = await findByLinkId(canvasElement, linkId); - const radio = questionElement?.querySelector(`span[data-test="radio-single-${text}"] input`); - - if (!radio) { - throw new Error(`Input or textarea was not found inside ${`[data-linkid=${linkId}] block`}`); - } - - fireEvent.click(radio); - // Here we await for debounced store update - await new Promise((resolve) => setTimeout(resolve, 500)); -} - -export async function getInputText(canvasElement: HTMLElement, linkId: string) { - const questionElement = await findByLinkId(canvasElement, linkId); - const input = - questionElement?.querySelector('input') ?? questionElement?.querySelector('textarea'); - - if (!input) { - throw new Error(`Input or textarea was not found inside ${`[data-linkid=${linkId}] block`}`); - } - - return input.value; -} - -export async function chooseSelectOption( - canvasElement: HTMLElement, - linkId: string, - optionLabel: string -) { - const questionElement = await findByLinkId(canvasElement, linkId); - - const input = questionElement.querySelector('input, textarea'); - if (!input) { - throw new Error(`There is no input inside ${linkId}`); - } - - fireEvent.focus(input); - fireEvent.keyDown(input, { key: 'ArrowDown', code: 'ArrowDown' }); - - const option = await screen.findByText(optionLabel); - fireEvent.click(option); -} -export async function chooseQuantityOption( - canvasElement: HTMLElement, - linkId: string, - quantity: number | string, - quantityComparator?: string -) { - const questionElement = await findByLinkId(canvasElement, linkId); - - const inputComaparator = questionElement.querySelector( - 'div[data-test=""q-item-quantity-comparator""] input' - ); - const inputWeight = questionElement.querySelector('div[data-test="q-item-quantity-field"] input'); - - if (!inputComaparator) { - throw new Error(`There is no input inside ${linkId}`); - } - if (!inputWeight) { - throw new Error(`There is no input inside ${linkId}`); - } - - fireEvent.focus(inputComaparator); - fireEvent.keyDown(inputComaparator, { key: 'ArrowDown', code: 'ArrowDown' }); - - if (quantityComparator) { - const option = await screen.findByText(quantityComparator); - fireEvent.click(option); - fireEvent.change(inputComaparator, { target: { value: quantityComparator } }); - } - - fireEvent.change(inputWeight, { target: { value: quantity } }); - // Here we await for debounced store update - await new Promise((resolve) => setTimeout(resolve, 500)); -} - -export async function findByLinkId(canvasElement: HTMLElement, linkId: string) { - const selector = `[data-linkid="${linkId}"]`; - return await waitFor(() => { - const el = canvasElement.querySelector(selector); - if (!el) { - throw new Error(`Element ${selector} not found`); - } - return el; - }); -} -export async function inputOpenChoiceOtherText( - canvasElement: HTMLElement, - linkId: string, - text: string -) { - const questionElement = await findByLinkId(canvasElement, linkId); - - const textarea = questionElement?.querySelector( - 'div[data-test="q-item-radio-open-label-box"] textarea' - ); - - if (!textarea) { - throw new Error(`Input or textarea was not found inside ${`[data-test=${linkId}] block`}`); - } - - fireEvent.change(textarea, { target: { value: text } }); - - // Here we await for debounced store update - await new Promise((resolve) => setTimeout(resolve, 500)); -} diff --git a/packages/testing-toolkit/src/vite-env.d.ts b/packages/testing-toolkit/src/vite-env.d.ts deleted file mode 100644 index 9921b7f24..000000000 --- a/packages/testing-toolkit/src/vite-env.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2023 Commonwealth Scientific and Industrial Research - * Organisation (CSIRO) ABN 41 687 119 230. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/// -// Vite is only used for Storybook - -interface ImportMetaEnv { - readonly VITE_RENDERER_VERSION: string; -} - -interface ImportMeta { - readonly env: ImportMetaEnv; -} diff --git a/packages/testing-toolkit/tsconfig.json b/packages/testing-toolkit/tsconfig.json deleted file mode 100644 index 7508ed78e..000000000 --- a/packages/testing-toolkit/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "target": "ES6", - "module": "ES6", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "moduleResolution": "node", - "forceConsistentCasingInFileNames": true, - "useUnknownInCatchVariables": false, - "strict": true, - "skipLibCheck": true, - "jsx": "react-jsx", - "sourceMap": true, - "allowJs": true, - "outDir": "lib", - "declaration": true, - "checkJs": true, - "resolveJsonModule": true - }, - "include": ["src"], - "exclude": ["lib", "dist"] -} diff --git a/packages/testing-toolkit/vite.config.ts b/packages/testing-toolkit/vite.config.ts deleted file mode 100644 index bf414cad3..000000000 --- a/packages/testing-toolkit/vite.config.ts +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2025 Commonwealth Scientific and Industrial Research - * Organisation (CSIRO) ABN 41 687 119 230. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { defineConfig } from 'vite'; -// @ts-ignore -import { version } from './package.json'; - -// This Vite config is for storybook usage only. -// https://vitejs.dev/config/ -export default defineConfig({ - define: { - 'import.meta.env.VITE_RENDERER_VERSION': JSON.stringify(version ?? 'unspecified') - } -});