diff --git a/app/components/live-participants.hbs b/app/components/live-participants.hbs new file mode 100644 index 00000000..eb595963 --- /dev/null +++ b/app/components/live-participants.hbs @@ -0,0 +1,44 @@ +
+

{{@user}}

+ +
\ No newline at end of file diff --git a/app/components/live-participants.js b/app/components/live-participants.js new file mode 100644 index 00000000..b7cea4ba --- /dev/null +++ b/app/components/live-participants.js @@ -0,0 +1,11 @@ +import Component from '@glimmer/component'; +import { ROLES } from '../constants/live'; +import { getOwner } from '@ember/application'; + +export default class LiveParticipantsComponent extends Component { + ROLES = ROLES; + + get liveService() { + return getOwner(this).lookup('service:live'); + } +} diff --git a/app/components/live-sidebar.hbs b/app/components/live-sidebar.hbs index b97f7bcd..f8ff6b5a 100644 --- a/app/components/live-sidebar.hbs +++ b/app/components/live-sidebar.hbs @@ -40,41 +40,26 @@ {{/each}} is presenting -
-

Guest Users

- -
+ + + \ No newline at end of file diff --git a/app/components/live-sidebar.js b/app/components/live-sidebar.js index 9ebce74a..97410018 100644 --- a/app/components/live-sidebar.js +++ b/app/components/live-sidebar.js @@ -7,10 +7,12 @@ import { getOwner } from '@ember/application'; export default class LiveHeaderComponent extends Component { @tracked isSideBarOpen = false; ROLES = ROLES; - get liveService() { - return getOwner(this).lookup('service:live'); - } + @action toggleMobileSidebar() { this.isSideBarOpen = !this.isSideBarOpen; } + + get liveService() { + return getOwner(this).lookup('service:live'); + } } diff --git a/app/services/live.js b/app/services/live.js index 740ae6eb..39c1466f 100644 --- a/app/services/live.js +++ b/app/services/live.js @@ -31,6 +31,9 @@ export default class LiveService extends Service { @globalRef('videoEl') videoEl; @tracked peers; @tracked isScreenShareOn; + @tracked mavenRole = ''; + @tracked moderatorRole = ''; + @tracked guestRole = ''; @tracked roomCodesForMaven = []; @tracked roomCodeLoading = false; @tracked userData = this.login?.userData; @@ -360,6 +363,13 @@ export default class LiveService extends Service { async renderScreenVideoToPeers(peers) { this.peers = peers; + const maven = peers.find((peer) => peer.roleName === ROLES.maven); + const moderator = peers.find((peer) => peer.roleName === ROLES.moderator); + const guest = peers.find((peer) => peer.roleName === ROLES.guest); + this.mavenRole = maven?.roleName; + this.moderatorRole = moderator?.roleName; + this.guestRole = guest?.roleName; + const presenterTrackId = peers?.find((p) => p.roleName === ROLES.host) ?.auxiliaryTracks[0]; if (presenterTrackId) { diff --git a/tests/constants/participants-data.js b/tests/constants/participants-data.js new file mode 100644 index 00000000..58312fcc --- /dev/null +++ b/tests/constants/participants-data.js @@ -0,0 +1,61 @@ +export const hostPeer = [ + { + id: 1, + name: 'Ankush', + roleName: 'host', + }, +]; + +export const mavenPeerData = [ + { + id: 1, + name: 'Ankush', + roleName: 'host', + }, + { + id: 2, + name: 'Maven1', + roleName: 'maven', + }, + { + id: 3, + name: 'Maven2', + roleName: 'maven', + }, +]; + +export const moderatorData = [ + { + id: 1, + name: 'Ankush', + roleName: 'host', + }, + { + id: 2, + name: 'Mod1', + roleName: 'moderator', + }, + { + id: 3, + name: 'Mod3', + roleName: 'moderator', + }, +]; + +export const guestData = [ + { + id: 1, + name: 'Ankush', + roleName: 'host', + }, + { + id: 2, + name: 'Guest1', + roleName: 'guest', + }, + { + id: 3, + name: 'Guest2', + roleName: 'guest', + }, +]; diff --git a/tests/integration/components/live-participants-test.js b/tests/integration/components/live-participants-test.js new file mode 100644 index 00000000..a4ea75b5 --- /dev/null +++ b/tests/integration/components/live-participants-test.js @@ -0,0 +1,133 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'website-www/tests/helpers'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; +import { + hostPeer, + mavenPeerData, + moderatorData, + guestData, +} from '../../constants/participants-data'; + +module('Integration | Component | live-participants', function (hooks) { + setupRenderingTest(hooks); + test('renders No Maven In the stream Text', async function (assert) { + this.setProperties({ + peers: hostPeer, + profilePic: 'profilepicurl', + isKickoutModalOpen: true, + }); + this.set('openKickoutModal', () => { + this.isKickoutModalOpen = true; + }); + await render(hbs``); + assert + .dom('[data-test-sidebar-body-role] .user') + .hasText('No Mavens in the stream'); + }); + + test('renders No Moderators In the stream Text', async function (assert) { + this.setProperties({ + peers: hostPeer, + profilePic: 'profilepicurl', + isKickoutModalOpen: true, + }); + this.set('openKickoutModal', () => { + this.isKickoutModalOpen = true; + }); + await render(hbs` `); + assert + .dom('[data-test-sidebar-body-role] .user') + .hasText('No Moderators in the stream'); + }); + + test('renders No Guests In the stream Text', async function (assert) { + this.setProperties({ + peers: hostPeer, + profilePic: 'profilepicurl', + isKickoutModalOpen: true, + }); + this.set('openKickoutModal', () => { + this.isKickoutModalOpen = true; + }); + await render(hbs` `); + assert + .dom('[data-test-sidebar-body-role] .user') + .hasText('No Guests in the stream'); + }); + + test('renders Mavens Lists who joined Stream', async function (assert) { + this.setProperties({ + peers: mavenPeerData, + profilePic: 'profilepicurl', + isKickoutModalOpen: true, + }); + this.set('openKickoutModal', () => { + this.isKickoutModalOpen = true; + }); + await render(hbs``); + assert.dom('[data-test-sidebar-user="2"]').hasText('Maven1'); + }); + + test('renders Moderators Lists who joined Stream', async function (assert) { + this.setProperties({ + peers: moderatorData, + profilePic: 'profilepicurl', + isKickoutModalOpen: true, + }); + this.set('openKickoutModal', () => { + this.isKickoutModalOpen = true; + }); + await render(hbs``); + assert.dom('[data-test-sidebar-user="3"]').hasText('Mod3'); + }); + + test('renders Guests Lists who joined Stream', async function (assert) { + this.setProperties({ + peers: guestData, + profilePic: 'profilepicurl', + isKickoutModalOpen: true, + }); + this.set('openKickoutModal', () => { + this.isKickoutModalOpen = true; + }); + await render(hbs``); + assert.dom('[data-test-sidebar-user="3"]').hasText('Guest2'); + }); +}); diff --git a/tests/integration/components/live-sidebar-test.js b/tests/integration/components/live-sidebar-test.js index 5b7f66e9..af38530c 100644 --- a/tests/integration/components/live-sidebar-test.js +++ b/tests/integration/components/live-sidebar-test.js @@ -7,7 +7,7 @@ module('Integration | Component | live-sidebar', function (hooks) { setupRenderingTest(hooks); test('live-sidebar renders', async function (assert) { - assert.expect(17); + assert.expect(12); this.setProperties({ peers: [ { @@ -48,17 +48,5 @@ module('Integration | Component | live-sidebar', function (hooks) { assert.dom('[data-test-sidebar-host-name]').exists(); assert.dom('[data-test-sidebar-host-name]').hasText('Ankush is presenting'); - - assert.dom('[data-test-sidebar-body-role]').exists(); - - assert.dom('[data-test-sidebar-body-role-guest]').exists(); - assert.dom('[data-test-sidebar-body-role-guest]').hasText('Guest Users'); - - assert.dom('[data-test-sidebar-user="2"]').exists(); - assert.strictEqual( - document.querySelector(`[data-test-sidebar-user="2"]`).innerText, - this.peers[1].name, - 'guest name is same!' - ); }); });