Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

2.1 KB
Raw Blame
import { setup } from '../../support/setup.js';
import filterTests from '../../support/filterTests';

setup();

describe(`Live tests`, () => {
	it('Can visit the page', () => {
		cy.visit('http://localhost:8080');
	});

	it('Should have a play button', () => {
		cy.get('.vjs-big-play-button').should('be.visible');
	});

	it('User menu should be visible', () => {
		cy.get('#user-menu').should('be.visible');
	});
});

filterTests(['desktop'], () => {
	describe(`Live desktop tests`, () => {
		it('Click on user menu', () => {
			cy.get('#user-menu').click();
		});
		it('Can toggle chat off', () => {
			cy.contains('Hide Chat').click();
		});

		it('Chat should not be visible', () => {
			cy.get('#chat-container').should('not.exist');
		});

		it('Click on user menu', () => {
			cy.get('#user-menu').click();
		});

		it('Can toggle chat on', () => {
			cy.contains('Show Chat').click();
		});

		it('Click on user menu', () => {
			cy.get('#user-menu').click();
		});

		it('Show change name modal', () => {
			cy.contains('Change name').click();
		});

		it('Should change name', () => {
			cy.get('#name-change-field').focus();
			cy.get('#name-change-field').type('{selectall}');
			cy.get('#name-change-field').type('my-new-name');
			cy.get('#name-change-submit').click();
			// The rename round-trips over the chat websocket and updates the
			// user menu, so assert on that instead of sleeping.
			cy.get('#user-menu').should('contain', 'my-new-name');
		});

		it('Should change to custom websocket host', () => {
			cy.setConfig('sockethostoverride', 'ws://localhost:8080');
		});

		it('Refresh page with new socket host', () => {
			cy.visit('http://localhost:8080');
		});

		it('Can send a chat message over the overridden websocket host', () => {
			// Round-trips a real message: typed into the input, sent over the
			// overridden socket, broadcast back, and rendered in the feed
			// under the name set earlier in this spec.
			cy.get('#chat-input-content-editable').type(
				'e2e message via custom socket{enter}',
			);
			cy.contains('.chat-message_user', 'e2e message via custom socket')
				.should('be.visible')
				.and('contain', 'my-new-name');
		});
	});
});