From 7b418673c89f571d57233ceab181d44c463d8509 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sun, 24 Aug 2025 21:52:47 +0100 Subject: [PATCH] fixes --- .../tv-request-grid.component.html | 13 +++ .../components/tv/tv-details.component.html | 23 ++--- .../components/tv/tv-details.component.ts | 52 ------------ tests/cypress.config.ts | 2 + tests/cypress/fixtures/wizard-config.json | 22 +++++ tests/cypress/support/e2e.ts | 3 + tests/cypress/support/setup.ts | 84 +++++++++++++++++++ 7 files changed, 131 insertions(+), 68 deletions(-) create mode 100644 tests/cypress/fixtures/wizard-config.json create mode 100644 tests/cypress/support/setup.ts diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html index eb1283440..5e7327163 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.html @@ -76,3 +76,16 @@ --> + + + + + + + + + + diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html index 7240366ae..9e1fa9565 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.html @@ -192,11 +192,13 @@
- @defer (on viewport; prefetch on idle) { - - } @placeholder { - - } + + +
@@ -229,17 +231,6 @@
- - - - - - - -
diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts index d085ad4c4..fc42f1c4e 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/tv-details.component.ts @@ -13,7 +13,6 @@ import { TvAdvancedOptionsComponent } from "./panels/tv-advanced-options/tv-adva import { RequestServiceV2 } from "../../../services/requestV2.service"; import { forkJoin } from "rxjs"; import { SonarrFacade } from "app/state/sonarr"; -import { ITvRequestViewModelV2 } from "../../../interfaces/ISearchTvResult"; @Component({ standalone: false, @@ -136,57 +135,6 @@ export class TvDetailsComponent implements OnInit { return this.tv.seasonRequests.every(e => e.episodes.every(x => x.available || x.approved || x.requested)); } - // FAB Button methods moved from tv-request-grid component - public requestAllSeasons() { - this.tv.requestAll = true; - this.tv.firstSeason = false; - this.tv.latestSeason = false; - this.submitRequests(); - } - - public requestFirstSeason() { - this.tv.requestAll = false; - this.tv.firstSeason = true; - this.tv.latestSeason = false; - this.submitRequests(); - } - - public requestLatestSeason() { - this.tv.requestAll = false; - this.tv.firstSeason = false; - this.tv.latestSeason = true; - this.submitRequests(); - } - - public async submitRequests() { - // Make sure something has been selected - if (!this.tv.requestAll && !this.tv.firstSeason && !this.tv.latestSeason) { - this.messageService.send('You need to select some episodes!'); - return; - } - - this.tv.requested = true; - - const viewModel = { - firstSeason: this.tv.firstSeason, - latestSeason: this.tv.latestSeason, - requestAll: this.tv.requestAll, - theMovieDbId: this.tv.id, - requestOnBehalf: null, - languageCode: 'en' // Default language, can be enhanced later - }; - viewModel.seasons = []; - - try { - await this.requestService2.requestTv(viewModel).toPromise(); - this.messageService.send(`Request for ${this.tv.title} has been added successfully`); - // Refresh the data - await this.load(); - } catch (error) { - this.messageService.send('Failed to submit request'); - } - } - private checkPoster() { if (this.tv.images.original == null) { this.tv.images.original = "../../../images/default_movie_poster.png"; diff --git a/tests/cypress.config.ts b/tests/cypress.config.ts index c37fac020..7a4b7d862 100644 --- a/tests/cypress.config.ts +++ b/tests/cypress.config.ts @@ -35,6 +35,8 @@ export default defineConfig({ // Project configuration projectId: 'o5451s', + + e2e: { // Setup node events async setupNodeEvents( diff --git a/tests/cypress/fixtures/wizard-config.json b/tests/cypress/fixtures/wizard-config.json new file mode 100644 index 000000000..e4a7127df --- /dev/null +++ b/tests/cypress/fixtures/wizard-config.json @@ -0,0 +1,22 @@ +{ + "database": { + "type": "sqlite", + "connectionString": "Data Source=Ombi.db" + }, + "mediaServer": { + "type": "plex", + "host": "http://localhost:32400", + "token": "test-token" + }, + "user": { + "username": "admin", + "password": "admin123", + "claims": ["Admin"] + }, + "ombiConfig": { + "landingPage": "discover", + "autoApprove": false + } +} + + diff --git a/tests/cypress/support/e2e.ts b/tests/cypress/support/e2e.ts index ad17442eb..1a0474763 100644 --- a/tests/cypress/support/e2e.ts +++ b/tests/cypress/support/e2e.ts @@ -21,5 +21,8 @@ import './mock-data.commands'; import "cypress-real-events/support"; import '@bahmutov/cy-api/support'; +// Import our setup utilities +import './setup'; + // Alternatively you can use CommonJS syntax: // require('./commands') diff --git a/tests/cypress/support/setup.ts b/tests/cypress/support/setup.ts new file mode 100644 index 000000000..0affd1d50 --- /dev/null +++ b/tests/cypress/support/setup.ts @@ -0,0 +1,84 @@ +// Test setup and initialization utilities +import './commands'; + +// Global setup that runs before all tests +beforeEach(() => { + // Check if application is already set up + cy.checkApplicationSetup(); +}); + +// Check if the application is already configured +Cypress.Commands.add('checkApplicationSetup', () => { + cy.log('Checking application setup status...'); + + // Try to access the application to see if it's already configured + cy.request({ + method: 'GET', + url: '/api/v1/status', + failOnStatusCode: false, + timeout: 10000 + }).then((response) => { + if (response.status === 200) { + // Application is running and configured + cy.log('Application is already configured, skipping wizard'); + return; + } + + // Check if we're on the wizard page + cy.visit('/').then(() => { + cy.url().then((url) => { + if (url.includes('/wizard') || url.includes('/setup')) { + cy.log('Wizard detected, running setup...'); + cy.runWizardSetup(); + } else { + cy.log('Application appears to be configured'); + } + }); + }); + }); +}); + +// Run the wizard setup +Cypress.Commands.add('runWizardSetup', () => { + cy.log('Running wizard setup...'); + + // Import wizard page object + cy.fixture('wizard-config').then((config) => { + // Run through wizard steps + cy.get('[data-test="wizard-welcome-next"]').click(); + cy.get('[data-test="wizard-database-next"]').click(); + cy.get('[data-test="wizard-media-server-next"]').click(); + + // Create local user + cy.get('[data-test="wizard-username"]').type(Cypress.env('username')); + cy.get('[data-test="wizard-password"]').type(Cypress.env('password')); + cy.get('[data-test="wizard-user-next"]').click(); + + // Complete configuration + cy.get('[data-test="wizard-config-next"]').click(); + cy.get('[data-test="wizard-finish"]').click(); + + // Wait for setup to complete + cy.url().should('not.include', '/wizard'); + cy.log('Wizard setup completed successfully'); + }); +}); + +// Check if we need to run setup for this test run +Cypress.Commands.add('ensureApplicationSetup', () => { + // This command can be called explicitly in tests that need setup + cy.checkApplicationSetup(); +}); + +// Add to global commands interface +declare global { + namespace Cypress { + interface Chainable { + checkApplicationSetup(): Chainable; + runWizardSetup(): Chainable; + ensureApplicationSetup(): Chainable; + } + } +} + +