Skip to content

Commit

Permalink
Bump QFE to 4.14.2 and backporting some tests (#4407)
Browse files Browse the repository at this point in the history
* Bump to 4.14.2 and fixing and backporting tests

* Backport tests
  • Loading branch information
compulim authored Sep 7, 2022
1 parent 991a74e commit 382d795
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 110 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
WebChat.renderWebChat(
{
directLine: await WebChat.createDirectLineAppServiceExtension({
domain: 'https://webchat-mockbot2.azurewebsites.net/.bot/v3/directline',
domain: 'https://webchat-mockbot3.azurewebsites.net/.bot/v3/directline',
token: await testHelpers.token.fetchDirectLineAppServiceExtensionToken()
}),
store: testHelpers.createStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{
directLine: WebChat.createDirectLine({
token: await testHelpers.token.fetchDirectLineToken(
'https://webchat-mockbot2.azurewebsites.net/api/token/directline'
'https://webchat-mockbot3.azurewebsites.net/api/token/directline'
)
}),
store: testHelpers.createStore()
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/conversationStartProperties.sendEnUs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
locale: 'en-US'
},
token: await testHelpers.token.fetchDirectLineToken(
'https://webchat-mockbot2.azurewebsites.net/api/token/directline'
'https://webchat-mockbot3.azurewebsites.net/api/token/directline'
)
}),
store: testHelpers.createStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
locale: { invalid: true }
},
token: await testHelpers.token.fetchDirectLineToken(
'https://webchat-mockbot2.azurewebsites.net/api/token/directline'
'https://webchat-mockbot3.azurewebsites.net/api/token/directline'
)
}),
store: testHelpers.createStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
locale: 'xx-YY'
},
token: await testHelpers.token.fetchDirectLineToken(
'https://webchat-mockbot2.azurewebsites.net/api/token/directline'
'https://webchat-mockbot3.azurewebsites.net/api/token/directline'
)
}),
store: testHelpers.createStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
locale: '1a2b3c'
},
token: await testHelpers.token.fetchDirectLineToken(
'https://webchat-mockbot2.azurewebsites.net/api/token/directline'
'https://webchat-mockbot3.azurewebsites.net/api/token/directline'
)
}),
store: testHelpers.createStore()
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/conversationStartProperties.sendZhCn.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
locale: 'zh-CN'
},
token: await testHelpers.token.fetchDirectLineToken(
'https://webchat-mockbot2.azurewebsites.net/api/token/directline'
'https://webchat-mockbot3.azurewebsites.net/api/token/directline'
)
}),
store: testHelpers.createStore()
Expand Down
13 changes: 10 additions & 3 deletions __tests__/html/localization.fileUpload.polish.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
<body>
<div id="webchat"></div>
<script>
run(async function () {
const clock = lolex.install();

run(async function () {
const directLine = testHelpers.createDirectLineWithTranscript([
{
type: 'message',
id: 'A0000001',
timestamp: '2022-09-06T20:49:30.3628667Z',
localTimestamp: '2022-09-06T13:49:29.166-07:00',
timestamp: '2000-01-23T12:34:56.12345Z',
localTimestamp: '2000-01-23T12:34:56.12345Z',
localTimezone: 'America/Los_Angeles',
channelId: 'directline',
from: {
Expand Down Expand Up @@ -47,6 +49,11 @@
document.getElementById('webchat')
);

await pageConditions.webChatRendered();

// Wait for "Connecting..." message to dismiss
clock.tick(600);

await pageConditions.uiConnected();
await host.snapshot();
});
Expand Down
1 change: 1 addition & 0 deletions __tests__/setup/setupTestNightly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test.nightly = process.env.CI_PULL_REQUEST ? test.skip.bind(test) : test;
2 changes: 1 addition & 1 deletion __tests__/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test('video', async () => {
await driver.sleep(4000);

// Pause the video
await clickButton(driver, By.css('button[aria-label="Pause (k)"]'));
await clickButton(driver, By.css('button[title="Pause (k)"]'));

// Jump back for 10 seconds, to get the buffering bar the same
await driver.actions().sendKeys('j').perform();
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ module.exports = {
'<rootDir>/__tests__/setup/setupGlobalAgent.js',
'<rootDir>/__tests__/setup/preSetupTestFramework.js',
'<rootDir>/__tests__/setup/setupImageSnapshot.js',
'<rootDir>/__tests__/setup/setupTestNightly.js',
'<rootDir>/__tests__/setup/setupTimeout.js'
],
testPathIgnorePatterns: [
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botframework-webchat-root",
"version": "4.14.1",
"version": "4.14.2",
"private": true,
"files": [
"lib/**/*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'global-agent/bootstrap';

import { PropertyId } from 'microsoft-cognitiveservices-speech-sdk';
import { timeouts } from './constants.json';
import createTestHarness from './utilities/createTestHarness';
import MockAudioContext from './utilities/MockAudioContext';
Expand Down Expand Up @@ -35,7 +34,11 @@ async function waitUntil(fn, timeout = 5000, intervalMS = 1000) {
throw new Error('timed out');
}

test('should refresh authorization token', async () => {
test.nightly('should refresh authorization token', async () => {
if (!process.env.SPEECH_SERVICES_SUBSCRIPTION_KEY) {
throw new Error('"SPEECH_SERVICES_SUBSCRIPTION_KEY" environment variable must be set.');
}

jest.useFakeTimers('modern');

const { directLine } = await createTestHarness();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,22 @@ async function waitUntil(fn, timeout = 5000, intervalMS = 1000) {
throw new Error('timed out');
}

test('should refresh Direct Line token', async () => {
test.nightly('should refresh Direct Line token', async () => {
if (!process.env.SPEECH_SERVICES_SUBSCRIPTION_KEY) {
throw new Error('"SPEECH_SERVICES_SUBSCRIPTION_KEY" environment variable must be set.');
}

jest.useFakeTimers('modern');

const { directLine } = await createTestHarness({ enableInternalHTTPSupport: true });
const initialToken = directLine.dialogServiceConnector.properties.getProperty(PropertyId.Conversation_Agent_Connection_Id);

// We need to start the conversation, such as POST /conversations.
// Otherwise, refreshing token will say "conversation not found".
directLine.postActivity({
type: 'event'
});

// Wait until 2 seconds in real-time clock, to make sure the token renewed is different (JWT has a per-second timestamp).
await sleep(2000);

Expand Down
101 changes: 56 additions & 45 deletions packages/directlinespeech/__tests__/sendSpeechActivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,77 @@ beforeEach(() => {
global.AudioContext = MockAudioContext;
});

describe.each([['without internal HTTP support'], ['with internal HTTP support', { enableInternalHTTPSupport: true }]])(
'%s',
(_, testHarnessOptions) => {
test('should echo back when saying "hello" and "world"', async () => {
const { directLine, fetchCredentials, sendTextAsSpeech } = await createTestHarness(testHarnessOptions);
// TODO: [P2] #4053 Temporarily disable "internal HTTP" test until service recovered.
// describe.each([['without internal HTTP support'], ['with internal HTTP support', { enableInternalHTTPSupport: true }]])(
describe.each([['without internal HTTP support']])('%s', (_, testHarnessOptions) => {
test.nightly('should echo back when saying "hello" and "world"', async () => {
if (!process.env.SPEECH_SERVICES_SUBSCRIPTION_KEY) {
throw new Error('"SPEECH_SERVICES_SUBSCRIPTION_KEY" environment variable must be set.');
}

const connectedPromise = waitForConnected(directLine);
const activitiesPromise = subscribeAll(take(directLine.activity$, 2));
const { directLine, fetchCredentials, sendTextAsSpeech } = await createTestHarness(testHarnessOptions);

await connectedPromise;
const connectedPromise = waitForConnected(directLine);
const activitiesPromise = subscribeAll(take(directLine.activity$, 2));

await sendTextAsSpeech('hello');
await sendTextAsSpeech('world');
await connectedPromise;

const activities = await activitiesPromise;
const activityUtterances = Promise.all(
activities.map(activity => recognizeActivityAsText(activity, { fetchCredentials }))
);
await sendTextAsSpeech('hello');
await sendTextAsSpeech('world');

await expect(activityUtterances).resolves.toEqual(['Hello.', 'World.']);
});
const activities = await activitiesPromise;
const activityUtterances = Promise.all(
activities.map(activity => recognizeActivityAsText(activity, { fetchCredentials }))
);

test('should echo back "Bellevue" when saying "bellview"', async () => {
const { directLine, fetchCredentials, sendTextAsSpeech } = await createTestHarness(testHarnessOptions);
await expect(activityUtterances).resolves.toEqual(['Hello.', 'World.']);
});

const connectedPromise = waitForConnected(directLine);
const activitiesPromise = subscribeAll(take(directLine.activity$, 1));
test.nightly('should echo back "Bellevue" when saying "bellview"', async () => {
if (!process.env.SPEECH_SERVICES_SUBSCRIPTION_KEY) {
throw new Error('"SPEECH_SERVICES_SUBSCRIPTION_KEY" environment variable must be set.');
}

await connectedPromise;
const { directLine, fetchCredentials, sendTextAsSpeech } = await createTestHarness(testHarnessOptions);

await sendTextAsSpeech('bellview');
const connectedPromise = waitForConnected(directLine);
const activitiesPromise = subscribeAll(take(directLine.activity$, 1));

const activities = await activitiesPromise;
const activityUtterances = Promise.all(
activities.map(activity => recognizeActivityAsText(activity, { fetchCredentials }))
);
await connectedPromise;

await expect(activityUtterances).resolves.toEqual(['Bellevue.']);
});
}
);
await sendTextAsSpeech('bellview');

// TODO: Re-enable this test for "enableInternalHttpSupport = true" once DLS bug fix is lit up in production.
// 2020-05-11: Direct Line Speech protocol was updated to synthesize "text" if "speak" property is not set.
test('should synthesis if "speak" is empty', async () => {
const { directLine, fetchCredentials, sendTextAsSpeech } = await createTestHarness();
const activities = await activitiesPromise;
const activityUtterances = Promise.all(
activities.map(activity => recognizeActivityAsText(activity, { fetchCredentials }))
);

const connectedPromise = waitForConnected(directLine);
const activitiesPromise = subscribeAll(take(directLine.activity$, 1));
await expect(activityUtterances).resolves.toEqual(['Bellevue.']);
});

await connectedPromise;
// TODO: Re-enable this test for "enableInternalHttpSupport = true" once DLS bug fix is lit up in production.
// 2020-05-11: Direct Line Speech protocol was updated to synthesize "text" if "speak" property is not set.
test.nightly('should synthesis if "speak" is empty', async () => {
if (!process.env.SPEECH_SERVICES_SUBSCRIPTION_KEY) {
throw new Error('"SPEECH_SERVICES_SUBSCRIPTION_KEY" environment variable must be set.');
}

// "Don't speak XXX" command will not send "speak" property on respond.
await sendTextAsSpeech("Don't speak anything.");
const { directLine, fetchCredentials, sendTextAsSpeech } = await createTestHarness(testHarnessOptions);

const activities = await activitiesPromise;
const activityUtterances = await Promise.all(
activities.map(activity => recognizeActivityAsText(activity, { fetchCredentials }))
);
const connectedPromise = waitForConnected(directLine);
const activitiesPromise = subscribeAll(take(directLine.activity$, 1));

// Despite it does not have "speak" property, Direct Line Speech protocol will fallback to "text" property for synthesize.
expect(activityUtterances).toEqual([`Don't speak anything.`]);
await connectedPromise;

// "Don't speak XXX" command will not send "speak" property on respond.
await sendTextAsSpeech("Don't speak anything.");

const activities = await activitiesPromise;
const activityUtterances = await Promise.all(
activities.map(activity => recognizeActivityAsText(activity, { fetchCredentials }))
);

// Despite it does not have "speak" property, Direct Line Speech protocol will fallback to "text" property for synthesize.
expect(activityUtterances).toEqual([`Don't speak anything.`]);
});
});
Loading

0 comments on commit 382d795

Please sign in to comment.