Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
bc43245
Refactor hooks related to transcript
compulim Jan 12, 2022
06f76b9
Fix activities to entries mapping
compulim Jan 12, 2022
acf438f
Refactor uniqueId
compulim Jan 12, 2022
306311b
Add assertions
compulim Jan 12, 2022
e4ee294
Make redirectRef optional
compulim Jan 12, 2022
fc95ea8
Exclude array
compulim Jan 12, 2022
e8c5f57
Add ActivityKeyer context/hooks
compulim Jan 12, 2022
25ee2f7
Add ActiveDescendant composer
compulim Jan 13, 2022
761f914
Update to TypeScript
compulim Jan 13, 2022
ef1e261
BDD
compulim Jan 13, 2022
b15f3f8
BDD
compulim Jan 14, 2022
5151a06
BDD
compulim Jan 14, 2022
4ae7500
Support modifying ref
compulim Jan 14, 2022
eebe096
Clean up
compulim Jan 14, 2022
9185833
Add usePrevious
compulim Jan 14, 2022
e1b2aef
Assert under Provider
compulim Jan 14, 2022
3cb22d5
Add more typings
compulim Jan 14, 2022
b3198ac
Support undefined
compulim Jan 14, 2022
4329462
Add readonly
compulim Jan 14, 2022
6fa8b55
Add new ActivityTree provider
compulim Jan 14, 2022
1476248
Add TranscriptFocus provider
compulim Jan 14, 2022
5d40e14
Add test
compulim Jan 14, 2022
b39d6d4
Interim
compulim Jan 14, 2022
5e2ad59
Add tests
compulim Jan 14, 2022
f691a3c
Interim
compulim Jan 14, 2022
d05fffc
Clean up
compulim Jan 14, 2022
a88e53c
Clean up
compulim Jan 14, 2022
944efd9
Clean up
compulim Jan 14, 2022
616929f
Clean up
compulim Jan 14, 2022
2f094a6
Support Hi-DPI
compulim Jan 15, 2022
bf21bc9
Clean up
compulim Jan 15, 2022
c3984dc
Clean up
compulim Jan 15, 2022
bc4e992
Clean up
compulim Jan 15, 2022
8ce048a
Clean up
compulim Jan 15, 2022
4ebc5dd
Add useGetKeyByActivityId
compulim Jan 15, 2022
f4f89d5
Use activity key for looking up element
compulim Jan 15, 2022
79c0df9
Fix transcript focus event
compulim Jan 19, 2022
60ddd43
Move ActivityKeyer/ActivityTree to Composer
compulim Jan 19, 2022
e983763
Clean up
compulim Jan 19, 2022
6e01e62
Add <ActivityAcknowledgement>
compulim Jan 20, 2022
a939abf
Move ActivityAcknowledgement to api
compulim Jan 21, 2022
0ff8ab6
Remove auto acknowledge
compulim Jan 22, 2022
e9ed565
Fix dispatch scroll position
compulim Jan 22, 2022
a7b89c5
Fix tests
compulim Jan 24, 2022
ccf3a61
Fix test
compulim Jan 25, 2022
ed744eb
Adding tests
compulim Jan 25, 2022
fb3da1f
Move tests to HTML
compulim Jan 25, 2022
d587ccf
Clean up
compulim Jan 25, 2022
81b91b1
Skip if no activity should be marked as read
compulim Jan 25, 2022
27c07b0
Fix test
compulim Jan 25, 2022
0bf7310
Clean up
compulim Jan 25, 2022
4abbc20
Clean up
compulim Jan 28, 2022
876fd56
Clean up
compulim Feb 1, 2022
ad56578
Separate live region
compulim Feb 1, 2022
270bf3a
Fix VoiceOver
compulim Feb 1, 2022
6899762
Add keyboard help
compulim Feb 2, 2022
9669501
Fix &times;
compulim Feb 2, 2022
328992f
SVG close button and dark mode
compulim Feb 2, 2022
f3f089c
Use SVG and focus on transcript
compulim Feb 3, 2022
73da1a1
Clean up
compulim Feb 3, 2022
21521e5
Set aria-hidden on shown/hidden
compulim Feb 6, 2022
bf3ed3a
Fix repetitions
compulim Feb 6, 2022
b8e411c
Add flattened activity tree
compulim Feb 7, 2022
f5085d7
Fix scrolling
compulim Feb 7, 2022
7122e1a
Fix scrolling
compulim Feb 7, 2022
b297d20
Use focus trap
compulim Feb 7, 2022
aa21899
Simplify focus trap
compulim Feb 7, 2022
c565da4
Simpler focus trap and add link alt text
compulim Feb 7, 2022
3731038
Move aria-setsize
compulim Feb 7, 2022
b44ba6b
Clean up
compulim Feb 7, 2022
0345b3b
Revert
compulim Feb 7, 2022
11e20db
Fix tests
compulim Feb 7, 2022
2292da8
Fix tests
compulim Feb 8, 2022
5732742
Fix test
compulim Feb 8, 2022
284f643
Remove obsoleted tests
compulim Feb 8, 2022
0686032
Fix test
compulim Feb 8, 2022
ca3802c
Add todo
compulim Feb 8, 2022
dc59581
Fix test
compulim Feb 8, 2022
501d0e6
Fix test
compulim Feb 8, 2022
7a6ae7d
Fix test
compulim Feb 8, 2022
ccebe67
Fix tests
compulim Feb 8, 2022
d531d30
Fix test
compulim Feb 8, 2022
ea0de5f
Fix test
compulim Feb 8, 2022
4944b5a
Fix tests
compulim Feb 8, 2022
ebd526b
Fix test
compulim Feb 8, 2022
650cc1a
Fix tests
compulim Feb 8, 2022
1ffef01
Fix tests
compulim Feb 8, 2022
bd66728
Fix tests
compulim Feb 8, 2022
ba30069
Fix tests
compulim Feb 8, 2022
3e63b57
Fix tests
compulim Feb 8, 2022
f605392
Fix tests
compulim Feb 8, 2022
f6d2c1f
Fix .has is undefined
compulim Feb 8, 2022
7869d99
Simplify getting activities marked as read/unread
compulim Feb 8, 2022
e755fba
Add test and clean up
compulim Feb 8, 2022
0549925
Clean up
compulim Feb 8, 2022
669bb64
Add entry
compulim Feb 8, 2022
4e5d3fa
Clean up
compulim Feb 8, 2022
7dd731f
Remove aria-setsize
compulim Feb 8, 2022
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
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ overrides:
no-empty-function: off
'@typescript-eslint/no-empty-function': error

no-duplicate-imports: off
'@typescript-eslint/no-duplicate-imports': error

# TODO #4003: We will rework on these rules
'@typescript-eslint/ban-ts-comment': off
'@typescript-eslint/ban-types': off
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixes [#4081](https://github.com/microsoft/BotFramework-WebChat/issues/4081). Updated typing for `StyleOptions.suggestedActionsStackedOverflow`, by [@compulim](https://github.com/compulim), in PR [#4083](https://github.com/microsoft/BotFramework-WebChat/pull/4083)
- Fixes [#4075](https://github.com/microsoft/BotFramework-WebChat/issues/4075). Added `box-sizing: border-box` to all descendants under Adaptive Cards, by [@compulim](https://github.com/compulim), in PR [#4084](https://github.com/microsoft/BotFramework-WebChat/pull/4084)
- Fixes [#4104](https://github.com/microsoft/BotFramework-WebChat/issues/4104) and [#4105](https://github.com/microsoft/BotFramework-WebChat/issues/4105). Fixed invalid entry in `core/package-lock.json`, removed `playground/host`, and added script to rebase URLs in `package-lock.json`, by [@compulim](https://github.com/compulim), in PR [#4106](https://github.com/microsoft/BotFramework-WebChat/pull/4106)
- Fixes [#3933](https://github.com/microsoft/BotFramework-WebChat/issues/3933), [#3934](https://github.com/microsoft/BotFramework-WebChat/issues/3934), [#3994](https://github.com/microsoft/BotFramework-WebChat/issues/3994) and [#4019](https://github.com/microsoft/BotFramework-WebChat/issues/4019), for various accessibility improvements, by [@compulim](https://github.com/compulim), in PR [#4108](https://github.com/microsoft/BotFramework-WebChat/pull/4108)
- Added a new keyboard help screen
- Reduce repetitions when reading message content and briefier readings
- Separated hints for links and interactive widgets
- Focus trap when focus is on interactive attachments or Adaptive Cards
- Using `role="feed"`/`role="article"` for chat history and its messages
- Always assign a message to `aria-activedescendant` for chat history
- Updated verbiage from "transcript" to "chat history"
- Fixed overlapping hit zone causing clicking on bottom edge of message bubble may focus on the next activity instead
- Fixed typings of `useFocus` and `useLocalizer`

### Changed

Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions __tests__/clockSkew.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('Clock skew', () => {
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);

const activityElements = await getActivityElements(driver);
const lastActivityParagraphElement = await activityElements[activityElements.length - 1].findElement(By.css('.webchat__basic-transcript__activity-box p'));
const lastActivityParagraphElement = await activityElements[activityElements.length - 1].findElement(By.css('.webchat__basic-transcript__activity-body p'));

await expect(lastActivityParagraphElement.getText()).resolves.toBe(
'echo This outgoing activity should be the last in the list.'
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('Clock skew', () => {
await driver.wait(minNumActivitiesShown(3), timeouts.directLine);

const activityElements = await getActivityElements(driver);
const firstActivityParagraphElement = await activityElements[0].findElement(By.css('.webchat__basic-transcript__activity-box p'));
const firstActivityParagraphElement = await activityElements[0].findElement(By.css('.webchat__basic-transcript__activity-body p'));

await expect(firstActivityParagraphElement.getText()).resolves.toBe(
'echo This outgoing activity should be the first in the list before echo back, and last after the echo back.'
Expand Down
15 changes: 15 additions & 0 deletions __tests__/html/accessibility.adaptiveCard.withoutTapAction.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,25 @@
await pageConditions.minNumActivitiesShown(2);
await pageConditions.scrollToBottomCompleted();

// SETUP: Focus on the first <select> inside the Adaptive Cards.
document.querySelector('select.ac-input').focus();

// WHEN: SHIFT-TAB key is pressed.
await host.sendShiftTab();

// THEN: It should focus on the last control inside the Adaptive Cards.
expect(document.activeElement.innerText).toBe('Dismiss');

// WHEN: TAB is pressed.
await host.sendTab();

// THEN: It should focus on the first control inside the Adaptive Cards.
expect(document.activeElement).toBe(document.querySelector('select.ac-input'));

// WHEN: ESCAPE key is pressed.
await host.sendKeys('ESCAPE');

// THEN: It should send the focus back to the transcript.
await pageConditions.became(
'focus is on the transcript',
() => document.activeElement === pageElements.transcript(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,20 @@

await pageConditions.uiConnected();
await pageConditions.numActivitiesShown(6);
await pageConditions.liveRegionStabilized();

const screenReaderTexts = [].map.call(pageElements.transcriptLiveRegion().children, child =>
testHelpers.getAllTextContents(child).join('\n')
);

expect(screenReaderTexts).toHaveLength(6);
expect(screenReaderTexts).toHaveLength(7);

expect(screenReaderTexts[0]).toBe('Bot said:\nExclamation mark Warning.\nSent at January 1 at 12:34 PM');
expect(screenReaderTexts[1]).toBe('Bot said:\nHello\nWorld\nAloha\nSent at January 1 at 12:34 PM');
expect(screenReaderTexts[2]).toBe('Bot said:\nHello\nWorld\nSent at January 1 at 12:34 PM');
expect(screenReaderTexts[3]).toBe('Bot said:\nUSD\n1.00\nJPY\n0.91\nSent at January 1 at 12:34 PM');
expect(screenReaderTexts[4]).toBe('Bot said:\nHello, World!\nSent at January 1 at 12:34 PM');
expect(screenReaderTexts[5]).toBe('Bot said:\nHello, Bing!\nSent at January 1 at 12:34 PM');
expect(screenReaderTexts[6]).toBe('One or more links in the message. Press shift tab key 2 to 3 times to switch to the chat history. Then click on the message to interact.');

// The screenshot should show the message in Markdown format, i.e. <strong> and <code>.
await host.snapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

await pageConditions.uiConnected();
await pageConditions.numActivitiesShown(10);
await pageConditions.liveRegionStabilized();

// Unmount Web Chat, and re-render everything.
ReactDOM.unmountComponentAtNode(container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

await pageConditions.uiConnected();
await pageConditions.numActivitiesShown(4);
await pageConditions.liveRegionStabilized();

const screenReaderTexts = [].map.call(pageElements.transcriptLiveRegion().children, child =>
testHelpers.getAllTextContents(child).join('\n')
Expand All @@ -82,23 +83,20 @@
);
expect(screenReaderTexts[2]).toBe('Bot said:\nA text: Hello.\nA text: World!\nSent at January 1 at 12:34 PM');

const activityAlts = [].map.call(
document.querySelectorAll(
'.webchat__basic-transcript__activity .webchat__screen-reader-activity[aria-roledescription="message"]'
),
element => testHelpers.getAllTextContents(element).join('\n')
const activityAlts = [].map.call(pageElements.transcriptLiveRegion().children, element =>
testHelpers.getAllTextContents(element).join('\n')
);

// The last activity have "webchat:fallback-text" field set to empty string. It is treated as role="presentation" and not emitted DOM element for screen reader.
expect(screenReaderTexts).toHaveLength(3);

// In interactive transcript, this is narrated as "2 attachments".
expect(activityAlts[0]).toBe(
'Bot said:\nNo “webchat:fallback-text” field.\n2 attachments.\nSent at January 1 at 12:34 PM'
'Bot said:\nNo “webchat:fallback-text” field.\nA text: Hello.\nA text: World!\nSent at January 1 at 12:34 PM'
);

expect(activityAlts[1]).toBe('Bot said:\nWith "webchat:fallback-text" field.\nSent at January 1 at 12:34 PM');
expect(activityAlts[2]).toBe('Bot said:\n2 attachments.\nSent at January 1 at 12:34 PM');
expect(activityAlts[2]).toBe('Bot said:\nA text: Hello.\nA text: World!\nSent at January 1 at 12:34 PM');
});
</script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@

await pageConditions.uiConnected();
await pageConditions.numActivitiesShown(7);
await pageConditions.liveRegionStabilized();

const screenReaderTexts = [].map.call(pageElements.transcriptLiveRegion().children, child =>
testHelpers.getAllTextContents(child).join('\n')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

const audioElement = document.getElementsByTagName('audio')[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

const audioElement = document.getElementsByTagName('audio')[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

await pageObjects.focusSendBoxTextBox();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

const videoElement = document.getElementsByTagName('video')[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
await pageConditions.allImagesLoaded();
await pageConditions.allOutgoingActivitiesSent();
await pageConditions.scrollToBottomCompleted();
await pageConditions.liveRegionStabilized();

const videoElement = document.getElementsByTagName('video')[0];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.webchat__screen-reader-activity {
.webchat__screen-reader-activity, .webchat__live-region-transcript__interactive_note {
color: initial !important;
height: initial !important;
opacity: initial !important;
Expand Down
10 changes: 4 additions & 6 deletions __tests__/html/autoScroll.acknowledgement.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@

expect(numActivitiesByAcknowledgement()).toEqual({ acknowledged: 4, unacknowledged: 3 });

const activityElementAtTopOfView = document.querySelectorAll('.webchat__basic-transcript__activity')[4];
const scrollable = document.querySelector('.webchat__basic-transcript__scrollable');
const { top: activityElementAtTopOfViewOffsetTop } = pageObjects.getActivityBoundingBoxes()[4];
const scrollable = pageElements.transcriptScrollable();

expect(scrollable.scrollTop).toBe(activityElementAtTopOfView.offsetTop);
expect(scrollable.scrollTop).toBe(activityElementAtTopOfViewOffsetTop);

await pageObjects.sendMessageViaSendBox('Aloha!');

Expand Down Expand Up @@ -160,9 +160,7 @@

expect(numActivitiesByAcknowledgement()).toEqual({ acknowledged: 9, unacknowledged: 3 });

expect(scrollable.scrollTop).toBe(
document.querySelectorAll('.webchat__basic-transcript__activity')[9].offsetTop
);
expect(scrollable.scrollTop).toBe(pageObjects.getActivityBoundingBoxes()[9].top);

// Scroll to bottom
scrollable.scrollTop = scrollable.scrollHeight;
Expand Down
43 changes: 43 additions & 0 deletions __tests__/html/autoScroll.afterSend.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!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>
<div id="webchat"></div>
<script>
run(async function () {
WebChat.renderWebChat(
{
directLine: WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }),
store: testHelpers.createStore()
},
document.getElementById('webchat')
);

// SETUP: Send "help" after connect.
await pageConditions.uiConnected();
await pageObjects.sendMessageViaSendBox('help');
await pageConditions.minNumActivitiesShown(2);
await pageConditions.scrollToBottomCompleted();

// WHEN: Scroll to top.
await pageObjects.scrollToTop();

// THEN: It should not show the "New messages" button.
await pageConditions.scrollToEndButtonHidden();

// WHEN: Send "Hello, World!" message.
await pageObjects.sendMessageViaSendBox('Hello, World!');

// THEN: It should scroll to bottom after send.
await pageConditions.scrollToBottomCompleted();
await pageConditions.minNumActivitiesShown(4);
await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/autoScroll.afterSend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('Auto-scroll', () => {
test('should scroll to bottom on send', () => runHTML('autoScroll.afterSend.html'));
});
10 changes: 4 additions & 6 deletions __tests__/html/autoScroll.snap.activityAndPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@
await pageConditions.minNumActivitiesShown(5);
await pageConditions.scrollStabilized();

const activityElementAtBottomOfView = document.querySelectorAll('.webchat__basic-transcript__activity')[3];
const { bottom: activityElementAtBottomOfViewOffsetBottom } = pageObjects.getActivityBoundingBoxes()[3];

expect(scrollable.scrollTop).toBe(
activityElementAtBottomOfView.offsetTop +
activityElementAtBottomOfView.offsetHeight -
scrollable.offsetHeight,
activityElementAtBottomOfViewOffsetBottom - scrollable.offsetHeight,
'scrollable should be at 1 activity + 100px'
);

Expand All @@ -113,9 +111,9 @@
await pageConditions.minNumActivitiesShown(7);
await pageConditions.scrollStabilized();

const activityElementAtTopOfView = document.querySelector('.webchat__basic-transcript__activity:nth-child(7)');
const { top } = pageObjects.getActivityBoundingBoxes()[6];

expect(scrollable.scrollTop).toBe(activityElementAtTopOfView.offsetTop - 100);
expect(scrollable.scrollTop).toBe(top - 100);

await host.snapshot();
});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/html/autoScroll.snap.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@

expect(numActivitiesByAcknowledgement()).toEqual({ acknowledged: 3, unacknowledged: 1 });

const activityElementAtTopOfView = document.querySelector('.webchat__basic-transcript__activity:nth-child(4)');
const { top: activityElementAtTopOfViewOffsetTop } = pageObjects.getActivityBoundingBoxes()[3];
const scrollable = document.querySelector('.webchat__basic-transcript__scrollable');

expect(~~scrollable.scrollTop).toBeCloseTo(
~~(activityElementAtTopOfView.offsetTop - scrollable.offsetHeight * 0.8)
~~(activityElementAtTopOfViewOffsetTop - scrollable.offsetHeight * 0.8)
);

await host.snapshot();
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/autoScroll.withPostBack.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
await pageConditions.numActivitiesShown(8);

// EXPECT: Pause scrolling when the "Minim voluptate" activity (index = 6) is at the top of the screen.
await pageConditions.scrollStabilized(pageElements.activities()[6].offsetTop);
await pageConditions.scrollStabilized(pageObjects.getActivityBoundingBoxes()[6].top);

await host.snapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

await host.snapshot();

await host.sendTab();
await host.sendKeys('ESCAPE');

await host.snapshot();

Expand Down
Loading