1+ <!doctype html>
2+ < html lang ="en-US ">
3+ < head >
4+ < link href ="/assets/index.css " rel ="stylesheet " type ="text/css " />
5+ < script crossorigin ="anonymous " src ="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js "> </ script >
6+ < script crossorigin ="anonymous " src ="https://unpkg.com/react@16.8.6/umd/react.production.min.js "> </ script >
7+ < script crossorigin ="anonymous " src ="https://unpkg.com/react-dom@16.8.6/umd/react-dom.production.min.js "> </ script >
8+ < script crossorigin ="anonymous " src ="/test-harness.js "> </ script >
9+ < script crossorigin ="anonymous " src ="/test-page-object.js "> </ script >
10+ < script crossorigin ="anonymous " src ="/__dist__/webchat-es5.js "> </ script >
11+ < script crossorigin ="anonymous " src ="/__dist__/botframework-webchat-fluent-theme.production.min.js "> </ script >
12+ < style >
13+ webchat-element {
14+ display : contents;
15+ }
16+ </ style >
17+ </ head >
18+ < body >
19+ < webchat-element > </ webchat-element >
20+
21+ < script type ="text/babel ">
22+ const {
23+ React,
24+ ReactDOM : { render } ,
25+ WebChat : { FluentThemeProvider, ReactWebChat }
26+ } = window ; // Imports in UMD fashion.
27+
28+ class WebChatElement extends HTMLElement {
29+ constructor ( ) {
30+ super ( ) ;
31+
32+ this . attachShadow ( { mode : 'open' } ) ;
33+ }
34+
35+ connectedCallback ( ) {
36+ const container = document . createElement ( 'main' ) ;
37+
38+ container . id = 'webchat' ;
39+
40+ this . shadowRoot . appendChild ( container ) ;
41+ this . shadowRoot . appendChild ( document . head . querySelector ( 'link' ) . cloneNode ( ) ) ;
42+
43+ const directLine = testHelpers . createDirectLineWithTranscript (
44+ testHelpers . transcriptNavigation . generateTranscript ( )
45+ ) ;
46+
47+ const store = testHelpers . createStore ( ) ;
48+
49+ const App = ( ) => (
50+ < ReactWebChat
51+ directLine = { directLine }
52+ nonce = "test"
53+ store = { store }
54+ styleOptions = { { stylesRoot : this . shadowRoot } }
55+ />
56+ ) ;
57+
58+ render (
59+ < FluentThemeProvider >
60+ < App />
61+ </ FluentThemeProvider > ,
62+ container
63+ ) ;
64+ }
65+ }
66+
67+ run ( async function ( ) {
68+ customElements . define ( 'webchat-element' , WebChatElement ) ;
69+
70+ pageElements . root ( document . querySelector ( 'webchat-element' ) . shadowRoot ) ;
71+
72+ await pageConditions . uiConnected ( ) ;
73+ await pageConditions . scrollToBottomCompleted ( ) ;
74+ await host . snapshot ( 'local' ) ;
75+
76+ for ( const style of document . querySelector ( 'webchat-element' ) . shadowRoot . querySelectorAll ( 'style' ) ) {
77+ expect ( style . nonce ) . toBe ( 'test' ) ;
78+ }
79+ } ) ;
80+ </ script >
81+ </ body >
82+ </ html >
0 commit comments