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

fix: merging dev changes to main branch #215

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7b6fb2f
UI - Jest & RTL integration and setup
Bangarraju-Microsoft Oct 16, 2024
b0d2a32
Adding unit test cases for document
Somesh-Microsoft Oct 24, 2024
71aa8d7
added sidebartest fike
Nov 1, 2024
462f882
added test cases
Nov 4, 2024
0ef57f9
edits in sidebartest file
Nov 5, 2024
f8cecfd
added chatHistory test file
Nov 6, 2024
70ec46f
Add ChatHistoryList test file
Nov 6, 2024
35180b0
Chat Component splitted and unit test cases written
Bangarraju-Microsoft Nov 14, 2024
e525854
Unit test cases for button, feature card, ChatHistoryPanel, ChatHisto…
Bangarraju-Microsoft Nov 14, 2024
08b50e6
UI - Unit test cases for TitleCard, Draft,Landing, Layout
Bangarraju-Microsoft Nov 20, 2024
bcbf4be
Merge branch 'microsoft:main' into US-9072-UT
Bangarraju-Microsoft Nov 20, 2024
392794c
UT - ChatHistroyListItem, QuestionInput
Bangarraju-Microsoft Nov 20, 2024
92bf281
Merge branch 'US-9072-UT' of https://github.com/Bangarraju-Microsoft/…
Bangarraju-Microsoft Nov 20, 2024
f21ae97
UT - Answer, Jest config changes
Bangarraju-Microsoft Nov 22, 2024
fdf7e52
Unit test cases for chat.tsx and section card
Bangarraju-Microsoft Dec 6, 2024
ee5317f
Merge https://github.com/Roopan-Microsoft/psl-docgen-main into US-907…
Bangarraju-Microsoft Dec 6, 2024
0b67d57
after sync with roopan's main branch conflicts resolved and added code
Bangarraju-Microsoft Dec 6, 2024
273129b
After merge changes
Bangarraju-Microsoft Dec 6, 2024
7dd5d28
UT - ChatHistoryPanel, FeatureCard
Bangarraju-Microsoft Dec 13, 2024
ee493ad
UI - unit test cases for layout component
Bangarraju-Microsoft Jan 2, 2025
3773470
UI - unit test cases for SectionCard and Draft Components
Bangarraju-Microsoft Jan 3, 2025
d973164
Merge https://github.com/microsoft/Generic-Build-your-own-copilot-Sol…
Bangarraju-Microsoft Jan 8, 2025
9849512
UI - Merge missed code added
Bangarraju-Microsoft Jan 8, 2025
df57e0f
UI -remove screen.debug from the test file
Bangarraju-Microsoft Jan 8, 2025
2d87635
UI - pushed package lock file
Bangarraju-Microsoft Jan 8, 2025
d99342b
Merge pull request #194 from Bangarraju-Microsoft/US-9072-UT
Roopan-Microsoft Jan 8, 2025
307f712
Update docker-build-and-push.yml
Roopan-Microsoft Jan 17, 2025
2f8ad42
Update docker-build-and-push.yml
Roopan-Microsoft Jan 17, 2025
796c9b2
Update docker-build-and-push.yml
Roopan-Microsoft Jan 17, 2025
d34fb1b
feat: Implement Consistent Versioning and Tagging for Accelerator Images
Pavan-Microsoft Jan 22, 2025
b65de15
Update docker-build-and-push.yml
Pavan-Microsoft Jan 22, 2025
0ec2443
Merge pull request #196 from microsoft/PSL-US-12925
Roopan-Microsoft Jan 22, 2025
0b5e2ff
Merge branch 'dev' into PSL-update-dockeryml-file
Roopan-Microsoft Jan 27, 2025
0984bc0
Update docker-build-and-push.yml
Roopan-Microsoft Jan 27, 2025
2546cc3
Update WebApp.Dockerfile
Roopan-Microsoft Jan 27, 2025
56360f2
Merge pull request #195 from microsoft/PSL-update-dockeryml-file
Roopan-Microsoft Jan 27, 2025
0a2da91
Update docker-build-and-push.yml
Pavan-Microsoft Jan 27, 2025
a0b79cd
Merge pull request #197 from microsoft/PSL-US-12925_1
Roopan-Microsoft Jan 27, 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
58 changes: 29 additions & 29 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Build and Push Docker Image

on:
push:
branches: [main, dev, demo]
pull_request:
types: [closed]
branches:
- main
- dev
- demo
workflow_dispatch: # Add this line to enable manual triggering
branches: [main, dev, demo]
types:
- opened
- ready_for_review
- reopened
- synchronize
merge_group:

jobs:
build-and-push:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

steps:
Expand All @@ -37,26 +39,24 @@ jobs:
username: ${{ secrets.ACR_DEV_USERNAME }}
password: ${{ secrets.ACR_DEV_PASSWORD }}

- name: Set Docker image tag
id: docker_tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "TAG=latest" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "TAG=dev" >> $GITHUB_ENV
elif [[ "${{ github.ref }}" == "refs/heads/demo" ]]; then
echo "TAG=demo" >> $GITHUB_ENV
fi

- name: Build and push Docker image
if: ${{ github.ref_name == 'main' }}
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }} -f WebApp.Dockerfile .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:${{ env.TAG }}
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Build and push Docker image (Dev/Demo)
if: ${{ github.ref_name == 'dev' || github.ref_name == 'demo' }}
run: |
docker build -t ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest -f WebApp.Dockerfile .
docker push ${{ secrets.ACR_LOGIN_SERVER }}/webapp:latest

- name: Get registry
id: registry
run: echo "registry=${{ github.ref_name == 'main' && secrets.ACR_LOGIN_SERVER || secrets.ACR_DEV_LOGIN_SERVER }}" >> $GITHUB_OUTPUT

- name: Determine Tag Name Based on Branch
id: determine_tag
run: echo "tagname=${{ github.ref_name == 'main' && 'latest' || github.ref_name == 'dev' && 'dev' || github.ref_name == 'demo' && 'demo' || github.head_ref || 'default' }}" >> $GITHUB_OUTPUT

- name: Build Docker Image and optionally push
uses: docker/build-push-action@v6
with:
context: .
file: WebApp.Dockerfile
push: ${{ github.ref_name == 'main' || github.ref_name == 'dev' || github.ref_name == 'demo' }}
tags: |
${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}
${{ steps.registry.outputs.registry }}/webapp:${{ steps.determine_tag.outputs.tagname }}_${{ steps.date.outputs.date }}_${{ github.run_number }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ __pycache__/
static
scripts/config.json
venv
myenv
myenv
frontend/coverage
3 changes: 2 additions & 1 deletion WebApp.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ USER node
RUN npm ci
COPY --chown=node:node ./frontend/ ./frontend
WORKDIR /home/node/app/frontend
RUN npm install --save-dev @types/node @types/jest
RUN NODE_OPTIONS=--max_old_space_size=8192 npm run build

FROM python:3.11-alpine
Expand All @@ -27,4 +28,4 @@ COPY --from=frontend /home/node/app/static /usr/src/app/static/
WORKDIR /usr/src/app
EXPOSE 80

CMD ["gunicorn" , "-b", "0.0.0.0:80", "app:app"]
CMD ["gunicorn" , "-b", "0.0.0.0:80", "app:app"]
5 changes: 5 additions & 0 deletions frontend/__mocks__/dompurify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const DOMPurify = {
sanitize: jest.fn((input: string) => input), // Mock implementation that returns the input
};

export default DOMPurify; // Use default export
4 changes: 4 additions & 0 deletions frontend/__mocks__/fileMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// __mocks__/fileMock.ts
const fileMock = 'test-file-stub';

export default fileMock;
164 changes: 164 additions & 0 deletions frontend/__mocks__/mockAPIData.ts

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions frontend/__mocks__/react-markdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// __mocks__/react-markdown.tsx

import React from 'react';

// Mock implementation of react-markdown
const mockNode = {
children: [{ value: 'console.log("Test Code");' }]
};
const mockProps = { className: 'language-javascript' };

const ReactMarkdown: React.FC<{ children: React.ReactNode , components: any }> = ({ children,components }) => {
return <div data-testid="reactMockDown">
{/* {components && components.code({ node: mockNode, ...mockProps })} */}
{children}</div>; // Simply render the children
};

export default ReactMarkdown;
49 changes: 47 additions & 2 deletions frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,55 @@ import type { Config } from '@jest/types'

const config: Config.InitialOptions = {
verbose: true,

preset: 'ts-jest',
//testEnvironment: 'jsdom', // For React DOM testing
testEnvironment: 'jest-environment-jsdom',
testEnvironmentOptions: {
customExportConditions: ['']
},
moduleNameMapper: {
'\\.(css|less|scss)$': 'identity-obj-proxy', // For mocking static file imports
'^react-markdown$': '<rootDir>/__mocks__/react-markdown.tsx',
'^dompurify$': '<rootDir>/__mocks__/dompurify.js', // Point to the mock
'\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/__mocks__/fileMock.ts',

},
setupFilesAfterEnv: ['<rootDir>/src/test/setupTests.ts'], // For setting up testing environment like jest-dom
transform: {
'^.+\\.tsx?$': 'ts-jest'
'^.+\\.ts(x)?$': 'ts-jest', // For TypeScript files
'^.+\\.js$': 'babel-jest', // For JavaScript files if you have Babel
},
setupFilesAfterEnv: ['<rootDir>/polyfills.js']

setupFiles: ['<rootDir>/jest.polyfills.js'],
collectCoverage: true,
//collectCoverageFrom: ['src/**/*.{ts,tsx}'], // Adjust the path as needed
//coverageReporters: ['json', 'lcov', 'text', 'clover'],

collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}'],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},

coveragePathIgnorePatterns: [
'<rootDir>/node_modules/', // Ignore node_modules
'<rootDir>/__mocks__/', // Ignore mocks
'<rootDir>/src/state/',
'<rootDir>/src/api/',
'<rootDir>/src/mocks/',
//'<rootDir>/src/test/',
'<rootDir>/src/components/QuestionInput/index.ts',
'<rootDir>/src/components/Answer/index.ts',
'<rootDir>/src/pages/NoPage.tsx',
'<rootDir>/src/index.tsx',
'<rootDir>/src/vite-env.d.ts',
'<rootDir>/src/helpers/'
],
}

export default config
28 changes: 28 additions & 0 deletions frontend/jest.polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @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 },
})
Loading
Loading