diff --git a/.dockerignore b/.dockerignore index caf903d478..6b6bad8a7d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,5 +10,6 @@ !/packages/test/fluent-bundle/dist !/packages/test/harness/dist !/packages/test/page-object/dist +!/packages/test/test-assets/out !/packages/test/web-server/dist !/serve-test.json diff --git a/.github/workflows/pull-request-validation.yml b/.github/workflows/pull-request-validation.yml index 1971e4aee2..13163b6857 100644 --- a/.github/workflows/pull-request-validation.yml +++ b/.github/workflows/pull-request-validation.yml @@ -66,6 +66,7 @@ jobs: ./packages/fluent-theme/static/ ./packages/test/harness/ ./packages/test/page-object/dist/ + ./packages/test/test-assets/out/ ./packages/test/web-server/dist/ ./serve-test.json ./testharness.dockerfile diff --git a/CHANGELOG.md b/CHANGELOG.md index 45d7fadba0..0211438d6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -319,6 +319,7 @@ Breaking changes in this release: - Activity status, in PR [#5669](https://github.com/microsoft/BotFramework-WebChat/pull/5669), by [@OEvgeny](https://github.com/OEvgeny) - Text attachment and related components, in PR [#5670](https://github.com/microsoft/BotFramework-WebChat/pull/5670), by [@OEvgeny](https://github.com/OEvgeny) - (Experimental) Added custom variants support for `botframework-webchat-fluent-theme` package, in PR [#5675](https://github.com/microsoft/BotFramework-WebChat/pull/5675), by [@OEvgeny](https://github.com/OEvgeny) +- Improved adaptive cards rendering in copilot variant, in PR [#5682](https://github.com/microsoft/BotFramework-WebChat/pull/5682), by [@OEvgeny](https://github.com/OEvgeny) ### Deprecated diff --git a/__tests__/assets/custom-element/custom-element.js b/__tests__/assets/custom-element/custom-element.js index f3ffb99f14..6fd234beb7 100644 --- a/__tests__/assets/custom-element/custom-element.js +++ b/__tests__/assets/custom-element/custom-element.js @@ -1,23 +1,5 @@ /* eslint-env browser */ -// #region TODO: Remove me after we bump Chrome to v117+ -const customElementNames = customElements.getName instanceof Function ? null : new WeakMap(); - -export function getCustomElementName(customElementConstructor) { - if (customElementNames) { - return customElementNames.get(customElementConstructor); - } - return customElements.getName(customElementConstructor); -} - -function setCustomElementName(customElementConstructor, name) { - if (customElementNames) { - customElementNames.set(customElementConstructor, name); - } - // No need to set for browsers that support customElements.getName() -} -// #endregion - export function customElement(elementKey, createElementClass) { const elementRegistration = document.querySelector(`element-registration[element-key="${elementKey}"]`); elementRegistration.elementConstructor = createElementClass(elementRegistration); @@ -73,7 +55,6 @@ function initDocument(elementRegistration, currentDocument) { } customElements.define(elementName, constructor, constructor.options); - setCustomElementName(constructor, elementName); result.resolve(constructor); }, diff --git a/__tests__/assets/custom-element/keyboard-event.ce.html b/__tests__/assets/custom-element/keyboard-event.ce.html index 8396000302..44cb1735a5 100644 --- a/__tests__/assets/custom-element/keyboard-event.ce.html +++ b/__tests__/assets/custom-element/keyboard-event.ce.html @@ -106,7 +106,7 @@ + + \ No newline at end of file diff --git a/__tests__/assets/esm/postActivity.js b/__tests__/assets/esm/postActivity.js new file mode 100644 index 0000000000..017e5e5599 --- /dev/null +++ b/__tests__/assets/esm/postActivity.js @@ -0,0 +1,18 @@ +export function postActivity(adapter, activityOrString) { + const activityTemplate = { + type: 'message', + from: { id: 'user', name: 'User', role: 'user' }, + timestamp: new Date().toISOString() + }; + + return new Promise((resolve, reject) => + adapter + .postActivity( + Object.assign( + activityTemplate, + typeof activityOrString === 'string' ? { text: activityOrString } : activityOrString + ) + ) + .subscribe(resolve, reject) + ); +} diff --git a/__tests__/assets/esm/test.js b/__tests__/assets/esm/test.js new file mode 100644 index 0000000000..0bbc28e06d --- /dev/null +++ b/__tests__/assets/esm/test.js @@ -0,0 +1,25 @@ +/* eslint-env browser */ +import '/test-harness.mjs'; +import '/test-page-object.mjs'; +import * as WebChat from 'botframework-webchat'; + +Object.assign(window, { WebChat }); + +const createHostStub = (host = {}) => ({ + ...Object.fromEntries( + Object.keys(host).map(methodName => [ + methodName, + // eslint-disable-next-line no-console + (...args) => console.info(`host.${methodName}()`, ...args) + ]) + ), + run: fn => fn() +}); + +const isWebDriver = !!navigator.webdriver; + +export const host = isWebDriver ? window.host : createHostStub(window.host); + +export const { pageConditions, testHelpers } = window; + +export const run = host.run || window.run; diff --git a/__tests__/html2/activity/collapsible.copilot.dark.html.snap-8.png b/__tests__/html2/activity/collapsible.copilot.dark.html.snap-8.png index b3aa781b22..eaee7c14e5 100644 Binary files a/__tests__/html2/activity/collapsible.copilot.dark.html.snap-8.png and b/__tests__/html2/activity/collapsible.copilot.dark.html.snap-8.png differ diff --git a/__tests__/html2/activity/collapsible.copilot.html.snap-8.png b/__tests__/html2/activity/collapsible.copilot.html.snap-8.png index 88a53ac851..97b25da0d6 100644 Binary files a/__tests__/html2/activity/collapsible.copilot.html.snap-8.png and b/__tests__/html2/activity/collapsible.copilot.html.snap-8.png differ diff --git a/__tests__/html2/activity/collapsible.html b/__tests__/html2/activity/collapsible.html index 8611aeda1b..8799573a37 100644 --- a/__tests__/html2/activity/collapsible.html +++ b/__tests__/html2/activity/collapsible.html @@ -6,11 +6,13 @@ @@ -34,10 +36,11 @@
diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html new file mode 100644 index 0000000000..0fc5a40487 --- /dev/null +++ b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html @@ -0,0 +1,10 @@ + + + + Attachment AdaptiveCard: custom (copilot, dark) + + + + diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-1.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-1.png new file mode 100644 index 0000000000..9f998c525a Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-1.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-2.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-2.png new file mode 100644 index 0000000000..5b08dc0a24 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-2.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-3.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-3.png new file mode 100644 index 0000000000..fd16444267 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-3.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-4.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-4.png new file mode 100644 index 0000000000..113c1dd9f6 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.dark.html.snap-4.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.html b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html new file mode 100644 index 0000000000..6d76613f43 --- /dev/null +++ b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html @@ -0,0 +1,10 @@ + + + + Attachment AdaptiveCard: custom (copilot) + + + + diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-1.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-1.png new file mode 100644 index 0000000000..a3ca349d7d Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-1.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-2.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-2.png new file mode 100644 index 0000000000..7e05883fdf Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-2.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-3.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-3.png new file mode 100644 index 0000000000..889270e68b Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-3.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-4.png b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-4.png new file mode 100644 index 0000000000..57a36489f0 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.copilot.html.snap-4.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html new file mode 100644 index 0000000000..3c6befd725 --- /dev/null +++ b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html @@ -0,0 +1,10 @@ + + + + Attachment AdaptiveCard: custom (fluent, dark) + + + + diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-1.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-1.png new file mode 100644 index 0000000000..abec961421 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-1.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-2.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-2.png new file mode 100644 index 0000000000..70efa01ad8 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-2.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-3.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-3.png new file mode 100644 index 0000000000..c8c1d9cbb4 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-3.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-4.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-4.png new file mode 100644 index 0000000000..867d54468a Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.dark.html.snap-4.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.html b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html new file mode 100644 index 0000000000..8c4c849149 --- /dev/null +++ b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html @@ -0,0 +1,10 @@ + + + + Attachment AdaptiveCard: custom (fluent) + + + + diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-1.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-1.png new file mode 100644 index 0000000000..c9494b3810 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-1.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-2.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-2.png new file mode 100644 index 0000000000..8cb75cb818 Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-2.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-3.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-3.png new file mode 100644 index 0000000000..ecc2da5f7c Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-3.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-4.png b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-4.png new file mode 100644 index 0000000000..9fabe4315f Binary files /dev/null and b/__tests__/html2/attachment/adaptiveCard/custom.fluent.html.snap-4.png differ diff --git a/__tests__/html2/attachment/adaptiveCard/custom.skip.html b/__tests__/html2/attachment/adaptiveCard/custom.skip.html new file mode 100644 index 0000000000..3ccbc3f4d6 --- /dev/null +++ b/__tests__/html2/attachment/adaptiveCard/custom.skip.html @@ -0,0 +1,186 @@ + + + + + + + Attachment AdaptiveCard: custom + + + + + +
+ +
+
+
+ + + + + \ No newline at end of file diff --git a/__tests__/html2/basic/customIcons.html b/__tests__/html2/basic/customIcons.html index f875c9b113..cfd003c8be 100644 --- a/__tests__/html2/basic/customIcons.html +++ b/__tests__/html2/basic/customIcons.html @@ -8,8 +8,7 @@ "imports": { "react": "https://esm.sh/react@18.3.1", "react-dom": "https://esm.sh/react-dom@18.3.1", - "react-dom/": "https://esm.sh/react-dom@18.3.1/", - "@fluentui/react-components": "https://esm.sh/@fluentui/react-components?deps=react@18.3.1&exports=FluentProvider,createDarkTheme,webLightTheme" + "react-dom/": "https://esm.sh/react-dom@18.3.1/" } } diff --git a/__tests__/html2/citation/url.html b/__tests__/html2/citation/url.html index 780978635a..a0174a9403 100644 --- a/__tests__/html2/citation/url.html +++ b/__tests__/html2/citation/url.html @@ -7,8 +7,8 @@ diff --git a/__tests__/html2/copyButton/layout.html b/__tests__/html2/copyButton/layout.html index 248206fb08..79864d8d3d 100644 --- a/__tests__/html2/copyButton/layout.html +++ b/__tests__/html2/copyButton/layout.html @@ -6,10 +6,12 @@ @@ -32,9 +34,10 @@
diff --git a/__tests__/html2/fluentTheme/defaultFeedback.activity.html b/__tests__/html2/fluentTheme/defaultFeedback.activity.html index ce5a18bc20..65122d055b 100644 --- a/__tests__/html2/fluentTheme/defaultFeedback.activity.html +++ b/__tests__/html2/fluentTheme/defaultFeedback.activity.html @@ -7,10 +7,12 @@ @@ -32,9 +34,10 @@
@@ -34,9 +36,10 @@
@@ -31,10 +33,10 @@
@@ -30,9 +32,10 @@
@@ -30,9 +32,10 @@
@@ -26,9 +28,10 @@
@@ -37,10 +39,11 @@
diff --git a/__tests__/html2/part-grouping/navigation.html b/__tests__/html2/part-grouping/navigation.html index caac30fedd..10c59d409c 100644 --- a/__tests__/html2/part-grouping/navigation.html +++ b/__tests__/html2/part-grouping/navigation.html @@ -6,11 +6,13 @@ @@ -44,10 +46,11 @@ KeyboardEventElement.listenKeyboardEvents(); @@ -37,10 +38,10 @@
@@ -37,10 +38,10 @@
@@ -101,10 +103,11 @@