-
Notifications
You must be signed in to change notification settings - Fork 78
HorizontalGallery UI tests using MockCallingAdapter #1347
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
Merged
Merged
Changes from 49 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
1b8aacc
rough POC
mgamis-msft 7a7b16f
added mock video element
mgamis-msft 6e89486
Move HTMLElement generation for videostream in MockCallAdapter
mgamis-msft 0416b26
added state into qArgs as an option
mgamis-msft 2468aea
Added one more video participant
mgamis-msft 442d31d
created CallingState type
mgamis-msft 64bc31f
HorizontalGallery paged tests added
mgamis-msft 1478d82
Added identifiers to HorizontalGallery buttons. Clicking buttons in U…
mgamis-msft c6ace27
Merge branch 'main' into mgamis/mock-calling-state
mgamis-msft ce69a63
rename to TestCallingState, clean up and added documentation
mgamis-msft 1286ae9
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft 1211a61
change files
mgamis-msft a1a5167
address insecure randomness flag from CodeQL
mgamis-msft ca24e38
fixed error in call test uitls.ts
mgamis-msft 9859c33
Change file changed from prerelease to minor
mgamis-msft 69bf503
stable-review api changes
mgamis-msft 4c7ed73
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft cd4e7b5
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft aa71c7b
clean up MockCallAdapter
mgamis-msft dac0175
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft 4799998
removed delay in HorizontalGallery UI tests. Changed remoteParticipan…
mgamis-msft 76e0f16
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft d9bbf63
small refactor
mgamis-msft 9582202
more readable code
mgamis-msft 96b57e0
fixed MockCallAdapter constuctor
mgamis-msft a6fe754
MockAdapter refactor checkpoint
mgamis-msft f3ab0b7
refactor checkpoint 2
mgamis-msft c08adf0
refactor checkpoint 3
mgamis-msft d6a1c21
small fixes in MockCallAdapter
mgamis-msft 20f1d19
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft b2759db
Delete locally generated snapshot
mgamis-msft 013b0e0
added clickOffPage util function
mgamis-msft 0b30de1
Update doc
mgamis-msft 1c437ff
small cleanup
mgamis-msft a6f0fe5
removed default test remote participants
mgamis-msft c9c4310
removed useMockAdapter query argument
mgamis-msft 771c198
deleted old snapshots after rename
mgamis-msft 76f58dd
Added helper function to create CallAdapter using createAzureCommunic…
mgamis-msft 0ec2f58
buildUrlWithMockAdapter doc improvement
mgamis-msft 8e89fdc
added wait for VideoGallery render in each test
mgamis-msft 44fd3f7
rename snapshots
mgamis-msft 1f66e33
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft 632a5fc
better documentation of MockCallAdapter
mgamis-msft ea52be5
cleaned up MockCallingAdapter handlers
mgamis-msft e32b2dd
fixed initial state in MockCallAdapter constructor
mgamis-msft 279893e
small fix
mgamis-msft 9087cc4
clickOffPage -> clickOutsideOfPage
mgamis-msft 308c61d
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft 295fdba
Removed snapshot updates from localization UI tests
mgamis-msft 6f20640
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft b1fdfc9
remove casting of param to TestCallingState
mgamis-msft 1e6a9bd
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft 46b58ed
Merge branch 'main' into mgamis/horizontal-gallery-ui-tests
mgamis-msft c0a7f66
try-catch statement to parse mockCallState
mgamis-msft ec50d17
Update composite automation snapshots
github-actions[bot] a99b486
Update composite automation snapshots
github-actions[bot] 39e9a99
Revert "try-catch statement to parse mockCallState"
mgamis-msft 62c7a68
Revert "Revert "try-catch statement to parse mockCallState""
mgamis-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
7 changes: 7 additions & 0 deletions
7
change/@internal-react-components-c719cfda-ce9d-4a95-87a3-47326ceb56d2.json
This file contains hidden or 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,7 @@ | ||
| { | ||
| "type": "minor", | ||
| "comment": "Identifiers added for HorizontalGallery left and right navigation buttons.", | ||
| "packageName": "@internal/react-components", | ||
| "email": "miguelgamis@microsoft.com", | ||
| "dependentChangeType": "patch" | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
95 changes: 95 additions & 0 deletions
95
packages/react-composites/tests/browser/call/HorizontalGallery.test.ts
This file contains hidden or 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,95 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { test } from './fixture'; | ||
| import { expect } from '@playwright/test'; | ||
| import { buildUrlWithMockAdapter } from './utils'; | ||
| import { dataUiId, pageClick, clickOutsideOfPage, waitForPageFontsLoaded, waitForSelector } from '../common/utils'; | ||
| import { IDS } from '../common/constants'; | ||
|
|
||
| test.describe('HorizontalGallery tests', async () => { | ||
| test('HorizontalGallery should have 1 audio participant', async ({ pages, serverUrl }) => { | ||
| const page = pages[0]; | ||
| const testRemoteParticipants = [ | ||
| { | ||
| displayName: 'Paul Bridges', | ||
| isSpeaking: true, | ||
| isVideoStreamAvailable: true | ||
| }, | ||
| { | ||
| displayName: 'Eryka Klein' | ||
| }, | ||
| { | ||
| displayName: 'Fiona Harper', | ||
| isVideoStreamAvailable: true | ||
| } | ||
| ]; | ||
| await page.goto( | ||
| buildUrlWithMockAdapter(serverUrl, { | ||
| remoteParticipants: testRemoteParticipants | ||
| }) | ||
| ); | ||
| // Click off page to turn away initial aria label | ||
| await clickOutsideOfPage(page); | ||
| await waitForSelector(page, dataUiId(IDS.videoGallery)); | ||
| await waitForPageFontsLoaded(page); | ||
|
JamesBurnside marked this conversation as resolved.
|
||
| expect(await page.screenshot()).toMatchSnapshot('horizontal-gallery-with-1-audio-participant.png'); | ||
| }); | ||
|
|
||
| test('HorizontalGallery should have multiple audio participants spanning multiple pages. Navigation buttons should work.', async ({ | ||
| pages, | ||
| serverUrl | ||
| }) => { | ||
| const page = pages[0]; | ||
| const testRemoteParticipants = [ | ||
| { | ||
| displayName: 'Paul Bridges', | ||
| isSpeaking: true, | ||
| isVideoStreamAvailable: true | ||
| }, | ||
| { | ||
| displayName: 'Eryka Klein' | ||
| }, | ||
| { | ||
| displayName: 'Fiona Harper', | ||
| isVideoStreamAvailable: true | ||
| }, | ||
| { | ||
| displayName: 'Pardeep Singh' | ||
| }, | ||
| { | ||
| displayName: 'Reina Takizawa', | ||
| isSpeaking: true | ||
| }, | ||
| { | ||
| displayName: 'Vasily Podkolzin', | ||
| isMuted: true | ||
| }, | ||
| { | ||
| displayName: 'Luciana Rodriguez' | ||
| }, | ||
| { | ||
| displayName: 'Antonie van Leeuwenhoek' | ||
| }, | ||
| { | ||
| displayName: 'Gerald Ho' | ||
| } | ||
| ]; | ||
| await page.goto( | ||
| buildUrlWithMockAdapter(serverUrl, { | ||
| remoteParticipants: testRemoteParticipants | ||
| }) | ||
| ); | ||
| // Click off page to turn away initial aria label | ||
| await clickOutsideOfPage(page); | ||
| await waitForSelector(page, dataUiId(IDS.videoGallery)); | ||
| await waitForPageFontsLoaded(page); | ||
|
JamesBurnside marked this conversation as resolved.
|
||
| expect(await page.screenshot()).toMatchSnapshot('horizontal-gallery-with-many-audio-participants-on-page-1.png'); | ||
| await waitForSelector(page, dataUiId(IDS.horizontalGalleryRightNavButton)); | ||
| await pageClick(page, dataUiId(IDS.horizontalGalleryRightNavButton)); | ||
| expect(await page.screenshot()).toMatchSnapshot('horizontal-gallery-with-many-audio-participants-on-page-2.png'); | ||
| await waitForSelector(page, dataUiId(IDS.horizontalGalleryLeftNavButton)); | ||
| await pageClick(page, dataUiId(IDS.horizontalGalleryLeftNavButton)); | ||
| expect(await page.screenshot()).toMatchSnapshot('horizontal-gallery-with-many-audio-participants-on-page-1.png'); | ||
| }); | ||
| }); | ||
Binary file added
BIN
+15.8 KB
...-snapshots/horizontal-gallery-with-1-audio-participant-Desktop-Chrome-win32.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
+38.6 KB
...s/horizontal-gallery-with-1-audio-participant-Mobile-Android-Portrait-win32.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
+23.7 KB
...izontal-gallery-with-many-audio-participants-on-page-1-Desktop-Chrome-win32.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
+46.1 KB
...allery-with-many-audio-participants-on-page-1-Mobile-Android-Portrait-win32.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
+21.3 KB
...izontal-gallery-with-many-audio-participants-on-page-2-Desktop-Chrome-win32.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
+46.8 KB
...allery-with-many-audio-participants-on-page-2-Mobile-Android-Portrait-win32.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 removed
BIN
-22.1 KB
...on.test.ts-snapshots/localized-call-configuration-page-Desktop-Chrome-win32.png
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
packages/react-composites/tests/browser/call/TestCallingState.ts
This file contains hidden or 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,19 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| /** | ||
| * Calling state passed as as a query argument to set up MockCallingAdapter in playwright test | ||
| */ | ||
| export type TestCallingState = { | ||
| remoteParticipants?: TestRemoteParticipant[]; | ||
| }; | ||
|
|
||
| /** | ||
| * Remote participant state used in {@link TestCallingState} | ||
| */ | ||
| export type TestRemoteParticipant = { | ||
| displayName: string; | ||
| isMuted?: boolean; | ||
| isSpeaking?: boolean; | ||
| isVideoStreamAvailable?: boolean; | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -20,19 +20,15 @@ import { | |
| import { IDS } from '../../common/constants'; | ||
| import { isMobile, verifyParamExists } from '../../common/testAppUtils'; | ||
| import memoizeOne from 'memoize-one'; | ||
| import { FontIcon, Icon, IContextualMenuItem, mergeStyles } from '@fluentui/react'; | ||
| import { Icon, IContextualMenuItem, mergeStyles } from '@fluentui/react'; | ||
| import { fromFlatCommunicationIdentifier } from '@internal/acs-ui-common'; | ||
| import { MockCallAdapter } from './mocks/MockCallAdapter'; | ||
| import { TestCallingState } from '../TestCallingState'; | ||
|
|
||
| const urlSearchParams = new URLSearchParams(window.location.search); | ||
| const params = Object.fromEntries(urlSearchParams.entries()); | ||
|
|
||
| // Required params | ||
| const displayName = verifyParamExists(params.displayName, 'displayName'); | ||
| const token = verifyParamExists(params.token, 'token'); | ||
| const groupId = verifyParamExists(params.groupId, 'groupId'); | ||
| const userId = verifyParamExists(params.userId, 'userId'); | ||
|
|
||
| // Optional params | ||
| const mockCallState = JSON.parse(params.mockCallState) as TestCallingState; | ||
| const useFrLocale = Boolean(params.useFrLocale); | ||
| const showCallDescription = Boolean(params.showCallDescription); | ||
| const injectParticipantMenuItems = Boolean(params.injectParticipantMenuItems); | ||
|
|
@@ -43,13 +39,11 @@ function App(): JSX.Element { | |
|
|
||
| useEffect(() => { | ||
| const initialize = async (): Promise<void> => { | ||
| const newAdapter = await createAzureCommunicationCallAdapter({ | ||
| userId: fromFlatCommunicationIdentifier(userId) as CommunicationUserIdentifier, | ||
| displayName, | ||
| credential: new AzureCommunicationTokenCredential(token), | ||
| locator: { groupId: groupId } | ||
| }); | ||
| setCallAdapter(wrapAdapterForTests(newAdapter)); | ||
| if (mockCallState) { | ||
| setCallAdapter(wrapAdapterForTests(new MockCallAdapter(mockCallState))); | ||
| } else { | ||
| setCallAdapter(wrapAdapterForTests(await createCallAdapterWithCredentials())); | ||
| } | ||
| }; | ||
|
|
||
| initialize(); | ||
|
|
@@ -154,6 +148,22 @@ const unsetSpeakingWhileMicrophoneIsMuted = (state: CallAdapterState): CallAdapt | |
| */ | ||
| const memoizedUnsetSpeakingWhileMicrophoneIsMuted = memoizeOne(unsetSpeakingWhileMicrophoneIsMuted); | ||
|
|
||
| // Function to create call adapter using createAzureCommunicationCallAdapter | ||
| const createCallAdapterWithCredentials = async (): Promise<CallAdapter> => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice tidy refactor! |
||
| const displayName = verifyParamExists(params.displayName, 'displayName'); | ||
| const token = verifyParamExists(params.token, 'token'); | ||
| const groupId = verifyParamExists(params.groupId, 'groupId'); | ||
| const userId = verifyParamExists(params.userId, 'userId'); | ||
|
|
||
| const callAdapter = await createAzureCommunicationCallAdapter({ | ||
| userId: fromFlatCommunicationIdentifier(userId) as CommunicationUserIdentifier, | ||
| displayName, | ||
| credential: new AzureCommunicationTokenCredential(token), | ||
| locator: { groupId: groupId } | ||
| }); | ||
| return callAdapter; | ||
| }; | ||
|
|
||
| function onFetchParticipantMenuItems(): IContextualMenuItem[] { | ||
| return [ | ||
| { | ||
|
|
||
Oops, something went wrong.
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.
It might have been a mistake exposing
_Identifiersthrough the public API (we thought @internal was OK for this, but unsure).Let's not add to this anymore. Just directly use
data-ui-idin the component and directly use thedata-ui-idfrom e2e tests, like we already do for composites.Thanks for trying to stick to this pattern...