Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activity grouping feature #3365

Merged
merged 100 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
6361cc5
Stacked layout
compulim Jul 9, 2020
2b11b3b
Clean up
compulim Jul 9, 2020
2cac1d2
Add carousel layout
compulim Jul 10, 2020
3f06a80
Add mirrorStyles
compulim Jul 10, 2020
3acd639
Redo StackedLayout
compulim Jul 11, 2020
5d7317a
Clean up
compulim Jul 12, 2020
b410b68
Clean up
compulim Jul 12, 2020
51d666d
Clean up
compulim Jul 12, 2020
39363f8
Clean up
compulim Jul 12, 2020
1e027a2
Clean up
compulim Jul 12, 2020
836ce12
Clean up
compulim Jul 13, 2020
2c3cf4f
Add groupActivities middleware
compulim Jul 13, 2020
04a3e89
Enable groupActivitiesMiddleware
compulim Jul 13, 2020
83211ec
Cosmetics
compulim Jul 13, 2020
3dd8536
Fix layout issues
compulim Jul 13, 2020
0b7e30e
Rename
compulim Jul 14, 2020
a4c3f61
Add avatar show in grouping feature
compulim Jul 14, 2020
9252339
Fix avatar/nub combination
compulim Jul 14, 2020
ec6cd44
Improve perf
compulim Jul 16, 2020
3893860
Fix perf and stacked layout with cards
compulim Jul 17, 2020
fe1c59b
Fix ESLint and IE11 layout
compulim Jul 18, 2020
b93721c
Fix layout
compulim Jul 18, 2020
31295fa
Clean up
compulim Jul 18, 2020
5823208
Test harness for grouping avatar
compulim Jul 19, 2020
6463b15
Add URL
compulim Jul 19, 2020
e56d73b
Fix plus/minus button for show avatar
compulim Jul 19, 2020
ac72c1e
Add test transcripts
compulim Jul 20, 2020
4416a82
Support default layout
compulim Jul 20, 2020
275960c
Hide panel in Web Driver mode
compulim Jul 20, 2020
5e2341a
Update URL
compulim Jul 20, 2020
eed07ff
Fix plus/minus button
compulim Jul 20, 2020
66ac964
Select all on click
compulim Jul 20, 2020
21aa84a
Simplify transcript
compulim Jul 20, 2020
c44e0a4
Fix double attachment layout
compulim Jul 20, 2020
9be08c5
Add tests
compulim Jul 21, 2020
0602cb0
Increase font size
compulim Jul 21, 2020
c1ede39
Add backward compatibility
compulim Jul 22, 2020
5f816dc
Backcompat for activity status
compulim Jul 22, 2020
5e1e4b3
Fix ESLint
compulim Jul 22, 2020
bf5e712
Fix ESLint
compulim Jul 22, 2020
1ef3c96
Fix ESLint
compulim Jul 22, 2020
c2c862d
Add tests for backward compatibility
compulim Jul 24, 2020
f8117ed
Add tests
compulim Jul 24, 2020
437cc32
Clean up
compulim Jul 24, 2020
4d7139b
Move tests
compulim Jul 24, 2020
22df176
Fix ESLint
compulim Jul 24, 2020
136628e
Remove unneeded ESLint
compulim Jul 24, 2020
64de3d0
Clean up
compulim Jul 24, 2020
76e9834
Clean up
compulim Jul 24, 2020
fb882f6
Clean up
compulim Jul 24, 2020
1033d92
Add tests
compulim Jul 24, 2020
5eb7462
Add test snapshots
compulim Jul 24, 2020
29f49aa
Update tests
compulim Jul 25, 2020
ffa3d81
Add tests
compulim Jul 25, 2020
5ab1910
Test deprecation notes
compulim Jul 25, 2020
143d9c3
Add thumbnail URL
compulim Jul 25, 2020
1f9a5e8
Fix padding for activity without message
compulim Jul 25, 2020
cdad3ba
Fix tests
compulim Jul 25, 2020
7bd0a39
Update screenshot for noises
compulim Jul 26, 2020
9c05977
Fix tests
compulim Jul 26, 2020
a88d227
Add tests
compulim Jul 26, 2020
e28747d
Fix screenshots
compulim Jul 26, 2020
3d7236f
Better timeout message
compulim Jul 27, 2020
d66b277
Remove console log
compulim Jul 27, 2020
4c247ed
Test reliability
compulim Jul 27, 2020
3cbebfa
Fix tests
compulim Jul 27, 2020
5286de8
Update DOM element
compulim Jul 27, 2020
5991e06
Fix signature
compulim Jul 27, 2020
60238ae
Fix tests
compulim Jul 27, 2020
886c830
Fix carousel alignment
compulim Jul 27, 2020
5b18376
Fix screenshots
compulim Jul 27, 2020
875b74d
Fix screenshots
compulim Jul 27, 2020
cc61a6e
Fix screenshots
compulim Jul 27, 2020
d1fcaa4
Fix screenshots
compulim Jul 27, 2020
cc12c97
Fix screenshots
compulim Jul 27, 2020
b78ae37
Fix bottom-aligned avatar
compulim Jul 27, 2020
5c2dfea
Fix screenshots
compulim Jul 27, 2020
8684b7a
Fix tests
compulim Jul 27, 2020
2d6d374
Fix layout
compulim Jul 27, 2020
f06f7ef
Fix tests
compulim Jul 27, 2020
eb581bc
Fix tests
compulim Jul 27, 2020
1c12359
Fix snapshots
compulim Jul 27, 2020
4a3cbbc
Fix tests
compulim Jul 27, 2020
4bda6d8
Add entry
compulim Jul 27, 2020
2f31008
Fix ESLint
compulim Jul 28, 2020
8ce77dd
Fix ESLint
compulim Jul 28, 2020
b583d8d
Rename BasicTranscript2 to BasicTranscript
compulim Jul 28, 2020
2010293
Clean up
compulim Jul 28, 2020
6ced0dd
Add test
compulim Jul 28, 2020
1309c1a
Clean up
compulim Jul 28, 2020
e1e2a76
Add tests
compulim Jul 28, 2020
59c3c53
Update useCreateActivityStatusRenderer signature
compulim Jul 28, 2020
689ba76
Clean up
compulim Jul 28, 2020
ff45602
Add useCreateAvatarRenderer hook
compulim Jul 28, 2020
bc5904d
Use multiple args
compulim Jul 28, 2020
9a645e1
Fix useSendTimeoutForActivity
compulim Jul 28, 2020
ac4d794
Add useGetSendTimeoutForActivity hook
compulim Jul 28, 2020
8d16562
Applying PR suggestions
compulim Jul 30, 2020
d505e4a
Apply PR suggestions
compulim Jul 30, 2020
d6b49be
Apply PR suggestions
compulim Jul 30, 2020
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Breaking changes

- Due to the complexity, we are no longer exposing `<CarouselLayout>` and `<StackedLayout>`. Please use `<BasicTranscript>` to render the transcript instead.
- With the new activity grouping feature:
- Customized avatar cannot be wider than `styleOptions.avatarSize`. If you want to show a wider avatar, please increase `styleOptions.avatarSize`.
- If customized avatar is rendering `false`, bubble will still be padded to leave a gutter for the empty customized avatar. To hide gutter, please set `styleOptions.botAvatarInitials` and `styleOptions.userAvatarInitials` to falsy.
- Default bubble nub offset is set to `0`, previously `"bottom"` (or `-0`)
- Previously, we put the bubble nub at the bottom while keeping the avatar on top. This is not consistent in the new layout.
- By default, we will group avatar per status group.
- If you want to switch back to previous behaviors, please set `styleOptions.showAvatarInGroup` to `true`.
- Default `botAvatarInitials` and `userAvatarInitials` is changed to `undefined`, from `""` (empty string)
- When the initials is `undefined`, no gutter space will be reserved for the avatar.
- When the initials is `""` (empty string), gutter space will be reserved, but not avatar will be shown.

### Added

- Resolves [#3250](https://github.com/microsoft/BotFramework-WebChat/issues/3250). Added activity grouping feature, by [@compulim](https://github.com/compulim), in PR [#3365](https://github.com/microsoft/BotFramework-WebChat/pull/3365)

## [4.9.2] - 2020-07-14

### Added
Expand Down
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.
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.
Diff not rendered.
2 changes: 1 addition & 1 deletion __tests__/customizableAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('customizable avatar', () => {
fontFamily: "'Calibri', 'Helvetica Neue', 'Arial', 'sans-serif'",
height: 128,
justifyContent: 'center',
width: 64
width: '100%'
}
},
React.createElement('div', {}, activity.from.role)
Expand Down
15 changes: 15 additions & 0 deletions __tests__/html/__jest__/createJobObservable.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ export default function createJobObservable(driver, { ignorePageError = false }
if (job === ABORT_SYMBOL) {
break;
} else if (job.type === 'done') {
if (job.payload.deprecation) {
const deferred = createDeferred();

observer.next({
deferred,
job: {
type: 'expect deprecation'
}
});

if (!(await deferred.promise)) {
return observer.error(new Error('Expected deprecation notes were not found in the console log.'));
}
}

observer.complete();
break;
} else if (job.type === 'error') {
Expand Down
6 changes: 4 additions & 2 deletions __tests__/html/__jest__/runPageProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default async function runPageProcessor(driver, { ignoreConsoleError = fa
const webChatTestLoaded = await driver.executeScript(() => !!window.WebChatTest);

if (!webChatLoaded) {
throw new Error('"webchat.js" is not loaded on the page.');
throw new Error('"webchat.js" did not load on the page, or the page was not found.');
}

if (!webChatTestLoaded) {
throw new Error('"testharness.js" is not loaded on the page.');
throw new Error('"testharness.js" did not load on the page.');
}

if (await driver.executeScript(() => !(window.React && window.ReactDOM && window.ReactTestUtils))) {
Expand Down Expand Up @@ -85,6 +85,8 @@ export default async function runPageProcessor(driver, { ignoreConsoleError = fa
console.log(`Saved to ${filename}`);

result = filename;
} else if (job.type === 'expect deprecation') {
result = (await driver.executeScript(() => window.WebChatTest.shiftDeprecationHistory())).length;
} else {
throw new Error(`Unknown job type "${job.type}".`);
}
Expand Down
12 changes: 11 additions & 1 deletion __tests__/html/__jest__/setupRunHTMLTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Options } from 'selenium-webdriver/chrome';
import { URL } from 'url';
import fetch from 'node-fetch';

import { timeout } from './sleep';
import indent from './indent';
import mergeCoverageMap from './mergeCoverageMap';
import parseURLParams from './parseURLParams';
Expand Down Expand Up @@ -30,7 +31,16 @@ global.runHTMLTest = async (
.setChromeOptions(chromeOptions)
.build();

const sessionId = (await driver.getSession()).getId();
const session = await Promise.race([
driver.getSession(),
timeout(
15000,
'Timed out while waiting for a Web Driver session. Probably there are more test runners running simultaneously than Web Driver sessions. Or some Web Driver sessions are hung.'
)
]);

const sessionId = session.getId();

const params = parseURLParams(new URL(url, 'http://webchat2/').hash);

try {
Expand Down
8 changes: 7 additions & 1 deletion __tests__/html/__jest__/sleep.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export default function sleep(durationInMS) {
export default function sleep(durationInMS = 1000) {
return new Promise(resolve => setTimeout(resolve, durationInMS));
}

export function timeout(durationInMS, message = 'timeout') {
return sleep(durationInMS).then(() => {
throw new Error(message);
});
}
144 changes: 144 additions & 0 deletions __tests__/html/activityGrouping.avatarMiddleware.atBottom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<div id="webchat"></div>
<script type="text/babel" data-presets="env,stage-3,react">
const {
React: { useMemo },
WebChat: {
hooks: { useDirection }
},
WebChatTest: { conditions, createDirectLineWithTranscript, createStore, host, pageObjects, timeouts, token }
} = window;

(async function() {
const PortraitAvatar = ({ fromUser }) => {
const style = useMemo(() => ({ borderRadius: 4, width: '100%' }), []);

return <img src={fromUser ? 'assets/user-avatar.jpg' : 'assets/bot-avatar.jpg'} style={style} />;
};

const avatarMiddleware = () => next => (...args) => {
const [{ activity, fromUser, ...otherArgs }] = args;
const { id } = activity;

return <PortraitAvatar fromUser={fromUser} />;
};

window.WebChat.renderWebChat(
{
avatarMiddleware,
directLine: await createDirectLineWithTranscript([
{
from: { role: 'bot' },
id: '1.0',
text: 'Cillum ea irure amet reprehenderit minim.',
timestamp: -300001,
type: 'message'
},
{
from: { role: 'bot' },
id: '1.1',
text: 'Minim ut laboris enim nostrud magna.',
timestamp: -300001,
type: 'message'
},
{
channelData: { state: 'sent' },
from: { role: 'user' },
id: '2.0',
text: 'Tempor deserunt ut enim eu elit.',
timestamp: -300001,
type: 'message'
},
{
channelData: { state: 'sent' },
from: { role: 'user' },
id: '2.1',
text: 'Elit occaecat quis velit qui ad.',
timestamp: -300001,
type: 'message'
},
{
attachmentLayout: 'carousel',
attachments: [
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface1.jpg'
},
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface2.jpg'
},
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface3.jpg'
}
],
from: { role: 'bot' },
id: '3.0',
text: '',
timestamp: 0,
type: 'message'
},
{
attachmentLayout: 'stacked',
attachments: [
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface4.jpg',
thumbnailUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface4.jpg'
}
],
channelData: { state: 'sent' },
from: { role: 'user' },
id: '4.0',
text: '',
timestamp: 0,
type: 'message'
}
]),
store: createStore(),
styleOptions: {
botAvatarInitials: 'Bot',
bubbleBackground: '#0063B1',
bubbleBorderColor: '#0063B1',
bubbleBorderRadius: 4,
bubbleFromUserBackground: '#0063B1',
bubbleFromUserBorderColor: '#0063B1',
bubbleFromUserBorderRadius: 4,
bubbleFromUserNubOffset: -0,
bubbleFromUserNubSize: 10,
bubbleFromUserTextColor: 'White',
bubbleNubOffset: -0,
bubbleNubSize: 10,
bubbleTextColor: 'White',
groupTimestamp: 5000,
userAvatarInitials: 'You'
}
},
document.getElementById('webchat')
);

await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);
await pageObjects.wait(conditions.allImagesLoaded(), timeouts.network);

await host.snapshot();
await host.done();
})().catch(async err => {
console.error(err);

await host.error(err);
});
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
*/

describe('activity grouping', () => {
test('should not break avatar middleware with avatar at bottom', () =>
runHTMLTest('activityGrouping.avatarMiddleware.atBottom.html', { height: 1280 }));
});
Loading