import {mockKalturaBe, loadPlayer} from './env'; const MANIFEST = `#EXTM3U #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,URI="${location.origin}/media/index_1.m3u8",SUBTITLES="subs" #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=509496,RESOLUTION=480x272,AUDIO="audio",SUBTITLES="subs" ${location.origin}/media/index.m3u8`; const MANIFEST_SAFARI = `#EXTM3U #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="English",DEFAULT=NO,AUTOSELECT=YES,FORCED=NO,LANGUAGE="en",URI="${location.origin}/media/index_1.m3u8" #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=504265,RESOLUTION=480x272,AUDIO="audio",SUBTITLES="subs" ${location.origin}/media/index.m3u8`; Cypress.on('uncaught:exception', (err, runnable) => { return false; }); describe('Info plugin', () => { beforeEach(() => { // manifest cy.intercept('GET', '**/a.m3u8*', Cypress.browser.name === 'webkit' ? MANIFEST_SAFARI : MANIFEST); // thumbnails cy.intercept('GET', '**/width/164/vid_slices/100', {fixture: '100.jpeg'}); cy.intercept('GET', '**/height/360/width/640', {fixture: '640.jpeg'}); // kava cy.intercept('POST', '**/index.php?service=analytics*', {}); }); it('should open and close Info plugin', () => { mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="infoRoot"]').should('exist'); cy.get('.playkit-close-overlay').click({force: true}); cy.get('[data-testid="infoRoot"]').should('not.exist'); }); }); describe('accessibility', () => { it('should name the dialog after the entry name', () => { mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[role="dialog"]') .invoke('attr', 'aria-labelledby') .should('match', /-info-title$/) .then(titleId => { cy.get(`[role="dialog"] h2[id="${titleId}"]`).should('have.text', 'MPEG Dash with MultiAudio New Transcoding'); }); }); }); it('should name the dialog with a fallback title when the entry has no name', () => { cy.fixture('vod-without-description.json').then(response => { response[1].objects[0].name = ''; cy.intercept('http://mock-api/service/multirequest', req => { if (req.body[2]?.service === 'baseEntry' && req.body[2]?.action === 'list') { req.reply(response); } }); }); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[role="dialog"]') .invoke('attr', 'aria-labelledby') .then(titleId => { cy.get(`[role="dialog"] h2[id="${titleId}"]`).should('have.text', 'Video info'); }); }); }); // closes Info by keyboard, then checks the overlay state, focus restore and that player shortcuts respond again const assertKeyboardClose = (closeByKeyboard: () => void) => { mockKalturaBe(); loadPlayer().then((kalturaPlayer: any) => { cy.get('[data-testid="infoPluginButton"]').focus().click({force: true}); cy.get('[data-testid="infoRoot"]').should('exist'); cy.wrap(kalturaPlayer).should((player: any) => { expect(player.ui.store.getState().overlay.isOpen).to.be.true; }); closeByKeyboard(); cy.get('[data-testid="infoRoot"]').should('not.exist'); cy.wrap(kalturaPlayer).should((player: any) => { expect(player.ui.store.getState().overlay.isOpen).to.be.false; }); cy.focused().should('have.attr', 'data-testid', 'infoPluginButton'); // M toggles mute only when the player keyboard handler is not blocked by an open overlay. // force: the upper bar may still be fading in, and a keydown does not need the button to be visible cy.wrap(kalturaPlayer) .its('muted') .then(mutedBefore => { cy.focused().trigger('keydown', {code: 'KeyM', key: 'm', keyCode: 77, force: true}); cy.wrap(kalturaPlayer).its('muted').should('eq', !mutedBefore); }); }); }; it('should close on Escape, restore focus and re-enable player keyboard shortcuts', () => { assertKeyboardClose(() => cy.get('[role="dialog"]').trigger('keydown', {code: 'Escape', key: 'Escape', keyCode: 27})); }); it('should close on Enter on the close button, restore focus and re-enable player keyboard shortcuts', () => { assertKeyboardClose(() => cy.get('.playkit-close-overlay').focus().trigger('keydown', {code: 'Enter', key: 'Enter', keyCode: 13})); }); }); describe('entry name', () => { it('should render entry name without description and broadcast date', () => { mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="entryDescription"]').should('not.exist'); cy.get('[data-testid="broadcastedDate"]').should('not.exist'); cy.get('[data-testid="entryName"]').should($div => { expect($div.text()).to.eq('MPEG Dash with MultiAudio New Transcoding'); }); }); }); }); describe('entry description', () => { it('should render entry description', () => { mockKalturaBe('vod-with-description.json'); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="entryDescription"]').should($div => { expect($div.text()).to.eq( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a.' ); }); }); }); it('should sanitize and render description with html tags inside', () => { const result = `line one
line two
line three
Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vestibulum ante ipsum primis in faucibus;
Last line

`; mockKalturaBe('vod-with-html-tags.json'); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="entryDescription"]').should($div => { expect($div.html()).to.eq(result); }); }); }); }); describe('entry broadcast and creation date', () => { it('should test live entry', () => { mockKalturaBe('live.json'); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="createdAt"]').should($div => { expect($div.text()).to.eq('Live now'); }); }); }); it('should test entry created more than year ago', () => { cy.clock(new Date(2025, 6, 24), ['Date']); mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="createdAt"]').should($div => { expect($div.text()).to.eq('More than a year ago'); }); }); }); it('should test entry created few months ago', () => { cy.clock(new Date(2022, 8, 10), ['Date']); mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="createdAt"]').should($div => { expect($div.text()).to.eq('2 Months ago'); }); }); }); it('should test entry created few days ago', () => { cy.clock(new Date(2022, 6, 9), ['Date']); mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="createdAt"]').should($div => { expect($div.text()).to.eq('3 days ago'); }); }); }); it('should test entry created today', () => { cy.clock(new Date(2022, 6, 5), ['Date']); mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="createdAt"]').should($div => { expect($div.text()).to.eq('Today'); }); }); }); it('should not render entry creation date if showCreatedAt is false', () => { mockKalturaBe(); loadPlayer({showCreatedAt: false}).then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="createdAt"]').should('not.exist'); }); }); }); describe('entry creator / owner', () => { it('should render entry creator by default', () => { mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="creator"]').should($div => { expect($div.text()).to.eq('By Test Creator'); }); }); }); it('should render entry owner if creator id is false', () => { mockKalturaBe(); loadPlayer({useCreatorId: false}).then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="creator"]').should($div => { expect($div.text()).to.eq('By Test Owner'); }); }); }); it('should not render entry owner if showUser is false', () => { mockKalturaBe(); loadPlayer({showUser: false}).then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="creator"]').should('not.exist'); }); }); }); describe('entry plays', () => { it('should render entry plays', () => { mockKalturaBe(); loadPlayer().then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="plays"]').should($div => { expect($div.text()).to.eq('19 plays'); }); }); }); it('should not render entry plays if showPlays is false', () => { mockKalturaBe(); loadPlayer({showPlays: false}).then(() => { cy.get('[data-testid="infoPluginButton"]').click({force: true}); cy.get('[data-testid="plays"]').should('not.exist'); }); }); }); });