-
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
16b5032
ab2596a
4794f65
26d4f9e
627f528
3a8aaa4
e86cc49
ea11cf5
5b7df54
9e41704
14ded14
19dd8c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <!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, createSendBoxPolymiddlewareFromLegacy, sendBoxComponent } | ||
| } | ||
| } = window; | ||
|
|
||
| const { directLine, store } = createDirectLineEmulator(); | ||
|
|
||
| const Downstream = () => createElement('div', {}, '<Downstream />'); | ||
|
|
||
| const polymiddleware = [ | ||
| createSendBoxPolymiddlewareFromLegacy(() => next => request => { | ||
| const child = next(request); | ||
| return () => createElement('div', { style: { border: 'solid 2px blue' } }, child?.()); | ||
| }), | ||
| createSendBoxPolymiddleware(next => request => sendBoxComponent(Downstream)) | ||
| ]; | ||
|
|
||
| WebChat.renderWebChat( | ||
| { | ||
| directLine, | ||
| polymiddleware, | ||
| store | ||
| }, | ||
| document.getElementById('webchat') | ||
| ); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| await host.snapshot('local'); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should run the test. Look at |
||
| }); | ||
| </script> | ||
| </body> | ||
| </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, memo } from 'react'; | ||
|
|
||
| run(async function () { | ||
| const { | ||
| testHelpers: { createDirectLineEmulator }, | ||
| WebChat: { | ||
| middleware: { createSendBoxPolymiddleware, sendBoxComponent } | ||
| } | ||
| } = window; | ||
|
|
||
| const { directLine, store } = createDirectLineEmulator(); | ||
|
|
||
| const MySendBox = memo(function MySendBox({ className, render }) { | ||
| return createElement('div', { className, style: { border: 'solid 2px red' } }, render({})); | ||
| }); | ||
|
|
||
| const polymiddleware = [ | ||
| createSendBoxPolymiddleware(next => request => next(request)), | ||
| createSendBoxPolymiddleware(next => request => { | ||
| const result = next(request); | ||
|
|
||
| return sendBoxComponent(MySendBox, { render: result.render }); | ||
| }) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Structure all the tests:
Then permutate it via using legacy middleware, and via using polymiddleware. Run the test after done. Look at |
||
| ]; | ||
|
|
||
| WebChat.renderWebChat( | ||
| { | ||
| directLine, | ||
| polymiddleware, | ||
| store | ||
| }, | ||
| document.getElementById('webchat') | ||
| ); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| await host.snapshot('local'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> | ||
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.
@claude[agent] Separate into 2 tests, one test the component added via legacy middleware, one test for the one via new polymiddleware.