mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Add test for setting socket override and verify no errors are thrown on reload. Closes #2355
This commit is contained in:
parent
3826f9380a
commit
eb1fc9706f
@ -1,4 +1,5 @@
|
|||||||
import { setup } from '../../support/setup.js';
|
import { setup } from '../../support/setup.js';
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
describe(`Live tests`, () => {
|
describe(`Live tests`, () => {
|
||||||
@ -67,4 +68,58 @@ describe(`Live tests`, () => {
|
|||||||
cy.wait(1500);
|
cy.wait(1500);
|
||||||
// cy.contains('is now known as').should('be.visible');
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user