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: unit test cases changes #1353

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
42fdd7a
added test cases setup chnages and added test cases
Rohini-Microsoft Sep 24, 2024
ee3523d
removed node-fetch
Rohini-Microsoft Sep 24, 2024
282dc68
Added test cases for NoPage Component
Kiran-Siluveru-Microsoft Sep 25, 2024
6bf0846
setup files changes added
Rohini-Microsoft Sep 25, 2024
630ab3e
setup changes added
Rohini-Microsoft Sep 25, 2024
53193fc
updated docker file
Rohini-Microsoft Sep 25, 2024
ed5e7e9
added changes in docker
Rohini-Microsoft Sep 25, 2024
220e232
added package.lock
Rohini-Microsoft Sep 25, 2024
013ef6c
changed docker file
Rohini-Microsoft Sep 25, 2024
ceb56ad
changed docker file
Rohini-Microsoft Sep 25, 2024
b18bfbf
added changes
Rohini-Microsoft Sep 25, 2024
229602a
added changes docker
Rohini-Microsoft Sep 25, 2024
66e1b61
added changes
Rohini-Microsoft Sep 25, 2024
6d81539
changes added
Rohini-Microsoft Sep 25, 2024
8b14486
added changes
Rohini-Microsoft Sep 25, 2024
fd30319
reverted docker changes
Rohini-Microsoft Sep 25, 2024
a67fc66
reverted changes
Rohini-Microsoft Sep 25, 2024
7bf3e88
reverted changes
Rohini-Microsoft Sep 25, 2024
299f9ff
reverted changes
Rohini-Microsoft Sep 25, 2024
deaa400
reverted
Rohini-Microsoft Sep 25, 2024
e68ad13
updated
Rohini-Microsoft Sep 25, 2024
befc881
reverted
Rohini-Microsoft Sep 25, 2024
537b508
reverted
Rohini-Microsoft Sep 25, 2024
0cd7e52
Answer.tsx unit test cases were in progress
Kiran-Siluveru-Microsoft Sep 25, 2024
fb000d5
added package-lock.json
Rohini-Microsoft Sep 25, 2024
b7080c0
added changes
Rohini-Microsoft Sep 25, 2024
72e1c9d
added changes
Rohini-Microsoft Sep 25, 2024
50b89eb
added npm command in docker
Rohini-Microsoft Sep 25, 2024
28d6861
Merge branch 'PSL-BUG-TEST-7937' of https://github.com/Azure-Samples/…
Kiran-Siluveru-Microsoft Sep 26, 2024
1d7138c
Answer Unit test cases in progress
Kiran-Siluveru-Microsoft Sep 26, 2024
806126c
For Answers unit testings added new test cases
Kiran-Siluveru-Microsoft Sep 26, 2024
b750067
Merge branch 'PSL-TS-7938' into PSL-8488-UT-ANSWERS
Kiran-Siluveru-Microsoft Sep 26, 2024
7fb5113
debug and logs removed
Kiran-Siluveru-Microsoft Sep 26, 2024
abc5817
logs removed from no page tests
Kiran-Siluveru-Microsoft Sep 26, 2024
16fa577
moved static data to separate files
Kiran-Siluveru-Microsoft Sep 26, 2024
b4d2de5
Added new test cases for answer component
Kiran-Siluveru-Microsoft Sep 27, 2024
748eacc
Merge branch 'main' of https://github.com/Azure-Samples/chat-with-you…
Kiran-Siluveru-Microsoft Sep 30, 2024
a445521
All Chat test code added and fixed key issues, added test ids
Kiran-Siluveru-Microsoft Sep 30, 2024
006ce35
Added few more unit test cases for chat component
Kiran-Siluveru-Microsoft Oct 1, 2024
3115d9b
Added chat test cases for citation panels view, text reader
Kiran-Siluveru-Microsoft Oct 1, 2024
c1d9dc8
chat component 80% test cases coverage achieved
Kiran-Siluveru-Microsoft Oct 1, 2024
d0231ea
Removed Comments
Kiran-Siluveru-Microsoft Oct 1, 2024
f06ec82
Added Cards Component unit test cases
Kiran-Siluveru-Microsoft Oct 3, 2024
29c6166
Clear Button Branch covered
Kiran-Siluveru-Microsoft Oct 3, 2024
0a64e58
Added accessibility unit test cases
Kiran-Siluveru-Microsoft Oct 3, 2024
f2607a9
ignore paths added to jest config
Kiran-Siluveru-Microsoft Oct 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# generated frontend files
code/dist/
code/frontend/coverage

# User-specific files
*.rsuser
Expand Down
164 changes: 164 additions & 0 deletions code/frontend/__mocks__/SampleData.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions code/frontend/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub';
1 change: 1 addition & 0 deletions code/frontend/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
33 changes: 33 additions & 0 deletions code/frontend/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { Config } from '@jest/types'

const config: Config.InitialOptions = {
preset: 'ts-jest',
testEnvironment: 'jest-environment-jsdom',
moduleNameMapper: {
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/__mocks__/fileMock.js',
'^lodash-es$': 'lodash',
},
setupFilesAfterEnv: ['<rootDir>/setupTests.ts'],
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
transformIgnorePatterns: [
'/node_modules/(?!react-markdown|vfile|unist-util-stringify-position|unist-util-visit|bail|is-plain-obj)',
],
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}'],
coveragePathIgnorePatterns: [
'<rootDir>/node_modules/', // Ignore node_modules
'<rootDir>/__mocks__/', // Ignore mocks
'<rootDir>/src/api/',
'<rootDir>/src/mocks/',
'<rootDir>/src/test/',
'<rootDir>/src/index.tsx',
'<rootDir>/src/vite-env.d.ts',
'<rootDir>/src/components/QuestionInput/index.ts',
'<rootDir>/src/components/Answer/index.ts',
],
};

export default config;
30 changes: 30 additions & 0 deletions code/frontend/jest.polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @note The block below contains polyfills for Node.js globals
* required for Jest to function when running JSDOM tests.

* These HAVE to be require's and HAVE to be in this exact
* order, since "undici" depends on the "TextEncoder" global API.
*
* Consider migrating to a more modern test runner if
* you don't want to deal with this.
*/
const { TextDecoder, TextEncoder } = require('node:util')

Object.defineProperties(globalThis, {
TextDecoder: { value: TextDecoder },
TextEncoder: { value: TextEncoder },

})

const { Blob } = require('node:buffer')
const { fetch, Headers, FormData, Request, Response } = require('undici')

Object.defineProperties(globalThis, {

fetch: { value: fetch, writable: true },
Blob: { value: Blob },
Headers: { value: Headers },
FormData: { value: FormData },
Request: { value: Request },
Response: { value: Response },
})
19 changes: 16 additions & 3 deletions code/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "tsc && vite",
"build": "tsc && vite build",
"watch": "tsc && vite build --watch",
"test": "vitest run"
"test": "jest --coverage --watchAll --verbose"
},
"dependencies": {
"@babel/traverse": "^7.25.6",
Expand All @@ -27,18 +27,31 @@
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0",
"remark-supersub": "^1.0.0",
"undici": "^6.19.8",
"uuid": "^10.0.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/isomorphic-fetch": "^0.0.39",
"@types/jest": "^29.5.13",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.5.5",
"@types/react": "^18.3.9",
"@types/react-dom": "^18.3.0",
"@types/testing-library__user-event": "^4.2.0",
"@types/uuid": "^10.0.0",
"@vitejs/plugin-react": "^4.3.1",
"identity-obj-proxy": "^3.0.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"msw": "^2.4.9",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"vite": "^5.4.7",
"vitest": "^2.1.1"
"vite": "^5.4.3"
}
}
7 changes: 7 additions & 0 deletions code/frontend/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "@testing-library/jest-dom";
const { TextDecoder, TextEncoder } = require('node:util')

import { initializeIcons } from "@fluentui/react/lib/Icons";
initializeIcons();
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
4 changes: 2 additions & 2 deletions code/frontend/src/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export type Citation = {
filepath: string | null;
url: string | null;
metadata: string | null;
chunk_id: string | null;
reindex_id: string | null;
chunk_id: string | null | number;
reindex_id?: string | null;
}

export type ToolMessageContent = {
Expand Down
Loading