Skip to content

Commit 4cf502e

Browse files
fix: integrated deployment pipeline with test automation pipeline, fix test scripts, bug fixes
2 parents 6c86a4c + bf8ff0f commit 4cf502e

File tree

16 files changed

+524
-341
lines changed

16 files changed

+524
-341
lines changed

.github/workflows/CI.yml

Lines changed: 249 additions & 102 deletions
Large diffs are not rendered by default.

.github/workflows/test-automation.yml

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
name: Test Automation DKM
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- dev
8-
paths:
9-
- 'tests/e2e-test/**'
10-
schedule:
11-
- cron: '0 13 * * *' # Runs at 1 PM UTC
12-
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
DKM_URL:
7+
required: true
8+
type: string
9+
description: "Web URL for DKM"
10+
secrets:
11+
EMAILNOTIFICATION_LOGICAPP_URL_TA:
12+
required: false
13+
description: "Logic App URL for email notifications"
1314

1415
env:
15-
url: ${{ vars.DKM_URL }}
16+
url: ${{ inputs.DKM_URL }}
1617
accelerator_name: "DKM"
1718

1819
jobs:
@@ -27,20 +28,6 @@ jobs:
2728
with:
2829
python-version: '3.13'
2930

30-
- name: Azure CLI Login
31-
uses: azure/login@v2
32-
with:
33-
creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
34-
35-
- name: Start AKS
36-
id: start-aks
37-
uses: azure/cli@v2
38-
with:
39-
azcliversion: 'latest'
40-
inlineScript: |
41-
az aks install-cli
42-
if [ "$(az aks show --resource-group ${{ vars.DKM_RG }} --name ${{ vars.DKM_AKS_NAME }} --query "powerState.code" -o tsv)" = "Running" ]; then echo "AKS is running"; else az aks start --resource-group ${{ vars.DKM_RG }} --name ${{ vars.DKM_AKS_NAME }}; fi
43-
4431
- name: Install dependencies
4532
run: |
4633
python -m pip install --upgrade pip
@@ -49,6 +36,15 @@ jobs:
4936
- name: Ensure browsers are installed
5037
run: python -m playwright install --with-deps chromium
5138

39+
- name: Open URL
40+
run: |
41+
echo "Opening URL: ${{ env.url }}"
42+
python -m webbrowser "${{ env.url }}"
43+
44+
- name: Sleep for 30 seconds
45+
run: sleep 30s
46+
shell: bash
47+
5248
- name: Run tests(1)
5349
id: test1
5450
run: |
@@ -117,14 +113,4 @@ jobs:
117113
# Send the notification
118114
curl -X POST "${{ secrets.EMAILNOTIFICATION_LOGICAPP_URL_TA }}" \
119115
-H "Content-Type: application/json" \
120-
-d "$EMAIL_BODY" || echo "Failed to send notification"
121-
122-
- name: Stop AKS
123-
if: always()
124-
uses: azure/cli@v2
125-
with:
126-
azcliversion: 'latest'
127-
inlineScript: |
128-
az aks install-cli
129-
if [ "$(az aks show --resource-group ${{ vars.DKM_RG }} --name ${{ vars.DKM_AKS_NAME }} --query "powerState.code" -o tsv)" = "Running" ]; then az aks stop --resource-group ${{ vars.DKM_RG }} --name ${{ vars.DKM_AKS_NAME }}; else echo "AKS is already stopped"; fi
130-
az logout
116+
-d "$EMAIL_BODY" || echo "Failed to send notification"

App/frontend-app/src/assets/scss/global.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,8 @@ $max-content-width: 1600px;
104104
._max-content-width {
105105
max-width: $max-content-width;
106106
}
107+
}
108+
109+
.autoHeight {
110+
height :auto !important;
107111
}

App/frontend-app/src/components/chat/chatRoom.tsx

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ interface ChatRoomProps {
5050
export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDocument, disableOptionsPanel, clearChatFlag }: ChatRoomProps) {
5151
const customStyles = useStyles();
5252
const { t } = useTranslation();
53-
const [chatSessionId, setChatSessionId] = useState<string | null>(null);
53+
const [chatSessionId, setChatSessionId] = useState<string | null>(null);
5454
const [isLoading, setIsLoading] = useState<boolean>(false);
5555
const [disableSources, setDisableSources] = useState<boolean>(false);
5656
const [error, setError] = useState<unknown>();
@@ -99,16 +99,16 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
9999
useEffect(() => {
100100
handleModelChange(DefaultChatModel)
101101
}, []);
102-
103-
// Effect to clear chat when clearChat prop changes
102+
103+
// Effect to clear chat when clearChat prop changes
104104
useEffect(() => {
105105
if (clearChatFlag) {
106106
clearChat();
107107
}
108108
}, [clearChatFlag]); // Runs whenever clearChat changes
109109

110110

111-
111+
112112
const chatContainerRef = useRef<HTMLDivElement>(null);
113113
function scrollToBottom() {
114114
if (chatContainerRef.current) {
@@ -128,23 +128,23 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
128128
setTextareaKey(prev => prev + 1);
129129
setDisableSources(true);
130130
setIsLoading(true);
131-
131+
132132
// A simple function to check if the text contains Markdown
133133
const isMarkdown = (text: string) => {
134134
const markdownPattern = /(^|\s)(#{1,6}|\*\*|__|[-*]|\d+\.\s|\[.*\]\(.*\)|```|`[^`]*`)/;
135135
return markdownPattern.test(text);
136-
};
136+
};
137137

138138
const userTimestamp = new Date();
139139
// Ensure we have a chatSessionId or create one if null/undefined
140-
141-
140+
141+
142142
let currentSessionId = chatSessionId; // Get the current value of chatSessionId
143143
if (!currentSessionId) {
144144
const newSessionId = uuidv4(); // Generate a new UUID if no session exists
145145
setChatSessionId(newSessionId); // Save it for future renders
146146
currentSessionId = newSessionId; // Immediately use the new session ID in this function
147-
147+
148148
}
149149
const markdownToHtmlString = (markdown: string) => {
150150
return renderToStaticMarkup(<ReactMarkdown>{markdown}</ReactMarkdown>);
@@ -170,7 +170,7 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
170170
| Total NPLs sold by Enterprises through December 2023 | 168,364 | FHFA Non-Performing Loan Sales Report | Page 2 |
171171
| Average delinquency of NPLs sold | 2.8 years | FHFA Non-Performing Loan Sales Report | Page 2 |
172172
| Average current mark-to-market LTV ratio of NPLs | 83% | FHFA Non-Performing Loan Sales Report | Page 2 |`;
173-
173+
174174
const htmlString = await marked.parse(markdown);
175175
const htmlString2 = markdownToHtmlString(markdown);
176176

@@ -183,18 +183,18 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
183183
}],
184184
]);
185185

186-
187-
186+
187+
188188

189189

190190
let filterByDocumentIds: string[] = [];
191-
192-
191+
192+
193193
const transformDocuments = (documents: any[]) => {
194194
return documents.map(doc => doc.documentId); // Extracting documentId from each document
195195
};
196196
const formattedDocuments = transformDocuments(selectedDocuments);
197-
197+
198198

199199
if (button === "Selected Document" && selectedDocument) {
200200
filterByDocumentIds = [selectedDocument[0].documentId];
@@ -205,13 +205,13 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
205205
}
206206

207207
try {
208-
209-
210-
208+
209+
210+
211211
const request: ChatRequest = {
212212
Question: question,
213213
chatSessionId: currentSessionId,
214-
DocumentIds: button === "All Documents" ? [] : formattedDocuments
214+
DocumentIds: button === "All Documents" ? [] : formattedDocuments
215215
// cha: history,
216216
// options: {
217217
// model: model,
@@ -221,25 +221,25 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
221221
// },
222222
// filterByDocumentIds: filterByDocumentIds,
223223
};
224-
225-
224+
225+
226226
const response: ChatApiResponse = await Completion(request);
227-
228-
227+
228+
229229

230230
setIsLoading(false);
231231

232232
const answerTimestamp = new Date();
233233

234234
try {
235235
if (response && response.answer) {
236-
236+
237237
const formattedAnswer = removeNewlines(response.answer)
238238
const chatResp = await marked.parse(formattedAnswer) // Convert to HTML if Markdown detected
239-
240-
241-
242-
239+
240+
241+
242+
243243
// Update the conversation with the formatted answer
244244
setConversationAnswers((prevAnswers) => {
245245
const newAnswers = [...prevAnswers];
@@ -279,7 +279,7 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
279279
setChatSessionId(null);
280280
};
281281

282-
const handleModelChange = (model: string) => {
282+
const handleModelChange = (model: string) => {
283283
setModel(model);
284284
};
285285

@@ -293,7 +293,7 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
293293
};
294294

295295
function handleSend(ev: TextareaSubmitEvents, data: TextareaValueData) {
296-
if (data.value.trim() !='') {
296+
if (data.value.trim() != '') {
297297
makeApiRequest(data.value);
298298
}
299299
}
@@ -340,10 +340,10 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
340340
button === "Selected Documents"
341341
? selectedDocuments.map((document) => document.documentId)
342342
: button === "Search Results"
343-
? searchResultDocuments.map((document) => document.documentId)
344-
: button === "Selected Document"
345-
? [selectedDocument[0]?.documentId || ""]
346-
: [],
343+
? searchResultDocuments.map((document) => document.documentId)
344+
: button === "Selected Document"
345+
? [selectedDocument[0]?.documentId || ""]
346+
: [],
347347
groundTruthAnswer: "",
348348
documentURLs: [],
349349
chunkTexts: [],
@@ -482,8 +482,12 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
482482
{response.suggestingQuestions.map((followUp, index) => (
483483
<Suggestion
484484
key={index}
485-
className="!mr-2 !mt-2 !text-base"
486-
onClick={() => handleFollowUpQuestion(followUp)}
485+
className={`!mr-2 !mt-2 !text-base ${isLoading ? "pointer-events-none text-gray-400" : ""}`}
486+
onClick={() => {
487+
if (!isLoading) {
488+
handleFollowUpQuestion(followUp);
489+
}
490+
}}
487491
>
488492
{followUp}
489493
</Suggestion>
@@ -594,11 +598,11 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
594598
contentAfter={undefined}
595599
/>
596600
</div>
597-
</div>
601+
</div >
598602
);
599603
}
600604
function uuidv4() {
601-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
605+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
602606
const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
603607
return v.toString(16);
604608
});

App/frontend-app/src/components/documentViewer/dialogContentComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function DialogContentComponent({
5252
</div>
5353
)}
5454

55-
<div className="mb-4 h-96 overflow-y-auto">
55+
<div className="mb-4 h-96 overflow-y-auto autoHeight">
5656
{allChunkTexts.map(
5757
(item, index) =>
5858
item && (

App/frontend-app/src/components/uploadButton/uploadButton.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ const UploadDocumentsDialog = () => {
5959

6060
try {
6161
// Simulate upload delay
62-
await new Promise((resolve) => setTimeout(resolve, 2000));
62+
//File upload is significantly slower than expected, so commented out the line below.
63+
// await new Promise((resolve) => setTimeout(resolve, 2000));
6364
await importDocuments(formData); // Replace with actual upload API
6465

6566
// Update file status to success
@@ -93,9 +94,22 @@ const UploadDocumentsDialog = () => {
9394
noKeyboard: true,
9495
});
9596

97+
// Add this function to handle dialog close
98+
const handleDialogClose = () => {
99+
setIsOpen(false);
100+
setUploadingFiles([]); // Clear the uploaded files
101+
setIsUploading(false); // Reset uploading state
102+
};
103+
96104
return (<>
97105
{isUploadBtnVisible == true ?
98-
<Dialog open={isOpen} onOpenChange={(event, data) => setIsOpen(data.open)}>
106+
<Dialog open={isOpen} onOpenChange={(event, data) => {
107+
if (!data.open) {
108+
handleDialogClose();
109+
} else {
110+
setIsOpen(data.open);
111+
}
112+
}}>
99113
<DialogTrigger>
100114
<Button icon={<ArrowUpload24Regular />} onClick={() => setIsOpen(true)}>
101115
Upload documents
@@ -108,7 +122,7 @@ const UploadDocumentsDialog = () => {
108122
<Button
109123
icon={<DismissRegular />}
110124
appearance="subtle"
111-
onClick={() => setIsOpen(false)}
125+
onClick={handleDialogClose}
112126
style={{ position: "absolute", right: 20, top: 20 }}
113127
/>
114128
</DialogTitle>

Deployment/checkquota.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ foreach ($REGION in $REGIONS) {
6666

6767
foreach ($MODEL in $MIN_CAPACITY.Keys) {
6868

69-
$MODEL_INFO = $QUOTA_INFO | Where-Object { $_.Name -eq $MODEL }
69+
$MODEL_INFO = $QUOTA_INFO | Where-Object { $_.Name.Value -eq $MODEL }
7070

7171
if (-not $MODEL_INFO) {
7272
Write-Host "⚠️ WARNING: No quota information found for model: $MODEL in $REGION. Skipping."
73-
continue
73+
$INSUFFICIENT_QUOTA = $true
74+
break
7475
}
7576

7677
$CURRENT_VALUE = [int]$MODEL_INFO.CurrentValue

tests/e2e-test/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This will create a virtual environment directory named microsoft inside your cur
2020
Installing Playwright Pytest from Virtual Environment
2121

2222
- To install libraries run "pip install -r requirements.txt"
23+
- To install Playwright run "playwright install"
2324

2425
Run test cases
2526

tests/e2e-test/base/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from . import base
1+
"""Initiate base package"""

0 commit comments

Comments
 (0)