Skip to content

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

Add test for setting socket override and verify no errors are thrown on reload. Closes #2355

Gabe Kangasdf2dde85cbff
diff --git a/test/automated/browser/cypress/e2e/online/01_online_live.cy.js b/test/automated/browser/cypress/e2e/online/01_online_live.cy.js
index 3c3e66795e..408926f291 100644
--- a/test/automated/browser/cypress/e2e/online/01_online_live.cy.js
+++ b/test/automated/browser/cypress/e2e/online/01_online_live.cy.js
@@ -1,4 +1,5 @@
import { setup } from '../../support/setup.js';
+
setup();
describe(`Live tests`, () => {
@@ -67,4 +68,58 @@ describe(`Live tests`, () => {
cy.wait(1500);
// cy.contains('is now known as').should('be.visible');
});
+
+ it('Should change to custom websocket host', () => {
+ fetchData('http://localhost:8080/api/admin/config/sockethostoverride', {
+ method: 'POST',
+ data: { value: 'ws://localhost:8080' },
+ });
+ cy.wait(1500);
+ });
+
+ it('Refresh page with new socket host', () => {
+ cy.visit('http://localhost:8080');
+ });
});
+
+async function fetchData(url, options) {
+ const ADMIN_USERNAME = 'admin';
+ const ADMIN_STREAMKEY = 'abc123';
+
+ const { data, method = 'GET', auth = true } = options || {};
+
+ // eslint-disable-next-line no-undef
+ const requestOptions = {
+ method,
+ };
+
+ if (data) {
+ requestOptions.body = JSON.stringify(data);
+ }
+
+ if (auth && ADMIN_USERNAME && ADMIN_STREAMKEY) {
+ const encoded = btoa(`${ADMIN_USERNAME}:${ADMIN_STREAMKEY}`);
+ requestOptions.headers = {
+ Authorization: `Basic ${encoded}`,
+ };
+ requestOptions.mode = 'cors';
+ requestOptions.credentials = 'include';
+ }
+
+ try {
+ const response = await fetch(url, requestOptions);
+ const json = await response.json();
+
+ if (!response.ok) {
+ const message =
+ json.message || `An error has occurred: ${response.status}`;
+ throw new Error(message);
+ }
+ return json;
+ } catch (error) {
+ console.error(error);
+ return error;
+ // console.log(error)
+ // throw new Error(error)
+ }
+}