Hide disabled features (#2473)
* Hide/show on notify and fediverse feature disable/enable * Update browser tests to enable features for testing * Hide/show features in mobile action menu * Do not show fediauth option if fediverse features are not enabled. * Force showing tabs when in Storybook
This commit is contained in:
@@ -9,8 +9,8 @@ describe(`Basic tests`, () => {
|
||||
// Offline banner
|
||||
it('Has correct offline banner values', () => {
|
||||
cy.contains(
|
||||
'This stream is offline. Be notified the next time New Owncast Server goes live.'
|
||||
).should('be.visible');
|
||||
'This stream is offline. You can be notified the next time New Owncast Server goes live or follow streamer@testing.biz on the Fediverse.'
|
||||
).should('exist');
|
||||
});
|
||||
|
||||
// Verify the tags show up
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { setup } from '../../support/setup.js';
|
||||
import fetchData from '../../support/fetchData.js';
|
||||
|
||||
setup();
|
||||
|
||||
@@ -81,45 +82,3 @@ describe(`Live tests`, () => {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
@@ -15,6 +15,21 @@
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands';
|
||||
import fetchData from './fetchData.js';
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
|
||||
// Put Owncast in a state where it's ready to be tested.
|
||||
|
||||
// Set server URL
|
||||
fetchData('http://localhost:8080/api/admin/config/serverurl', {
|
||||
method: 'POST',
|
||||
data: { value: 'https://testing.biz' },
|
||||
});
|
||||
|
||||
// Enable Fediverse features.
|
||||
fetchData('http://localhost:8080/api/admin/config/federation/enable', {
|
||||
method: 'POST',
|
||||
data: { value: true },
|
||||
});
|
||||
|
||||
43
test/automated/browser/cypress/support/fetchData.js
Normal file
43
test/automated/browser/cypress/support/fetchData.js
Normal file
@@ -0,0 +1,43 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
export default fetchData;
|
||||
Reference in New Issue
Block a user