Skip to content

WIP: CF SDK: Modified SignalWire Client with auth states #1192

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2c05e0f
CF SDK: Modified SignalWireClient with auth states
iAmmar7 Mar 21, 2025
824a793
merge with main
iAmmar7 Mar 21, 2025
279bfe1
expose auth state via callback
iAmmar7 Mar 25, 2025
bfe1376
add call id as a param to reattach method
iAmmar7 Mar 27, 2025
d703ca3
modified SAT session
iAmmar7 Mar 31, 2025
d78f6e6
fix unit tests
iAmmar7 Mar 31, 2025
10d7378
rename auth states in the store
iAmmar7 Mar 31, 2025
60470b1
update playground
iAmmar7 Mar 31, 2025
dbf2cab
remove on off from the interface
iAmmar7 Mar 31, 2025
088278b
rename session auth handler
iAmmar7 Mar 31, 2025
d28a255
add a unit test for the session slice
iAmmar7 Mar 31, 2025
5aaf78c
use SwAuthorizationState
iAmmar7 Mar 31, 2025
d8f2df8
refactor
iAmmar7 Mar 31, 2025
b6ddccb
introduce v4 modules
iAmmar7 Apr 1, 2025
e221e5d
merge with main
iAmmar7 Apr 1, 2025
113bdd1
include V4 WSClient and SATSession
iAmmar7 Apr 1, 2025
554a38a
store origin call id in the store
iAmmar7 Apr 1, 2025
17a0f8f
trigger callback with new worker
iAmmar7 Apr 2, 2025
71d1b3a
fix the build
iAmmar7 Apr 3, 2025
7b4fd14
fix reattach with new client
iAmmar7 Apr 3, 2025
27038b8
move v4 client to a dedicated folder
iAmmar7 Apr 3, 2025
df93dab
remove localstorage changes from the playground
iAmmar7 Apr 3, 2025
a13fb98
remove unused base component getters
iAmmar7 Apr 3, 2025
6244825
fallback the conversation changes
iAmmar7 Apr 3, 2025
be83732
refactor types
iAmmar7 Apr 3, 2025
8c06d87
refactor v4 client
iAmmar7 Apr 3, 2025
bfbdc88
create multi instance v4 client
iAmmar7 Apr 4, 2025
27a2987
reattach with v4 client
iAmmar7 Apr 7, 2025
fb07355
add one more test
iAmmar7 Apr 7, 2025
f415740
playwright project for both v3 and v4 clients
iAmmar7 Apr 8, 2025
df81f98
revert the protected select method
iAmmar7 Apr 8, 2025
5b5df3f
merge with main
iAmmar7 Apr 16, 2025
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
6 changes: 4 additions & 2 deletions .github/workflows/browser-js-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ jobs:
demote,
audience,
reattach,
callfabric,
renegotiation,
videoElement,
fabricV3,
fabricV4,
renegotiationV3,
renegotiationV4,
v2WebRTC,
]
steps:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/browser-js-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ jobs:
# demote,
# audience,
# reattach,
callfabric,
renegotiation,
videoElement,
fabricV3,
fabricV4,
renegotiationV3,
renegotiationV4,
v2WebRTC,
]
steps:
Expand Down
6 changes: 6 additions & 0 deletions internal/e2e-js/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type CustomFixture = {
createRelayAppResource: typeof createRelayAppResource
resources: Resource[]
}
useV4Client: boolean
}

const test = baseTest.extend<CustomFixture>({
Expand Down Expand Up @@ -125,6 +126,11 @@ const test = baseTest.extend<CustomFixture>({
await Promise.allSettled(deleteResources)
}
},
useV4Client: async ({}, use, testInfo) => {
const val =
(testInfo.project.use as { useV4Client: boolean }).useV4Client ?? false
await use(val)
},
})

export { test, expect, Page }
52 changes: 37 additions & 15 deletions internal/e2e-js/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ const reattachTests = [
'roomSessionReattachWrongCallId.spec.ts',
'roomSessionReattachWrongProtocol.spec.ts',
]
const callfabricTests = [
const videoElementTests = ['buildVideoWithVideoSDK.spec.ts']
const fabricV3Tests = ['reattach.spec.ts']
const fabricV4Tests = ['reattachV4.spec.ts']
const fabricBaseTests = [
'address.spec.ts',
'buildVideoWithFabricSDK.spec.ts',
'cleanup.spec.ts',
'conversation.spec.ts',
'holdunhold.spec.ts',
'raiseHand.spec.ts',
'reattach.spec.ts',
'relayApp.spec.ts',
'swml.spec.ts',
'videoRoom.spec.ts',
Expand All @@ -52,10 +55,6 @@ const renegotiationTests = [
'renegotiateAudio.spec.ts',
'renegotiateVideo.spec.ts',
]
const videoElementTests = [
'buildVideoWithVideoSDK.spec.ts',
'buildVideoWithFabricSDK.spec.ts',
]
const v2WebRTC = ['v2WebrtcFromRest.spec.ts', 'webrtcCalling.spec.ts']

const useDesktopChrome = {
Expand All @@ -70,6 +69,16 @@ const useDesktopChrome = {
},
}

const useFabricV3Client = {
...useDesktopChrome,
useV4Client: false,
}

const useFabricV4Client = {
...useDesktopChrome,
useV4Client: true,
}

const config: PlaywrightTestConfig = {
testDir: 'tests',
reporter: process.env.CI ? 'github' : 'list',
Expand All @@ -95,9 +104,11 @@ const config: PlaywrightTestConfig = {
...demoteTests,
...audienceTests,
...reattachTests,
...callfabricTests,
...renegotiationTests,
...videoElementTests,
...fabricBaseTests,
...fabricV3Tests,
...fabricV4Tests,
...renegotiationTests,
...v2WebRTC,
],
},
Expand Down Expand Up @@ -132,19 +143,29 @@ const config: PlaywrightTestConfig = {
testMatch: reattachTests,
},
{
name: 'callfabric',
name: 'videoElement',
use: useDesktopChrome,
testMatch: callfabricTests,
testMatch: videoElementTests,
},
{
name: 'renegotiation',
use: useDesktopChrome,
name: 'fabricV3',
use: useFabricV3Client,
testMatch: [...fabricBaseTests, ...fabricV3Tests],
},
{
name: 'fabricV4',
use: useFabricV4Client,
testMatch: [...fabricBaseTests, ...fabricV4Tests],
},
{
name: 'renegotiationV3',
use: useFabricV3Client,
testMatch: renegotiationTests,
},
{
name: 'videoElement',
use: useDesktopChrome,
testMatch: videoElementTests,
name: 'renegotiationV4',
use: useFabricV4Client,
testMatch: renegotiationTests,
},
{
name: 'v2WebRTC',
Expand All @@ -153,4 +174,5 @@ const config: PlaywrightTestConfig = {
},
],
}

export default config
21 changes: 15 additions & 6 deletions internal/e2e-js/tests/buildVideoWithFabricSDK.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ test.describe('buildVideoElement with CallFabric SDK', () => {

test('should not render any video if rootElement is not passed', async ({
createCustomPage,
useV4Client,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)
const roomName = randomizeRoomName('build-video-element')
await resource.createVideoRoomResource(roomName)

await createCFClient(page)
await createCFClient(page, { useV4Client })

// Dial an address and join a video room without passing the rootElement
await dialAddress(page, {
Expand All @@ -56,14 +57,15 @@ test.describe('buildVideoElement with CallFabric SDK', () => {

test('should return the rootElement', async ({
createCustomPage,
useV4Client,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)
const roomName = randomizeRoomName('build-video-element')
await resource.createVideoRoomResource(roomName)

await createCFClient(page)
await createCFClient(page, { useV4Client })

// Dial an address and join a video room without passing the rootElement
await dialAddress(page, {
Expand Down Expand Up @@ -116,14 +118,15 @@ test.describe('buildVideoElement with CallFabric SDK', () => {

test('should render multiple video elements', async ({
createCustomPage,
useV4Client,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)
const roomName = randomizeRoomName('build-video-element')
await resource.createVideoRoomResource(roomName)

await createCFClient(page)
await createCFClient(page, { useV4Client })

// Dial and expect both video and member overlays
await dialAddress(page, {
Expand Down Expand Up @@ -255,14 +258,15 @@ test.describe('buildVideoElement with CallFabric SDK', () => {

test('should render the video even if the function is called before call.start', async ({
createCustomPage,
useV4Client,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)
const roomName = randomizeRoomName('build-video-element')
await resource.createVideoRoomResource(roomName)

await createCFClient(page)
await createCFClient(page, { useV4Client })

// Create and expect 1 video elements
await page.evaluate(
Expand Down Expand Up @@ -307,14 +311,15 @@ test.describe('buildVideoElement with CallFabric SDK', () => {

test('should not create a new element if the elements are same', async ({
createCustomPage,
useV4Client,
resource,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)
const roomName = randomizeRoomName('build-video-element')
await resource.createVideoRoomResource(roomName)

await createCFClient(page)
await createCFClient(page, { useV4Client })

// Dial an address and join a video room with rootElement
await dialAddress(page, {
Expand Down Expand Up @@ -345,6 +350,7 @@ test.describe('buildVideoElement with CallFabric SDK', () => {

test('should handle the element for multiple users', async ({
createCustomPage,
useV4Client,
resource,
}) => {
const pageOne = await createCustomPage({ name: '[pageOne]' })
Expand All @@ -355,7 +361,10 @@ test.describe('buildVideoElement with CallFabric SDK', () => {
const roomName = randomizeRoomName('build-video-element')
await resource.createVideoRoomResource(roomName)

await Promise.all([createCFClient(pageOne), createCFClient(pageTwo)])
await Promise.all([
createCFClient(pageOne, { useV4Client }),
createCFClient(pageTwo, { useV4Client }),
])

// Dial an address and join a video room from pageOne
await dialAddress(pageOne, {
Expand Down
9 changes: 6 additions & 3 deletions internal/e2e-js/tests/callfabric/address.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { SERVER_URL, createCFClient } from '../../utils'
test.describe('Addresses', () => {
test('query multiple addresses and single address', async ({
createCustomPage,
useV4Client,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

await createCFClient(page)
await createCFClient(page, { useV4Client })

const { addressById, addressByName, addressToCompare } =
await page.evaluate(async () => {
Expand All @@ -35,11 +36,12 @@ test.describe('Addresses', () => {

test('Should return only type rooms in ASC order by name', async ({
createCustomPage,
useV4Client,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

await createCFClient(page)
await createCFClient(page, { useV4Client })

const isCorrectlySorted = await page.evaluate(async () => {
// @ts-expect-error
Expand Down Expand Up @@ -95,11 +97,12 @@ test.describe('Addresses', () => {
*/
test.skip('Should return only type rooms in DESC order by name', async ({
createCustomPage,
useV4Client,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

await createCFClient(page)
await createCFClient(page, { useV4Client })

const isCorrectlySorted = await page.evaluate(async () => {
// @ts-expect-error
Expand Down
13 changes: 9 additions & 4 deletions internal/e2e-js/tests/callfabric/cleanup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
} from '../../utils'

test.describe('Clean up', () => {
test('it should create a webscoket client', async ({ createCustomPage }) => {
test('it should create a webscoket client', async ({
createCustomPage,
useV4Client,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

Expand All @@ -30,7 +33,7 @@ test.describe('Clean up', () => {

expect(websocketUrl).toBe(null)

await createCFClient(page)
await createCFClient(page, { useV4Client })

await disconnectClient(page)

Expand All @@ -42,11 +45,12 @@ test.describe('Clean up', () => {

test('it should cleanup session emitter and workers', async ({
createCustomPage,
useV4Client,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

await createCFClient(page, { attachSagaMonitor: true })
await createCFClient(page, { attachSagaMonitor: true, useV4Client })

await test.step('the client should have workers and listeners attached', async () => {
const watchers: Record<string, number> = await page.evaluate(() => {
Expand Down Expand Up @@ -91,14 +95,15 @@ test.describe('Clean up', () => {
test('it should cleanup call emitter and workers without affecting the client', async ({
createCustomPage,
resource,
useV4Client,
}) => {
const page = await createCustomPage({ name: '[page]' })
await page.goto(SERVER_URL)

const roomName = `e2e-cleanup_${uuid()}`
await resource.createVideoRoomResource(roomName)

await createCFClient(page, { attachSagaMonitor: true })
await createCFClient(page, { attachSagaMonitor: true, useV4Client })

// Dial an address and join a video room
await dialAddress(page, {
Expand Down
5 changes: 3 additions & 2 deletions internal/e2e-js/tests/callfabric/conversation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
test('send message in a room conversation', async ({
createCustomPage,
resource,
useV4Client,
}) => {
const page = await createCustomPage({ name: '[page]' })
const page2 = await createCustomPage({
Expand All @@ -18,8 +19,8 @@
await page.goto(SERVER_URL)
await page2.goto(SERVER_URL)

await createCFClient(page)
await createCFClient(page2)
await createCFClient(page, { useV4Client })
await createCFClient(page2, { useV4Client })

const roomName = `e2e-js-convo-room_${uuid()}`
await resource.createVideoRoomResource(roomName)
Expand Down Expand Up @@ -94,7 +95,7 @@

expect(messages).not.toBeUndefined()

expect(messages.data.length).toEqual(2)

Check failure on line 98 in internal/e2e-js/tests/callfabric/conversation.spec.ts

View workflow job for this annotation

GitHub Actions / Browser SDK production / Run E2E tests (20.x, fabricV4)

[fabricV4] › tests/callfabric/conversation.spec.ts:10:7 › Conversation Room › send message in a room conversation

1) [fabricV4] › tests/callfabric/conversation.spec.ts:10:7 › Conversation Room › send message in a room conversation Error: expect(received).toEqual(expected) // deep equality Expected: 2 Received: 1 96 | expect(messages).not.toBeUndefined() 97 | > 98 | expect(messages.data.length).toEqual(2) | ^ 99 | expect(messages.data[0]).toMatchObject(*** 100 | conversation_id: addressId, 101 | details: ***, at /home/runner/work/signalwire-js/signalwire-js/internal/e2e-js/tests/callfabric/conversation.spec.ts:98:34

Check failure on line 98 in internal/e2e-js/tests/callfabric/conversation.spec.ts

View workflow job for this annotation

GitHub Actions / Browser SDK production / Run E2E tests (20.x, fabricV3)

[fabricV3] › tests/callfabric/conversation.spec.ts:10:7 › Conversation Room › send message in a room conversation

1) [fabricV3] › tests/callfabric/conversation.spec.ts:10:7 › Conversation Room › send message in a room conversation Error: expect(received).toEqual(expected) // deep equality Expected: 2 Received: 1 96 | expect(messages).not.toBeUndefined() 97 | > 98 | expect(messages.data.length).toEqual(2) | ^ 99 | expect(messages.data[0]).toMatchObject(*** 100 | conversation_id: addressId, 101 | details: ***, at /home/runner/work/signalwire-js/signalwire-js/internal/e2e-js/tests/callfabric/conversation.spec.ts:98:34
expect(messages.data[0]).toMatchObject({
conversation_id: addressId,
details: {},
Expand Down
5 changes: 3 additions & 2 deletions internal/e2e-js/tests/callfabric/holdunhold.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test.describe('CallFabric Hold/Unhold Call', () => {
test('should dial a call and be able to hold/unhold the call', async ({
createCustomPage,
resource,
useV4Client,
}) => {
const pageOne = await createCustomPage({ name: '[page-one]' })
const pageTwo = await createCustomPage({ name: '[page-two]' })
Expand All @@ -25,15 +26,15 @@ test.describe('CallFabric Hold/Unhold Call', () => {
await resource.createVideoRoomResource(roomName)

await test.step('[page-one] should create a client and dial a call', async () => {
await createCFClient(pageOne)
await createCFClient(pageOne, { useV4Client })
await dialAddress(pageOne, {
address: `/public/${roomName}?channel=video`,
})
await expectMCUVisible(pageOne)
})

await test.step('[page-two] should create a client and dial a call', async () => {
await createCFClient(pageTwo)
await createCFClient(pageTwo, { useV4Client })
await dialAddress(pageTwo, {
address: `/public/${roomName}?channel=video`,
})
Expand Down
Loading
Loading