Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 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('legacy-component');
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await host.snapshot('legacy-component');
await host.snapshot('local');

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 5b7df54. Changed snapshot name to 'local' for consistency.

});
</script>
</body>
</html>
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 sendBoxPolymiddleware = [
createSendBoxPolymiddleware(next => request => sendBoxComponent(Downstream))
];

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

await pageConditions.uiConnected();

await host.snapshot('poly-component');
});
</script>
</body>
</html>
Loading