-
Notifications
You must be signed in to change notification settings - Fork 73
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
Real Time Text API update and tests #5580
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d405620
Update
carocao-msft 9ea37c5
Change files
carocao-msft edb006b
api
carocao-msft 184f6d4
Merge branch 'main' into carocao/RTTAPI
carocao-msft f8a5d8b
cc
carocao-msft 33b57c7
update
carocao-msft e9cbd8f
Merge branch 'main' into carocao/RTTAPI
carocao-msft c987cc9
Add RTT disclosure banner styles and usage
carocao-msft 2e8ee6b
lint
carocao-msft 162fc0a
fix build
carocao-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
change-beta/@azure-communication-react-4b0c972c-f310-493e-a96f-29df49eefadf.json
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,9 @@ | ||
{ | ||
"type": "prerelease", | ||
"area": "feature", | ||
"workstream": "RTT", | ||
"comment": "Caption Banner API update, and update the merged caption list to only store 50 entries. Also added tests for the sorting logic", | ||
"packageName": "@azure/communication-react", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
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
196 changes: 196 additions & 0 deletions
196
packages/react-components/src/components/utils/sortCaptionsAndRealTimeTexts.test.ts
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,196 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
/* @conditional-compile-remove(rtt) */ | ||
import { CaptionsInformation, RealTimeTextInformation } from '../CaptionsBanner'; | ||
/* @conditional-compile-remove(rtt) */ | ||
import { _formatPhoneNumber } from './formatPhoneNumber'; | ||
/* @conditional-compile-remove(rtt) */ | ||
import { sortCaptionsAndRealTimeTexts } from './sortCaptionsAndRealTimeTexts'; | ||
/* @conditional-compile-remove(rtt) */ | ||
const mockCaptions: CaptionsInformation[] = [ | ||
{ | ||
id: '1', | ||
displayName: 'John Doe', | ||
captionText: 'Hello', | ||
createdTimeStamp: new Date('2021-09-01T00:00:01Z') | ||
}, | ||
{ | ||
id: '2', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:00Z') | ||
}, | ||
{ | ||
id: '3', | ||
displayName: 'John Doe', | ||
captionText: 'Hi', | ||
createdTimeStamp: new Date('2021-09-01T00:00:02Z') | ||
}, | ||
{ | ||
id: '4', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:09Z') | ||
}, | ||
{ | ||
id: '5', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:05Z') | ||
} | ||
]; | ||
/* @conditional-compile-remove(rtt) */ | ||
const mockRealTimeTexts: RealTimeTextInformation[] = [ | ||
{ | ||
id: 11, | ||
displayName: 'John Doe', | ||
message: 'Hello', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:03Z'), | ||
isTyping: false | ||
}, | ||
{ | ||
id: 22, | ||
displayName: 'John Doe', | ||
message: 'Hello there ', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:10Z'), | ||
isTyping: false | ||
}, | ||
{ | ||
id: 33, | ||
displayName: 'John Doe', | ||
message: 'Hi', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:04Z'), | ||
isTyping: false | ||
} | ||
]; | ||
/* @conditional-compile-remove(rtt) */ | ||
describe('Sort Captions and Real Time Text List', () => { | ||
test('if only using captions, captions should be sorted by created timestamp', () => { | ||
const result = [ | ||
{ | ||
id: '2', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:00Z') | ||
}, | ||
{ | ||
id: '1', | ||
displayName: 'John Doe', | ||
captionText: 'Hello', | ||
createdTimeStamp: new Date('2021-09-01T00:00:01Z') | ||
}, | ||
|
||
{ | ||
id: '3', | ||
displayName: 'John Doe', | ||
captionText: 'Hi', | ||
createdTimeStamp: new Date('2021-09-01T00:00:02Z') | ||
}, | ||
{ | ||
id: '5', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:05Z') | ||
}, | ||
{ | ||
id: '4', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:09Z') | ||
} | ||
]; | ||
expect(sortCaptionsAndRealTimeTexts(mockCaptions, [])).toEqual(result); | ||
}); | ||
|
||
test('if only using RTT, RTT should be sorted by last updated time stamp', () => { | ||
const result = [ | ||
{ | ||
id: 11, | ||
displayName: 'John Doe', | ||
message: 'Hello', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:03Z'), | ||
isTyping: false | ||
}, | ||
{ | ||
id: 33, | ||
displayName: 'John Doe', | ||
message: 'Hi', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:04Z'), | ||
isTyping: false | ||
}, | ||
{ | ||
id: 22, | ||
displayName: 'John Doe', | ||
message: 'Hello there ', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:10Z'), | ||
isTyping: false | ||
} | ||
]; | ||
expect(sortCaptionsAndRealTimeTexts([], mockRealTimeTexts)).toEqual(result); | ||
}); | ||
|
||
test('when using both, captions and RTT should be compared with captions created timestamp and rtts last updated timestamp', () => { | ||
const result = [ | ||
{ | ||
id: '2', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:00Z') | ||
}, | ||
{ | ||
id: '1', | ||
displayName: 'John Doe', | ||
captionText: 'Hello', | ||
createdTimeStamp: new Date('2021-09-01T00:00:01Z') | ||
}, | ||
|
||
{ | ||
id: '3', | ||
displayName: 'John Doe', | ||
captionText: 'Hi', | ||
createdTimeStamp: new Date('2021-09-01T00:00:02Z') | ||
}, | ||
{ | ||
id: 11, | ||
displayName: 'John Doe', | ||
message: 'Hello', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:03Z'), | ||
isTyping: false | ||
}, | ||
{ | ||
id: 33, | ||
displayName: 'John Doe', | ||
message: 'Hi', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:04Z'), | ||
isTyping: false | ||
}, | ||
{ | ||
id: '5', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:05Z') | ||
}, | ||
{ | ||
id: '4', | ||
displayName: 'John Doe', | ||
captionText: 'Hello there ', | ||
createdTimeStamp: new Date('2021-09-01T00:00:09Z') | ||
}, | ||
{ | ||
id: 22, | ||
displayName: 'John Doe', | ||
message: 'Hello there ', | ||
finalizedTimeStamp: new Date('2021-09-01T00:00:10Z'), | ||
isTyping: false | ||
} | ||
]; | ||
expect(sortCaptionsAndRealTimeTexts(mockCaptions, mockRealTimeTexts)).toEqual(result); | ||
}); | ||
}); | ||
|
||
// for cc | ||
describe('Place holder test for cc', () => { | ||
test('place holder', async () => { | ||
expect(true).toEqual(true); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does mean that inprogress captions counts towards the 50?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes