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

feat: CWYD | Frontend Unit test cases #3

Open
wants to merge 141 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
141 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
092acf6
Merge branch 'main' of https://github.com/Azure-Samples/chat-with-you…
Kiran-Siluveru-Microsoft Oct 4, 2024
41bf85a
Merge branch 'main' of https://github.com/Azure-Samples/chat-with-you…
Kiran-Siluveru-Microsoft Oct 4, 2024
caf9f59
vite import meta issue fixed for unit testing
Kiran-Siluveru-Microsoft Oct 7, 2024
fd0c002
Commented code for failing unit test cases
Kiran-Siluveru-Microsoft Oct 8, 2024
1eae707
Merge branch 'main' of https://github.com/Azure-Samples/chat-with-you…
Kiran-Siluveru-Microsoft Oct 8, 2024
0e076d2
uncomment the tests.yml code
Rohini-Microsoft Oct 9, 2024
4a25eed
npm ci uncomment
Rohini-Microsoft Oct 9, 2024
eaed0f4
fix testcase issue
Oct 9, 2024
f0d9e9d
fix testcase issue for pr: #1379
Oct 9, 2024
68fed82
removed watchall in package.json
Rohini-Microsoft Oct 9, 2024
eeddf95
fixed lint issue
Rohini-Microsoft Oct 9, 2024
c02fb91
Merge branch 'main' into PSL-8488-UT-ANSWERS
AjitPadhi-Microsoft Oct 10, 2024
3e4062f
Merge branch 'main' of https://github.com/Azure-Samples/chat-with-you…
Kiran-Siluveru-Microsoft Oct 14, 2024
2a42036
Assistant type section component segregated
Kiran-Siluveru-Microsoft Oct 15, 2024
ed5aab9
Segregated ChatMessageContainer component
Kiran-Siluveru-Microsoft Oct 15, 2024
a80ecd2
Citation Panel separated
Kiran-Siluveru-Microsoft Oct 15, 2024
a9e660a
ChatHistory Panel Component is separated from Chat
Kiran-Siluveru-Microsoft Oct 15, 2024
597fddc
Merge branch 'main' into PSL-8488-UT-ANSWERS
ross-p-smith Oct 15, 2024
c62066b
ChatHistoryListItem segregated into groups and cell components
Kiran-Siluveru-Microsoft Oct 16, 2024
3585760
Chat Component Unit test cases in progress
Kiran-Siluveru-Microsoft Oct 16, 2024
9606928
test watch added to package.json
Kiran-Siluveru-Microsoft Oct 17, 2024
4299876
Merge branch 'PSL-8488-UT-ANSWERS' of https://github.com/Azure-Sample…
Kiran-Siluveru-Microsoft Oct 17, 2024
ed1a8b7
"Added new tests for Layout component, including auth branching cases…
Somesh-Microsoft Oct 21, 2024
e9ffaaf
added more test cases in it in order to cover uncovered line
Oct 22, 2024
fec575d
Removed Chat History List component and dependency functions are move…
Kiran-Siluveru-Microsoft Oct 25, 2024
77c00d8
Merge branch 'PSL-8488-UT-ANSWERS' of https://github.com/Azure-Sample…
Somesh-Microsoft Oct 25, 2024
34b59fd
Adding test file for ChatHistoryPanel & Citationpanel
Somesh-Microsoft Nov 6, 2024
1bcd884
"Added mock for microsoft-cognitiveservices-speech-sdk, updated Answe…
Somesh-Microsoft Nov 8, 2024
98af7ac
"Updated ChatHistoryListItemGroups component tests to use new mock da…
Somesh-Microsoft Nov 11, 2024
006f86b
ChatHistoryyListItemCell have covered 83%
Nov 20, 2024
8a42bf8
UT - ChatHistoryItemCell, ChatMessageContainer,HistoryButton, Spinner
Bangarraju-Microsoft Nov 20, 2024
626188c
UT - removed console log and screen debugers
Bangarraju-Microsoft Nov 20, 2024
4b34321
ChatHistoryListItemGroups test
Nov 21, 2024
85411d1
Merge branch 'PSL-8488-UT-ANSWERS' of https://github.com/Azure-Sample…
Nov 21, 2024
dce5000
removed error
Nov 21, 2024
106e346
UT - Spinner, ChatMessageContainer, ChatListItemGroups,AssistantTypeS…
Bangarraju-Microsoft Nov 21, 2024
65456fb
UT - Spinner, ChatMessageContainer, ChatListItemGroups,AssistantTypeS…
Bangarraju-Microsoft Nov 21, 2024
1f294e3
merge conflicts resolved
Bangarraju-Microsoft Nov 21, 2024
9c260c4
one test cases fix
Nov 22, 2024
636101a
Merge branch 'PSL-8488-UT-ANSWERS' of https://github.com/Azure-Sample…
Nov 22, 2024
2dbb0b1
ci: Updated workflow to handle main, dev and demo branch | Dependabot…
Roopan-Microsoft Nov 25, 2024
97ced9f
fix: SFI Fixes & scope reverted to subscription (#1513)
Roopan-Microsoft Nov 25, 2024
903c259
ci: workflow updated for build docker (#1514)
Roopan-Microsoft Nov 25, 2024
4cf2972
ci: build docker updated for dev (#1522)
Roopan-Microsoft Nov 25, 2024
9158819
ci: workflow branch code updated (#1525)
Roopan-Microsoft Nov 25, 2024
4545a48
updated comment
AjitPadhi-Microsoft Nov 25, 2024
84a33b5
updated workflow
AjitPadhi-Microsoft Nov 25, 2024
f8c1c8f
updated workflow
AjitPadhi-Microsoft Nov 25, 2024
e31a661
updated workflow
AjitPadhi-Microsoft Nov 26, 2024
847ce7e
updated bicep for registry
AjitPadhi-Microsoft Nov 26, 2024
8f8cc98
fixed bicep
AjitPadhi-Microsoft Nov 26, 2024
15b948c
fix: bicep updated (#1527)
AjitPadhi-Microsoft Nov 26, 2024
1645e43
Merge branch 'main' into dev
Roopan-Microsoft Nov 27, 2024
8df387a
Merge branch 'dev' of https://github.com/Azure-Samples/chat-with-your…
Roopan-Microsoft Nov 27, 2024
e4dd5f2
fix: Container issue fix for multiple branch (#1539)
AjitPadhi-Microsoft Nov 27, 2024
88d06dc
fix: Updated workflow (#1540)
AjitPadhi-Microsoft Nov 27, 2024
e5cf4dd
ci: Psl container fix for checkout code from head branch (#1541)
Roopan-Microsoft Nov 27, 2024
7e69f5c
ChatHistoryListItemGroups test cases updated
Nov 27, 2024
fcb13da
ChatHistoryItemCell test cases
Nov 28, 2024
d56f098
fix: Auth type set default to rbac and removed resource group from bi…
Roopan-Microsoft Dec 3, 2024
02d0056
fix: multiple container tag issue fix (#1552)
AjitPadhi-Microsoft Dec 9, 2024
90e1040
fix: Workflow issue fix on docker image (#1554)
AjitPadhi-Microsoft Dec 9, 2024
fe6d273
Merge https://github.com/Roopan-Microsoft/psl-cwyd-main into PSL-8488…
Bangarraju-Microsoft Dec 9, 2024
dee02ba
docs: CWYD | Storage Account & Cosmos DB Icons updated (#1467)
Roopan-Microsoft Dec 9, 2024
7fb0636
feat: PostgreSQL implementation for Chat History and Vectorization (…
gpickett Dec 17, 2024
8a5a1cb
fix: Downmerge dev (#1566)
Pavan-Microsoft Dec 18, 2024
131c323
fix: CWYD Citation Links to Documents Break After Specific Timeframe …
Harmanpreet-Microsoft Dec 18, 2024
93b84ed
fix: Commit changes bug (#1568)
UtkarshMishra-Microsoft Dec 18, 2024
0875b92
fix: Post-Deployment Script for Managing Bicep Outputs in .env File …
Pavan-Microsoft Dec 19, 2024
76190b3
fix: import error in env_helper.py (#1571)
Pavan-Microsoft Dec 19, 2024
c65bf01
fix: add conversation flow in environment variable for adminweb app (…
Priyanka-Microsoft Dec 19, 2024
1f326d9
fix: Update Hosting Model Configuration in ARM/Bicep Template (#1570)
Prasanjeet-Microsoft Dec 19, 2024
fc688c2
fix: Update main.json for changes conversation flow changes in bicep …
Priyanka-Microsoft Dec 19, 2024
405d4bc
docs: Update README for PostgreSQL / Cosmos DB Integration (#1576)
Fr4nc3 Dec 20, 2024
56adb59
Merge branch 'main' into dev
Roopan-Microsoft Dec 24, 2024
afaabdc
build: Dependabotchanges merge to Dev branch (#1602)
Roopan-Microsoft Dec 30, 2024
03f52b3
feat: Configurable System Prompts for Flexibility and Maintenance - C…
Pavan-Microsoft Dec 31, 2024
e92eba1
fix: Add Missing Logs (#1609)
Pavan-Microsoft Jan 2, 2025
b0860ee
commented the prompt flow in azure yaml file
Roopan-Microsoft Jan 3, 2025
983b1f7
Merge branches 'dev' and 'dev' of https://github.com/Azure-Samples/ch…
Roopan-Microsoft Jan 3, 2025
dae4043
Add execute permissions parse_env.sh in postprovision hook
Pavan-Microsoft Jan 3, 2025
08ad207
fix: Build issue with docker
Prajwal-Microsoft Jan 4, 2025
c49ddfd
Update build-docker.yml
Prajwal-Microsoft Jan 5, 2025
5994f99
fix: Docker file failure issue
Prajwal-Microsoft Jan 5, 2025
6a4cebb
build: merging dev changes to main branch (#1599)
Roopan-Microsoft Jan 5, 2025
99d10df
Merge branch 'dev' of https://github.com/Azure-Samples/chat-with-your…
Bangarraju-Microsoft Jan 6, 2025
76e0093
merge issue fixed
Bangarraju-Microsoft Jan 6, 2025
9e4cb83
removed debuger from test files
Bangarraju-Microsoft Jan 6, 2025
e3cf7ed
package lock file pushed due to docker image build failing
Bangarraju-Microsoft Jan 6, 2025
a13551b
chore: Delete .github/workflows/sync-branches.yml (#1617)
Harmanpreet-Microsoft Jan 7, 2025
20f176d
Merge branch 'main' into PSL-8488-UT-ANSWERS
Roopan-Microsoft Jan 8, 2025
87c2474
package lock updated
Roopan-Microsoft Jan 8, 2025
93a1310
UI - duplicate code added due to merge
Bangarraju-Microsoft Jan 9, 2025
6aac7c1
version downgraded for build push actions
Roopan-Microsoft Jan 10, 2025
604111e
Merge branch 'PSL-8488-UT-ANSWERS' of https://github.com/Azure-Sample…
Roopan-Microsoft Jan 10, 2025
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
226 changes: 226 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 },
})
17 changes: 16 additions & 1 deletion code/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "tsc && vite",
"build": "tsc && vite build",
"watch": "tsc && vite build --watch",
"test": "vitest run"
"test": "jest --coverage --verbose",
"test:watch": "jest --coverage --verbose --watchAll"
},
"dependencies": {
"@babel/traverse": "^7.25.9",
Expand All @@ -27,16 +28,30 @@
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0",
"remark-supersub": "^1.0.0",
"undici": "^6.19.8",
"uuid": "^11.0.2"
},
"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.12",
"@types/react-dom": "^18.3.1",
"@types/testing-library__user-event": "^4.2.0",
"@types/uuid": "^10.0.0",
"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",
"@vitejs/plugin-react": "^4.3.3",
"prettier": "^3.3.3",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"vite": "^5.4.10",
"vitest": "^2.1.4"
Expand Down
44 changes: 44 additions & 0 deletions code/frontend/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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;

// Mock IntersectionObserver
class IntersectionObserverMock {
callback: IntersectionObserverCallback;
options: IntersectionObserverInit;

root: Element | null = null; // Required property
rootMargin: string = '0px'; // Required property
thresholds: number[] = [0]; // Required property

constructor(callback: IntersectionObserverCallback, options: IntersectionObserverInit) {
this.callback = callback;
this.options = options;
}

observe = jest.fn((target: Element) => {
// Simulate intersection with an observer instance
this.callback([{ isIntersecting: true }] as IntersectionObserverEntry[], this as IntersectionObserver);
});

unobserve = jest.fn();
disconnect = jest.fn(); // Required method
takeRecords = jest.fn(); // Required method
}

// Store the original IntersectionObserver
const originalIntersectionObserver = window.IntersectionObserver;

beforeAll(() => {
window.IntersectionObserver = IntersectionObserverMock as any;
});

afterAll(() => {
// Restore the original IntersectionObserver
window.IntersectionObserver = originalIntersectionObserver;
});

6 changes: 3 additions & 3 deletions code/frontend/src/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export type Citation = {
title: string | null;
filepath: string | null;
url: string | null;
metadata: string | null;
chunk_id: string | null;
reindex_id: string | null;
metadata: string | null | Record<string, string| number>;
chunk_id: string | null | number;
reindex_id?: string | null;
}

export type ToolMessageContent = {
Expand Down
Loading
Loading