From 56d52c283c642e527f5869f117b21646bab44145 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Fri, 15 Nov 2024 18:39:15 -0800 Subject: [PATCH] chore(tests): clean up browser tests by splitting out federation UI tests --- test/automated/browser/cypress.config.js | 1 + .../e2e/offline/00-offline_performance.cy.js | 34 ++++++++++++++ .../e2e/offline/00_offline_performance.cy.js | 14 ------ ...ine_basic.cy.js => 01-offline_basic.cy.js} | 11 ----- ...bed.cy.js => 02-offline_video_embed.cy.js} | 0 ... => 03-offline_readwrite_chat_embed.cy.js} | 0 ...s => 04-offline_readonly_chat_embed.cy.js} | 0 ...y.js => 05-offline_identifier_check.cy.js} | 8 ---- ...e_mobile.cy.js => 06-offline_mobile.cy.js} | 2 +- .../07-offline_enabled_fediverse.cy.js | 44 +++++++++++++++++++ test/automated/browser/cypress/support/e2e.js | 18 +++----- 11 files changed, 86 insertions(+), 46 deletions(-) create mode 100644 test/automated/browser/cypress/e2e/offline/00-offline_performance.cy.js delete mode 100644 test/automated/browser/cypress/e2e/offline/00_offline_performance.cy.js rename test/automated/browser/cypress/e2e/offline/{01_offline_basic.cy.js => 01-offline_basic.cy.js} (75%) rename test/automated/browser/cypress/e2e/offline/{02_offline_video_embed.cy.js => 02-offline_video_embed.cy.js} (100%) rename test/automated/browser/cypress/e2e/offline/{03_offline_readwrite_chat_embed.cy.js => 03-offline_readwrite_chat_embed.cy.js} (100%) rename test/automated/browser/cypress/e2e/offline/{04_offline_readonly_chat_embed.cy.js => 04-offline_readonly_chat_embed.cy.js} (100%) rename test/automated/browser/cypress/e2e/offline/{05_offline_identifier_check.cy.js => 05-offline_identifier_check.cy.js} (83%) rename test/automated/browser/cypress/e2e/offline/{06_offline_mobile.cy.js => 06-offline_mobile.cy.js} (85%) create mode 100644 test/automated/browser/cypress/e2e/offline/07-offline_enabled_fediverse.cy.js diff --git a/test/automated/browser/cypress.config.js b/test/automated/browser/cypress.config.js index 91a67ffbf..fe9c6abf9 100644 --- a/test/automated/browser/cypress.config.js +++ b/test/automated/browser/cypress.config.js @@ -4,6 +4,7 @@ const { lighthouse, prepareAudit } = require('@cypress-audit/lighthouse'); module.exports = defineConfig({ projectId: 'wwi3xe', e2e: { + supportFile: 'cypress/support/e2e.js', setupNodeEvents(on, config) { on('before:browser:launch', (browser = {}, launchOptions) => { prepareAudit(launchOptions); diff --git a/test/automated/browser/cypress/e2e/offline/00-offline_performance.cy.js b/test/automated/browser/cypress/e2e/offline/00-offline_performance.cy.js new file mode 100644 index 000000000..1ebd971ea --- /dev/null +++ b/test/automated/browser/cypress/e2e/offline/00-offline_performance.cy.js @@ -0,0 +1,34 @@ +// describe('Lighthouse Metrics', () => { +// beforeEach(() => { +// cy.visit('http://localhost:8080'); +// }); + +// it('Capture Metrics', () => { +// cy.lighthouse({ +// accessibility: 97, +// 'best-practices': 90, +// seo: 90, +// performance: 0, // Once the performance issues are fixed revert this 90, +// }); +// }); +// }); + +import fetchData from '../../support/fetchData.js'; + +// Alternatively you can use CommonJS syntax: +// require('./commands') + +console.log('------------- support/e2e.js'); +// 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 }, +}); diff --git a/test/automated/browser/cypress/e2e/offline/00_offline_performance.cy.js b/test/automated/browser/cypress/e2e/offline/00_offline_performance.cy.js deleted file mode 100644 index 8fbe465e4..000000000 --- a/test/automated/browser/cypress/e2e/offline/00_offline_performance.cy.js +++ /dev/null @@ -1,14 +0,0 @@ -// describe('Lighthouse Metrics', () => { -// beforeEach(() => { -// cy.visit('http://localhost:8080'); -// }); - -// it('Capture Metrics', () => { -// cy.lighthouse({ -// accessibility: 97, -// 'best-practices': 90, -// seo: 90, -// performance: 0, // Once the performance issues are fixed revert this 90, -// }); -// }); -// }); diff --git a/test/automated/browser/cypress/e2e/offline/01_offline_basic.cy.js b/test/automated/browser/cypress/e2e/offline/01-offline_basic.cy.js similarity index 75% rename from test/automated/browser/cypress/e2e/offline/01_offline_basic.cy.js rename to test/automated/browser/cypress/e2e/offline/01-offline_basic.cy.js index dc69b8a96..2f0e20fc1 100644 --- a/test/automated/browser/cypress/e2e/offline/01_offline_basic.cy.js +++ b/test/automated/browser/cypress/e2e/offline/01-offline_basic.cy.js @@ -6,13 +6,6 @@ describe(`Basic tests`, () => { cy.visit('http://localhost:8080/'); }); - // Offline banner - it('Has correct offline banner values', () => { - cy.contains( - '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 it('Has correct tags visible', () => { cy.contains('#owncast').should('exist'); @@ -31,10 +24,6 @@ describe(`Basic tests`, () => { // cy.get('.ant-modal-close').click(); // }); - it('Can change to Followers tab', () => { - cy.contains('Followers').click(); - }); - // Verify content header values it('Has correct content header values', () => { cy.get('.header-title').should('have.text', 'New Owncast Server'); diff --git a/test/automated/browser/cypress/e2e/offline/02_offline_video_embed.cy.js b/test/automated/browser/cypress/e2e/offline/02-offline_video_embed.cy.js similarity index 100% rename from test/automated/browser/cypress/e2e/offline/02_offline_video_embed.cy.js rename to test/automated/browser/cypress/e2e/offline/02-offline_video_embed.cy.js diff --git a/test/automated/browser/cypress/e2e/offline/03_offline_readwrite_chat_embed.cy.js b/test/automated/browser/cypress/e2e/offline/03-offline_readwrite_chat_embed.cy.js similarity index 100% rename from test/automated/browser/cypress/e2e/offline/03_offline_readwrite_chat_embed.cy.js rename to test/automated/browser/cypress/e2e/offline/03-offline_readwrite_chat_embed.cy.js diff --git a/test/automated/browser/cypress/e2e/offline/04_offline_readonly_chat_embed.cy.js b/test/automated/browser/cypress/e2e/offline/04-offline_readonly_chat_embed.cy.js similarity index 100% rename from test/automated/browser/cypress/e2e/offline/04_offline_readonly_chat_embed.cy.js rename to test/automated/browser/cypress/e2e/offline/04-offline_readonly_chat_embed.cy.js diff --git a/test/automated/browser/cypress/e2e/offline/05_offline_identifier_check.cy.js b/test/automated/browser/cypress/e2e/offline/05-offline_identifier_check.cy.js similarity index 83% rename from test/automated/browser/cypress/e2e/offline/05_offline_identifier_check.cy.js rename to test/automated/browser/cypress/e2e/offline/05-offline_identifier_check.cy.js index e1987ec1b..ad2a86e87 100644 --- a/test/automated/browser/cypress/e2e/offline/05_offline_identifier_check.cy.js +++ b/test/automated/browser/cypress/e2e/offline/05-offline_identifier_check.cy.js @@ -15,7 +15,6 @@ const identifiers = [ '#offline-banner', // The entire offline banner component '#custom-page-content', // The entire custom page content component '#notify-button', // The notify button - '#follow-button', // The follow button ]; filterTests(['desktop'], () => { @@ -31,13 +30,6 @@ filterTests(['desktop'], () => { }); }); - // Followers - const followersCollection = '#followers-collection'; - it(`Has identifier: ${followersCollection}`, () => { - cy.contains('Followers').click(); - cy.get(followersCollection).should('be.visible'); - }); - // Modal const modalContainer = '#modal-container'; it(`Has identifier ${modalContainer}`, () => { diff --git a/test/automated/browser/cypress/e2e/offline/06_offline_mobile.cy.js b/test/automated/browser/cypress/e2e/offline/06-offline_mobile.cy.js similarity index 85% rename from test/automated/browser/cypress/e2e/offline/06_offline_mobile.cy.js rename to test/automated/browser/cypress/e2e/offline/06-offline_mobile.cy.js index 6ef309b81..6859251e9 100644 --- a/test/automated/browser/cypress/e2e/offline/06_offline_mobile.cy.js +++ b/test/automated/browser/cypress/e2e/offline/06-offline_mobile.cy.js @@ -1,5 +1,5 @@ import { setup } from '../../support/setup.js'; -import filterTests from '../../support/filterTests'; +import filterTests from '../../support/filterTests.js'; setup(); diff --git a/test/automated/browser/cypress/e2e/offline/07-offline_enabled_fediverse.cy.js b/test/automated/browser/cypress/e2e/offline/07-offline_enabled_fediverse.cy.js new file mode 100644 index 000000000..4c310aeb3 --- /dev/null +++ b/test/automated/browser/cypress/e2e/offline/07-offline_enabled_fediverse.cy.js @@ -0,0 +1,44 @@ +// TODO: Fire API call to enable federation and set domain, and stream username. + +import fetchData from '../../support/fetchData.js'; + +describe('Fediverse tests', () => { + // Enable Fediverse features. + before(() => { + fetchData('http://localhost:8080/api/admin/config/serverurl', { + method: 'POST', + data: { value: 'https://testing.biz' }, + }); + fetchData('http://localhost:8080/api/admin/config/federation/enable', { + method: 'POST', + data: { value: true }, + }); + }); + + it('Can visit the page', () => { + cy.visit('http://localhost:8080/'); + cy.reload(true); + }); + + // Offline banner + it('Has correct offline banner values', () => { + cy.contains( + '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'); + }); + + // Followers + const followersCollection = '#followers-collection'; + it(`Has identifier: ${followersCollection}`, () => { + cy.contains('Followers').click(); + cy.get(followersCollection).should('be.visible'); + }); + + it(`Has identifier: #follow-button`, () => { + cy.get('#follow-button').should('exist'); + }); + + it('Can change to Followers tab', () => { + cy.contains('Followers').click(); + }); +}); diff --git a/test/automated/browser/cypress/support/e2e.js b/test/automated/browser/cypress/support/e2e.js index bbad3483f..1b47aa493 100644 --- a/test/automated/browser/cypress/support/e2e.js +++ b/test/automated/browser/cypress/support/e2e.js @@ -20,16 +20,10 @@ 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 }, +before(() => { + // Set server URL + fetchData('http://localhost:8080/api/admin/config/serverurl', { + method: 'POST', + data: { value: 'https://testing.biz' }, + }); });