Skip to content

Commit

Permalink
Migrate test
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed Apr 6, 2024
1 parent 5410127 commit 6dd7059
Show file tree
Hide file tree
Showing 28 changed files with 490 additions and 311 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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions __tests__/html/upload/uploadPlainTextFile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
const store = testHelpers.createStore();

WebChat.renderWebChat(
{
directLine,
store
},
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await pageObjects.uploadFile('empty.txt');
await host.click(pageElements.sendButton());

await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/upload/uploadPlainTextFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('upload a plain text file', () => {
test('should send', () => runHTML('upload/uploadPlainTextFile'));
});
36 changes: 36 additions & 0 deletions __tests__/html/upload/uploadZipFile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
const store = testHelpers.createStore();

WebChat.renderWebChat(
{
directLine,
store
},
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await pageObjects.uploadFile('empty.zip');
await host.click(pageElements.sendButton());

await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/upload/uploadZipFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('upload a zip file', () => {
test('should send', () => runHTML('upload/uploadZipFile'));
});
39 changes: 39 additions & 0 deletions __tests__/html/upload/withWebWorker/customThumbnailQuality.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
const store = testHelpers.createStore();

WebChat.renderWebChat(
{
directLine,
store,
styleOptions: {
uploadThumbnailQuality: 0.1
}
},
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await pageObjects.uploadFile('seaofthieves.jpg');
await host.click(pageElements.sendButton());

await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/upload/withWebWorker/customThumbnailQuality.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('with Web Worker upload a picture with custom thumbnail quality', () => {
test('should send', () => runHTML('upload/withWebWorker/customThumbnailQuality'));
});
41 changes: 41 additions & 0 deletions __tests__/html/upload/withWebWorker/customThumbnailSize.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
const store = testHelpers.createStore();

WebChat.renderWebChat(
{
directLine,
store,
styleOptions: {
uploadThumbnailContentType: 'image/png',
uploadThumbnailHeight: 60,
uploadThumbnailWidth: 120
}
},
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await pageObjects.uploadFile('seaofthieves.jpg');
await host.click(pageElements.sendButton());

await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/upload/withWebWorker/customThumbnailSize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('with Web Worker upload a picture with custom thumbnail size', () => {
test('should send', () => runHTML('upload/withWebWorker/customThumbnailSize'));
});
132 changes: 132 additions & 0 deletions __tests__/html/upload/withWebWorker/withTelemetry.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
const store = testHelpers.createStore();

const telemetryMeasurements = [];

WebChat.renderWebChat(
{
directLine,
store,
onTelemetry: event => {
const { data, dimensions, duration, error, fatal, name, type, value } = event;

telemetryMeasurements.push({
data,
dimensions,
duration,
error,
fatal,
name,
type,
value
});
}
},
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await pageObjects.uploadFile('seaofthieves.jpg');
await host.click(pageElements.sendButton());

await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();

const sendFileTelemetryMeasurements = telemetryMeasurements.filter(({ name }) =>
['init', 'sendFiles:makeThumbnail', 'submitSendBox'].includes(name)
);

expect(sendFileTelemetryMeasurements).toHaveProperty('length', 4);
expect(sendFileTelemetryMeasurements[2]).toHaveProperty('name', 'sendFiles:makeThumbnail');
expect(sendFileTelemetryMeasurements[2]).toHaveProperty('type', 'timingend');

sendFileTelemetryMeasurements[2].duration = 1000;

expect(sendFileTelemetryMeasurements).toEqual([
{
data: undefined,
dimensions: {
'capability:downscaleImage:workerType': 'web worker',
'capability:renderer': 'html',
'prop:locale': 'en-US',
'prop:speechRecognition': 'false',
'prop:speechSynthesis': 'false'
},
duration: undefined,
error: undefined,
fatal: undefined,
name: 'init',
type: 'event',
value: undefined
},
{
data: undefined,
dimensions: {
'capability:downscaleImage:workerType': 'web worker',
'capability:renderer': 'html',
'prop:locale': 'en-US',
'prop:speechRecognition': 'false',
'prop:speechSynthesis': 'false'
},
duration: undefined,
error: undefined,
fatal: undefined,
name: 'sendFiles:makeThumbnail',
type: 'timingstart',
value: undefined
},
{
data: undefined,
dimensions: {
'capability:downscaleImage:workerType': 'web worker',
'capability:renderer': 'html',
'prop:locale': 'en-US',
'prop:speechRecognition': 'false',
'prop:speechSynthesis': 'false'
},
duration: 1000,
error: undefined,
fatal: undefined,
name: 'sendFiles:makeThumbnail',
type: 'timingend',
value: undefined
},
{
data: {
numFiles: 1,
sumSizeInKB: 379
},
dimensions: {
'capability:downscaleImage:workerType': 'web worker',
'capability:renderer': 'html',
'prop:locale': 'en-US',
'prop:speechRecognition': 'false',
'prop:speechSynthesis': 'false'
},
duration: undefined,
error: undefined,
fatal: undefined,
name: 'submitSendBox',
type: 'event',
value: undefined
}
]);

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/upload/withWebWorker/withTelemetry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('with Web Worker upload a picture', () => {
test('should send telemetry', () => runHTML('upload/withWebWorker/withTelemetry'));
});
39 changes: 39 additions & 0 deletions __tests__/html/upload/withWebWorker/withoutThumbnail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
const directLine = WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() });
const store = testHelpers.createStore();

WebChat.renderWebChat(
{
directLine,
store,
styleOptions: {
enableUploadThumbnail: false
}
},
document.getElementById('webchat')
);

await pageConditions.uiConnected();

await pageObjects.uploadFile('seaofthieves.jpg');
await host.click(pageElements.sendButton());

await pageConditions.minNumActivitiesShown(2);
await pageConditions.allImagesLoaded();

await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/upload/withWebWorker/withoutThumbnail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('with Web Worker upload a picture without thumbnail', () => {
test('should send', () => runHTML('upload/withWebWorker/withoutThumbnail'));
});
Loading

0 comments on commit 6dd7059

Please sign in to comment.