Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
@@ -0,0 +1,59 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1"
}
}
</script>
<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 type="module">
import { createElement } from 'react';

run(async function () {
const {
testHelpers: { createDirectLineEmulator },
WebChat: {
middleware: { createSendBoxPolymiddlewareFromLegacy }
}
} = window;

const { directLine, store } = createDirectLineEmulator();

const AdditionalComponent = () => createElement('div', { style: { border: 'solid 2px green', padding: '10px' } }, 'Additional Component');

const polymiddleware = [
createSendBoxPolymiddlewareFromLegacy(() => next => () => {
const child = next();
return () => createElement('div', {}, [
child?.(),
createElement(AdditionalComponent, { key: 'additional' })
]);
})
];

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

await pageConditions.uiConnected();

await host.snapshot('local');
});
</script>
</body>
</html>
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
@@ -0,0 +1,56 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1"
}
}
</script>
<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 type="module">
import { createElement } from 'react';

run(async function () {
const {
testHelpers: { createDirectLineEmulator },
WebChat: {
middleware: { createSendBoxPolymiddlewareFromLegacy }
}
} = window;

const { directLine, store } = createDirectLineEmulator();

const CustomSendBox = ({ className }) => createElement('div', { className, style: { border: 'solid 2px purple', padding: '10px' } }, 'Custom SendBox');

const polymiddleware = [
createSendBoxPolymiddlewareFromLegacy(() => next => () => {
// Replace with custom component
return () => createElement(CustomSendBox);
})
];

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

await pageConditions.uiConnected();

await host.snapshot('local');
});
</script>
</body>
</html>
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
@@ -0,0 +1,54 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1"
}
}
</script>
<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 type="module">
import { createElement } from 'react';

run(async function () {
const {
testHelpers: { createDirectLineEmulator },
WebChat: {
middleware: { createSendBoxPolymiddlewareFromLegacy }
}
} = window;

const { directLine, store } = createDirectLineEmulator();

const polymiddleware = [
createSendBoxPolymiddlewareFromLegacy(() => next => () => {
const child = next();
return () => createElement('div', { style: { border: 'solid 2px blue' } }, child?.());
})
];

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

await pageConditions.uiConnected();

await host.snapshot('local');
});
</script>
</body>
</html>
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
@@ -0,0 +1,54 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1"
}
}
</script>
<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 type="module">
import { createElement } from 'react';

run(async function () {
const {
testHelpers: { createDirectLineEmulator },
WebChat: {
middleware: { createSendBoxPolymiddlewareFromLegacy }
}
} = window;

const { directLine, store } = createDirectLineEmulator();

const sendBoxPolymiddleware = [
createSendBoxPolymiddlewareFromLegacy(() => next => request => {
const child = next(request);
return () => createElement('div', { style: { border: 'solid 2px blue' } }, child?.());
})
];

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

await pageConditions.uiConnected();

await host.snapshot('local');
});
</script>
</body>
</html>
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
@@ -0,0 +1,52 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1"
}
}
</script>
<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 type="module">
run(async function () {
const {
testHelpers: { createDirectLineEmulator },
WebChat: {
middleware: { createSendBoxPolymiddlewareFromLegacy }
}
} = window;

const { directLine, store } = createDirectLineEmulator();

const polymiddleware = [
createSendBoxPolymiddlewareFromLegacy(() => next => () => {
// Don't call next, effectively removing the sendbox
return () => null;
})
];

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

await pageConditions.uiConnected();

await host.snapshot('local');
});
</script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions __tests__/html2/middleware/sendBox/polymiddleware/add.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1"
}
}
</script>
<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 type="module">
import { createElement } from 'react';

run(async function () {
const {
testHelpers: { createDirectLineEmulator },
WebChat: {
middleware: { createSendBoxPolymiddleware, sendBoxComponent }
}
} = window;

const { directLine, store } = createDirectLineEmulator();

const AdditionalComponent = () => createElement('div', { style: { border: 'solid 2px green', padding: '10px' } }, 'Additional Component');

const polymiddleware = [
createSendBoxPolymiddleware(next => () => {
const result = next();

return sendBoxComponent(() => createElement('div', {}, [
result?.render({}),
createElement(AdditionalComponent, { key: 'additional' })
]));
})
];

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

await pageConditions.uiConnected();

await host.snapshot('local');
});
</script>
</body>
</html>
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
@@ -0,0 +1,53 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/react@18.3.1"
}
}
</script>
<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 type="module">
import { createElement } from 'react';

run(async function () {
const {
testHelpers: { createDirectLineEmulator },
WebChat: {
middleware: { createSendBoxPolymiddleware, sendBoxComponent }
}
} = window;

const { directLine, store } = createDirectLineEmulator();

const Downstream = () => createElement('div', {}, '<Downstream />');

const polymiddleware = [
createSendBoxPolymiddleware(next => () => sendBoxComponent(Downstream))
];

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

await pageConditions.uiConnected();

await host.snapshot('local');
});
</script>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading