forked from microsoft/BotFramework-WebChat
-
Notifications
You must be signed in to change notification settings - Fork 3
Fix sendBox polymiddleware tests and formatting #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Claude
wants to merge
12
commits into
main
Choose a base branch
from
claude/port-sendbox-middleware
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
16b5032
Initial plan
Claude ab2596a
Port sendBoxMiddleware to polymiddleware infrastructure
Claude 4794f65
Fix type imports and add test files for sendBox polymiddleware
Claude 26d4f9e
Fix legacy sendBox bridge types and build errors
Claude 627f528
Update deprecation dates, fix error message case, add displayName, re…
Claude 3a8aaa4
Add comprehensive test suite for sendBox middleware patterns
Claude e86cc49
Port sendBoxMiddleware to polymiddleware infrastructure
Claude ea11cf5
Add middleware exports to bundle and split legacyToPolymiddleware test
Claude 5b7df54
Fix sendBox polymiddleware signature and update snapshot names
Claude 9e41704
Addressing PR comments
Claude 14ded14
Wire up sendBox polymiddleware to replace template middleware
Claude 19dd8c8
Fix sendBox polymiddleware tests and formatting
Claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+4.82 KB
...nt-html-html-2-middleware-send-box-polymiddleware-add-component-html-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.82 KB
...leware-send-box-legacy-send-box-middleware-legacy-add-component-html-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions
59
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/add.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Binary file added
BIN
+4.82 KB
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/add.html.snap-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions
56
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/change.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Binary file added
BIN
+4.82 KB
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/change.html.snap-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions
54
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/decorate.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Binary file added
BIN
+4.82 KB
...sts__/html2/middleware/sendBox/legacySendBoxMiddleware/decorate.html.snap-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions
54
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/legacyAddComponent.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> | ||
52 changes: 52 additions & 0 deletions
52
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/remove.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Binary file added
BIN
+4.82 KB
__tests__/html2/middleware/sendBox/legacySendBoxMiddleware/remove.html.snap-1.png
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
60
__tests__/html2/middleware/sendBox/polymiddleware/add.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Binary file added
BIN
+4.82 KB
__tests__/html2/middleware/sendBox/polymiddleware/add.html.snap-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions
53
__tests__/html2/middleware/sendBox/polymiddleware/addComponent.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.