-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add bubbleImageMaxHeight and bubbleImageMinHeight * Update PR number * Default bubbleImageMinHeight to 240px * Update breaking change for bubbleImageMinHeight * Add test for freestyle * Fixed width but cropped height * Fix tests * Add aspect ratio to test images * Add CSS variable name
- Loading branch information
Showing
25 changed files
with
387 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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
Binary file modified
BIN
-199 Bytes
(100%)
...l-js-carousel-without-avatar-initials-2-attachments-with-wide-screen-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 modified
BIN
-140 Bytes
(100%)
.../chrome-docker/stacked-js-stacked-with-avatar-initials-4-attachments-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 modified
BIN
-180 Bytes
(100%)
...are-js-activity-grouping-should-not-break-legacy-activity-middleware-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
+27.2 KB
...le-options-bubble-image-min-max-height-should-resize-images-properly-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
+27.3 KB
...le-options-bubble-image-min-max-height-should-resize-images-properly-2-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
+27.1 KB
...le-options-bubble-image-min-max-height-should-resize-images-properly-3-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
+27.4 KB
...le-options-bubble-image-min-max-height-should-resize-images-properly-4-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
+25.2 KB
...le-options-bubble-image-height-should-resize-images-with-deprecation-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 modified
BIN
-482 Bytes
(100%)
...cript-activity-grouping-js-transcript-with-activity-grouping-test-43-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.
This file contains 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
140 changes: 140 additions & 0 deletions
140
__tests__/html/styleOptions/bubbleImageHeight/bubbleImageHeight.comprehensive.html
This file contains 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,140 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<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> | ||
<script> | ||
function expectWidthHeight(element, width, height) { | ||
try { | ||
expect(Math.abs(element.clientWidth - width) <= 1).toBe(true); | ||
} catch { | ||
expect(element.clientWidth).toBe(width); // Better message. | ||
} | ||
} | ||
|
||
run(async function () { | ||
const container = document.createElement('main'); | ||
|
||
container.setAttribute('id', 'webchat'); | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
const render = overrideProps => WebChat.renderWebChat({ directLine, store, ...overrideProps }, container); | ||
|
||
render({ | ||
styleOptions: { | ||
bubbleImageMaxHeight: 240, | ||
bubbleImageMinHeight: 180 | ||
} | ||
}); | ||
|
||
document.body.append(container); | ||
|
||
await host.windowSize(360, 1280, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
// Generated from https://placeholder.pics/svg/320x180. | ||
const LANDSCAPE_SVG = `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180"><rect x="2" y="2" width="316" height="176" style="fill:%23DEDEDE;stroke:%23555555;stroke-width:2"/><text x="50%" y="50%" font-size="18" text-anchor="middle" alignment-baseline="middle" font-family="monospace, sans-serif" fill="%23555555">320×180 (16:9)</text></svg>`; | ||
|
||
// Generated from https://placeholder.pics/svg/180x320. | ||
const PORTRAIT_SVG = `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="180" height="320"><rect x="2" y="2" width="176" height="316" style="fill:%23DEDEDE;stroke:%23555555;stroke-width:2"/><text x="50%" y="50%" font-size="18" text-anchor="middle" alignment-baseline="middle" font-family="monospace, sans-serif" fill="%23555555">180×320 (9:16)</text></svg>`; | ||
|
||
// Generated from https://placeholder.pics/svg/640x180. | ||
const WIDE_SVG = `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="640" height="180"><rect x="2" y="2" width="636" height="176" style="fill:%23DEDEDE;stroke:%23555555;stroke-width:2"/><text x="50%" y="50%" font-size="18" text-anchor="middle" alignment-baseline="middle" font-family="monospace, sans-serif" fill="%23555555">640×180 (32:9)</text></svg>`; | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [ | ||
{ | ||
contentType: 'image/svg+xml', | ||
contentUrl: WIDE_SVG, | ||
thumbnailUrl: WIDE_SVG | ||
}, | ||
{ | ||
contentType: 'image/svg+xml', | ||
contentUrl: LANDSCAPE_SVG, | ||
thumbnailUrl: LANDSCAPE_SVG | ||
}, | ||
{ | ||
contentType: 'image/svg+xml', | ||
contentUrl: PORTRAIT_SVG, | ||
thumbnailUrl: PORTRAIT_SVG | ||
} | ||
], | ||
from: { role: 'user' }, | ||
text: 'Images with varies `bubbleImageMaxHeight` and `bubbleImageMinHeight`.', | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.allImagesLoaded(); | ||
await pageConditions.scrollToBottomCompleted(); | ||
|
||
const imageElements = pageElements.activities()[0].querySelectorAll('.webchat__fixed-width-image'); | ||
const wideImage = imageElements[0]; | ||
const landscapeImage = imageElements[1]; | ||
const portraitImage = imageElements[2]; | ||
|
||
expectWidthHeight(wideImage, 339, 180); | ||
expectWidthHeight(landscapeImage, 339, 339 / 16 / 9); | ||
expectWidthHeight(portraitImage, 339, 240); | ||
|
||
await host.snapshot(); | ||
|
||
render({ | ||
styleOptions: { | ||
bubbleImageMinHeight: 240, | ||
bubbleImageMaxHeight: 360 | ||
} | ||
}); | ||
|
||
await pageConditions.scrollToBottomCompleted(); | ||
|
||
await pageConditions.became('image resized', () => wideImage.clientHeight === 240, 5_000); | ||
|
||
expectWidthHeight(wideImage, 338, 240); | ||
expectWidthHeight(landscapeImage, 338, 240); | ||
expectWidthHeight(portraitImage, 338, 360); | ||
|
||
await host.snapshot(); | ||
|
||
render({ | ||
styleOptions: { | ||
bubbleImageMinHeight: 120, | ||
bubbleImageMaxHeight: 180 | ||
} | ||
}); | ||
|
||
await pageConditions.scrollToBottomCompleted(); | ||
|
||
await pageConditions.became('image resized', () => wideImage.clientHeight === 120, 5_000); | ||
|
||
expectWidthHeight(wideImage, 338, 120); | ||
expectWidthHeight(landscapeImage, 338, 180); | ||
expectWidthHeight(portraitImage, 338, 180); | ||
|
||
await host.snapshot(); | ||
|
||
render({ | ||
styleOptions: { | ||
bubbleImageMinHeight: 0, | ||
bubbleImageMaxHeight: Infinity | ||
} | ||
}); | ||
|
||
await pageConditions.scrollToBottomCompleted(); | ||
|
||
await pageConditions.became('image resized', () => Math.abs(wideImage.clientHeight - 95) <= 1, 5_000); | ||
|
||
expectWidthHeight(wideImage, 338, 338 / (32 / 9)); | ||
expectWidthHeight(landscapeImage, 338, 338 / (16 / 9)); | ||
expectWidthHeight(portraitImage, 338, 338 / (9 / 16)); | ||
|
||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
__tests__/html/styleOptions/bubbleImageHeight/bubbleImageHeight.comprehensive.js
This file contains 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,6 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('styleOptions.bubbleImageMinMaxHeight', () => { | ||
test('should resize images properly', () => | ||
runHTML('styleOptions/bubbleImageHeight/bubbleImageHeight.comprehensive')); | ||
}); |
91 changes: 91 additions & 0 deletions
91
__tests__/html/styleOptions/bubbleImageHeight/bubbleImageHeight.deprecated.html
This file contains 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,91 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<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> | ||
<script> | ||
function expectWidthHeight(element, width, height) { | ||
try { | ||
expect(Math.abs(element.clientWidth - width) <= 1).toBe(true); | ||
} catch { | ||
expect(element.clientWidth).toBe(width); // Better message. | ||
} | ||
} | ||
|
||
run( | ||
async function () { | ||
const container = document.createElement('main'); | ||
|
||
container.setAttribute('id', 'webchat'); | ||
|
||
const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store, | ||
styleOptions: { bubbleImageHeight: 240, bubbleImageMaxHeight: 10, bubbleImageMinHeight: 10 } | ||
}, | ||
container | ||
); | ||
|
||
document.body.append(container); | ||
|
||
await host.windowSize(360, 1280, document.getElementById('webchat')); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
// Generated from https://placeholder.pics/svg/320x180. | ||
const LANDSCAPE_SVG = `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180"><rect x="2" y="2" width="316" height="176" style="fill:%23DEDEDE;stroke:%23555555;stroke-width:2"/><text x="50%" y="50%" font-size="18" text-anchor="middle" alignment-baseline="middle" font-family="monospace, sans-serif" fill="%23555555">320×180 (16:9)</text></svg>`; | ||
|
||
// Generated from https://placeholder.pics/svg/180x320. | ||
const PORTRAIT_SVG = `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="180" height="320"><rect x="2" y="2" width="176" height="316" style="fill:%23DEDEDE;stroke:%23555555;stroke-width:2"/><text x="50%" y="50%" font-size="18" text-anchor="middle" alignment-baseline="middle" font-family="monospace, sans-serif" fill="%23555555">180×320 (9:16)</text></svg>`; | ||
|
||
// Generated from https://placeholder.pics/svg/640x180. | ||
const WIDE_SVG = `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="640" height="180"><rect x="2" y="2" width="636" height="176" style="fill:%23DEDEDE;stroke:%23555555;stroke-width:2"/><text x="50%" y="50%" font-size="18" text-anchor="middle" alignment-baseline="middle" font-family="monospace, sans-serif" fill="%23555555">640×180 (32:9)</text></svg>`; | ||
|
||
await directLine.emulateIncomingActivity({ | ||
attachments: [ | ||
{ | ||
contentType: 'image/svg+xml', | ||
contentUrl: WIDE_SVG, | ||
thumbnailUrl: WIDE_SVG | ||
}, | ||
{ | ||
contentType: 'image/svg+xml', | ||
contentUrl: LANDSCAPE_SVG, | ||
thumbnailUrl: LANDSCAPE_SVG | ||
}, | ||
{ | ||
contentType: 'image/svg+xml', | ||
contentUrl: PORTRAIT_SVG, | ||
thumbnailUrl: PORTRAIT_SVG | ||
} | ||
], | ||
from: { role: 'user' }, | ||
text: 'Images with fixed `bubbleImageHeight`.', | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.allImagesLoaded(); | ||
|
||
const imageElements = pageElements.activities()[0].querySelectorAll('.webchat__fixed-width-image'); | ||
const wideImage = imageElements[0]; | ||
const landscapeImage = imageElements[1]; | ||
const portraitImage = imageElements[2]; | ||
|
||
expectWidthHeight(wideImage, 338, 240); | ||
expectWidthHeight(landscapeImage, 338, 240); | ||
expectWidthHeight(portraitImage, 338, 240); | ||
|
||
await host.snapshot(); | ||
}, | ||
{ expectDeprecations: true } | ||
); | ||
</script> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
__tests__/html/styleOptions/bubbleImageHeight/bubbleImageHeight.deprecated.js
This file contains 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,6 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('styleOptions.bubbleImageHeight', () => { | ||
test('should resize images with deprecation', () => | ||
runHTML('styleOptions/bubbleImageHeight/bubbleImageHeight.deprecated')); | ||
}); |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.