Skip to content

Commit d468f9b

Browse files
authored
[Language Conversations] Fix nightly (Azure#23207)
1 parent eff883a commit d468f9b

File tree

6 files changed

+308
-191
lines changed

6 files changed

+308
-191
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
// https://github.com/karma-runner/karma-chrome-launcher
5+
process.env.CHROME_BIN = require("puppeteer").executablePath();
6+
require("dotenv").config();
7+
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
8+
9+
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
10+
11+
module.exports = function (config) {
12+
config.set({
13+
// base path that will be used to resolve all patterns (eg. files, exclude)
14+
basePath: "./",
15+
16+
// frameworks to use
17+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
18+
frameworks: ["source-map-support", "mocha"],
19+
20+
plugins: [
21+
"karma-mocha",
22+
"karma-mocha-reporter",
23+
"karma-chrome-launcher",
24+
"karma-edge-launcher",
25+
"karma-firefox-launcher",
26+
"karma-ie-launcher",
27+
"karma-env-preprocessor",
28+
"karma-coverage",
29+
"karma-sourcemap-loader",
30+
"karma-junit-reporter",
31+
"karma-source-map-support",
32+
],
33+
34+
// list of files / patterns to load in the browser
35+
files: [
36+
"dist-test/index.browser.js",
37+
{ pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true },
38+
],
39+
40+
// list of files / patterns to exclude
41+
exclude: [],
42+
43+
// preprocess matching files before serving them to the browser
44+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
45+
preprocessors: {
46+
"**/*.js": ["sourcemap", "env"],
47+
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
48+
// Preprocess source file to calculate code coverage, however this will make source file unreadable
49+
// "dist-test/index.js": ["coverage"]
50+
},
51+
52+
envPreprocessor: [
53+
"TEST_MODE",
54+
"ENDPOINT",
55+
"LANGUAGE_API_KEY",
56+
"LANGUAGE_API_KEY_ALT",
57+
"AZURE_CLIENT_ID",
58+
"AZURE_CLIENT_SECRET",
59+
"AZURE_TENANT_ID",
60+
"LANGUAGE_CLU_PROJECT_NAME",
61+
"LANGUAGE_CLU_DEPLOYMENT_NAME",
62+
"LANGUAGE_ORCHESTRATION_PROJECT_NAME",
63+
"LANGUAGE_ORCHESTRATION_DEPLOYMENT_NAME",
64+
"RECORDINGS_RELATIVE_PATH",
65+
],
66+
67+
// test results reporter to use
68+
// possible values: 'dots', 'progress'
69+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
70+
reporters: ["mocha", "coverage", "junit"],
71+
72+
coverageReporter: {
73+
// specify a common output directory
74+
dir: "coverage-browser/",
75+
reporters: [
76+
{ type: "json", subdir: ".", file: "coverage.json" },
77+
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
78+
{ type: "html", subdir: "html" },
79+
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
80+
],
81+
},
82+
83+
junitReporter: {
84+
outputDir: "", // results will be saved as $outputDir/$browserName.xml
85+
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
86+
suite: "", // suite will become the package name attribute in xml testsuite element
87+
useBrowserName: false, // add browser name to report and classes names
88+
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
89+
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
90+
properties: {}, // key value pair of properties to add to the <properties> section of the report
91+
},
92+
93+
// web server port
94+
port: 9876,
95+
96+
// enable / disable colors in the output (reporters and logs)
97+
colors: true,
98+
99+
// level of logging
100+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
101+
logLevel: config.LOG_INFO,
102+
103+
// enable / disable watching file and executing tests whenever any file changes
104+
autoWatch: false,
105+
106+
// --no-sandbox allows our tests to run in Linux without having to change the system.
107+
// --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
108+
browsers: ["ChromeHeadlessNoSandbox"],
109+
customLaunchers: {
110+
ChromeHeadlessNoSandbox: {
111+
base: "ChromeHeadless",
112+
flags: ["--no-sandbox", "--disable-web-security"],
113+
},
114+
},
115+
116+
// Continuous Integration mode
117+
// if true, Karma captures browsers, runs the tests and exits
118+
singleRun: false,
119+
120+
// Concurrency level
121+
// how many browser should be started simultaneous
122+
concurrency: 1,
123+
124+
browserNoActivityTimeout: 60000000,
125+
browserDisconnectTimeout: 10000,
126+
browserDisconnectTolerance: 3,
127+
128+
client: {
129+
mocha: {
130+
// change Karma's debug.html to the mocha web reporter
131+
reporter: "html",
132+
timeout: "600000",
133+
},
134+
},
135+
});
136+
};

sdk/cognitivelanguage/ai-language-conversations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"extract-api": "tsc -p . && api-extractor run --local",
114114
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
115115
"integration-test:browser": "dev-tool run test:browser",
116-
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 \"test/**/*.spec.js\"",
116+
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 \"dist-esm/test/**/*.spec.js\"",
117117
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
118118
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
119119
"lint": "eslint package.json api-extractor.json src test --ext .ts",

sdk/cognitivelanguage/ai-language-conversations/test/public/analyze.spec.ts

Lines changed: 164 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
import { AuthMethod, createClient, startRecorder } from "./utils/recordedClient";
55
import { Context, Suite } from "mocha";
66
import { assert, matrix } from "@azure/test-utils";
7-
import { conv1, conv2, conv3, conv4, conv5, conv6 } from "./inputs";
87
import { ConversationAnalysisClient } from "../../src";
9-
import { Recorder } from "@azure-tools/test-recorder";
8+
import { Recorder, assertEnvironmentVariable } from "@azure-tools/test-recorder";
109

1110
matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
1211
describe(`[${authMethod}] ConversationAnalysisClient`, function (this: Suite) {
@@ -27,7 +26,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
2726

2827
describe("#sync", () => {
2928
it("Test Conversation App", async function () {
30-
const message = await client.analyzeConversation(conv1);
29+
const message = await client.analyzeConversation({
30+
kind: "Conversation",
31+
analysisInput: {
32+
conversationItem: {
33+
participantId: "1",
34+
id: "1",
35+
modality: "text",
36+
language: "en",
37+
text: "Send an email to Carol about the tomorrow's demo",
38+
},
39+
},
40+
parameters: {
41+
projectName: assertEnvironmentVariable("LANGUAGE_CLU_PROJECT_NAME"),
42+
deploymentName: assertEnvironmentVariable("LANGUAGE_CLU_DEPLOYMENT_NAME"),
43+
verbose: true,
44+
isLoggingEnabled: false,
45+
},
46+
});
3147
// Assert prediction type
3248
assert.equal(message.kind, "ConversationResult");
3349
assert.exists(message.result.query);
@@ -48,7 +64,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
4864
});
4965

5066
it("Test Orchestration App Conversational Response", async function () {
51-
const message = await client.analyzeConversation(conv2);
67+
const message = await client.analyzeConversation({
68+
kind: "Conversation",
69+
analysisInput: {
70+
conversationItem: {
71+
participantId: "1",
72+
id: "1",
73+
modality: "text",
74+
language: "en",
75+
text: "Send an email to Carol about the tomorrow's demo",
76+
},
77+
},
78+
parameters: {
79+
projectName: assertEnvironmentVariable("LANGUAGE_ORCHESTRATION_PROJECT_NAME"),
80+
deploymentName: assertEnvironmentVariable("LANGUAGE_ORCHESTRATION_DEPLOYMENT_NAME"),
81+
verbose: true,
82+
isLoggingEnabled: false,
83+
},
84+
});
5285
// Assert prediction type
5386
assert.equal(message.kind, "ConversationResult");
5487
assert.exists(message.result.query);
@@ -81,7 +114,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
81114
});
82115

83116
it.skip("Test Orchestration App LUIS Response", async function () {
84-
const message = await client.analyzeConversation(conv3);
117+
const message = await client.analyzeConversation({
118+
kind: "Conversation",
119+
analysisInput: {
120+
conversationItem: {
121+
participantId: "1",
122+
id: "1",
123+
modality: "text",
124+
language: "en",
125+
text: "Reserve a table for 2 at the Italian restaurant",
126+
},
127+
},
128+
parameters: {
129+
projectName: assertEnvironmentVariable("LANGUAGE_ORCHESTRATION_PROJECT_NAME"),
130+
deploymentName: assertEnvironmentVariable("LANGUAGE_ORCHESTRATION_DEPLOYMENT_NAME"),
131+
verbose: true,
132+
isLoggingEnabled: false,
133+
},
134+
});
85135
// Assert prediction type
86136
assert.equal(message.kind, "ConversationResult");
87137
assert.exists(message.result.query);
@@ -112,7 +162,24 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
112162
});
113163

114164
it("Test Orchestration App QnA Response", async function () {
115-
const message = await client.analyzeConversation(conv4);
165+
const message = await client.analyzeConversation({
166+
kind: "Conversation",
167+
analysisInput: {
168+
conversationItem: {
169+
participantId: "1",
170+
id: "1",
171+
modality: "text",
172+
language: "en",
173+
text: "How are you?",
174+
},
175+
},
176+
parameters: {
177+
projectName: assertEnvironmentVariable("LANGUAGE_ORCHESTRATION_PROJECT_NAME"),
178+
deploymentName: assertEnvironmentVariable("LANGUAGE_ORCHESTRATION_DEPLOYMENT_NAME"),
179+
verbose: true,
180+
isLoggingEnabled: false,
181+
},
182+
});
116183
// Assert prediction type
117184
assert.equal(message.kind, "ConversationResult");
118185
assert.exists(message.result.query);
@@ -140,7 +207,56 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
140207

141208
describe("#async", () => {
142209
it("Test Conversation App PII transcript", async function () {
143-
const poller = await client.beginConversationAnalysis(conv5);
210+
const poller = await client.beginConversationAnalysis({
211+
displayName: "Analyze PII in conversation",
212+
analysisInput: {
213+
conversations: [
214+
{
215+
conversationItems: [
216+
{
217+
id: "1",
218+
participantId: "0",
219+
modality: "transcript",
220+
text: "It is john doe.",
221+
lexical: "It is john doe",
222+
itn: "It is john doe",
223+
maskedItn: "It is john doe",
224+
},
225+
{
226+
id: "2",
227+
participantId: "1",
228+
modality: "transcript",
229+
text: "Yes, 633-27-8199 is my phone",
230+
lexical: "yes six three three two seven eight one nine nine is my phone",
231+
itn: "yes 633278199 is my phone",
232+
maskedItn: "yes 633278199 is my phone",
233+
},
234+
{
235+
id: "3",
236+
participantId: "1",
237+
modality: "transcript",
238+
text: "j.doe@yahoo.com is my email",
239+
lexical: "j dot doe at yahoo dot com is my email",
240+
maskedItn: "j.doe@yahoo.com is my email",
241+
itn: "j.doe@yahoo.com is my email",
242+
},
243+
],
244+
modality: "transcript",
245+
id: "1",
246+
language: "en",
247+
},
248+
],
249+
},
250+
tasks: [
251+
{
252+
kind: "ConversationalPIITask",
253+
parameters: {
254+
redactionSource: "lexical",
255+
piiCategories: ["all"],
256+
},
257+
},
258+
],
259+
});
144260
const message = await poller.pollUntilDone();
145261
// Assert main object
146262
assert.equal(message.status, "succeeded");
@@ -167,7 +283,47 @@ matrix([["APIKey"]] as const, async (authMethod: AuthMethod) => {
167283
});
168284

169285
it("Test Conversation Summarization App", async function () {
170-
const poller = await client.beginConversationAnalysis(conv6);
286+
const poller = await client.beginConversationAnalysis({
287+
displayName: "Analyze conversations from xxx",
288+
analysisInput: {
289+
conversations: [
290+
{
291+
conversationItems: [
292+
{
293+
text: "Hello, how can I help you?",
294+
modality: "text",
295+
id: "1",
296+
participantId: "Agent",
297+
},
298+
{
299+
text: "How to upgrade Office? I am getting error messages the whole day.",
300+
modality: "text",
301+
id: "2",
302+
participantId: "Customer",
303+
},
304+
{
305+
text: "Press the upgrade button please. Then sign in and follow the instructions.",
306+
modality: "text",
307+
id: "3",
308+
participantId: "Agent",
309+
},
310+
],
311+
modality: "text",
312+
id: "conversation1",
313+
language: "en",
314+
},
315+
],
316+
},
317+
tasks: [
318+
{
319+
taskName: "analyze 1",
320+
kind: "ConversationalSummarizationTask",
321+
parameters: {
322+
summaryAspects: ["Issue, Resolution"],
323+
},
324+
},
325+
],
326+
});
171327
const message = await poller.pollUntilDone();
172328
// Assert main object
173329
assert.equal(message.status, "succeeded");

0 commit comments

Comments
 (0)