Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
82 changes: 82 additions & 0 deletions __tests__/html2/fluentTheme/customElement/shadowRoot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></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>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
<style>
webchat-element {
display: contents;
}
</style>
</head>
<body>
<webchat-element></webchat-element>

<script type="text/babel">
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat }
} = window; // Imports in UMD fashion.

class WebChatElement extends HTMLElement {
constructor() {
super();

this.attachShadow({ mode: 'open' });
}

connectedCallback() {
const container = document.createElement('main');

container.id = 'webchat';

this.shadowRoot.appendChild(container);
this.shadowRoot.appendChild(document.head.querySelector('link').cloneNode());

const directLine = testHelpers.createDirectLineWithTranscript(
testHelpers.transcriptNavigation.generateTranscript()
);

const store = testHelpers.createStore();

const App = () => (
<ReactWebChat
directLine={directLine}
nonce="test"
store={store}
styleOptions={{ stylesRoot: this.shadowRoot }}
/>
);

render(
<FluentThemeProvider>
<App />
</FluentThemeProvider>,
container
);
}
}

run(async function () {
customElements.define('webchat-element', WebChatElement);

pageElements.root(document.querySelector('webchat-element').shadowRoot);

await pageConditions.uiConnected();
await pageConditions.scrollToBottomCompleted();
await host.snapshot('local');

for (const style of document.querySelector('webchat-element').shadowRoot.querySelectorAll('style')) {
expect(style.nonce).toBe('test');
}
});
</script>
</body>
</html>
69 changes: 69 additions & 0 deletions __tests__/html2/fluentTheme/customElement/slotted.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></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>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
<style>
webchat-element {
display: contents;
}
</style>
</head>
<body>
<webchat-element>
<main id="webchat"></main>
</webchat-element>

<script type="text/babel">
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat }
} = window; // Imports in UMD fashion.

class WebChatElement extends HTMLElement {
constructor() {
super();

this.attachShadow({ mode: 'open' });
}

connectedCallback() {
const slot = document.createElement('slot');

this.shadowRoot.appendChild(slot);

const directLine = testHelpers.createDirectLineWithTranscript(
testHelpers.transcriptNavigation.generateTranscript()
);
const store = testHelpers.createStore();

const App = () => <ReactWebChat directLine={directLine} store={store} />;

render(
<FluentThemeProvider>
<App />
</FluentThemeProvider>,
this.querySelector('#webchat')
);
}
}

run(async function () {
customElements.define('webchat-element', WebChatElement);

pageElements.root(document.querySelector('webchat-element'));

await pageConditions.uiConnected();
await pageConditions.scrollToBottomCompleted();
await host.snapshot('local');
});
</script>
</body>
</html>
Loading