From 3c37a21ab306972cc4ae934ed61354e4288f4c67 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sat, 20 Mar 2021 00:29:34 +0000 Subject: [PATCH] more automation --- .../movie/movie-details.component.html | 30 ++-- .../movie/movie-details.component.ts | 6 +- .../movie-information-panel.component.html | 5 + .../deny-dialog/deny-dialog.component.html | 6 +- .../deny-dialog/deny-dialog.component.ts | 6 +- src/Ombi/wwwroot/translations/en.json | 1 + .../details/movies/moviedetails.page.ts | 91 +++++++++++ .../page-objects/details/tv/tvdetails.page.ts | 10 +- .../cypress/integration/page-objects/index.ts | 1 + .../movie/moviedetials-buttons.spec.ts | 149 ++++++++++++++++++ 10 files changed, 274 insertions(+), 31 deletions(-) create mode 100644 tests/cypress/integration/page-objects/details/movies/moviedetails.page.ts create mode 100644 tests/cypress/tests/details/movie/moviedetials-buttons.spec.ts diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index f41884170..92eb37af4 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -42,31 +42,31 @@
- - {{'Search.ViewOnPlex' | translate}} + + {{'Search.ViewOnPlex' | translate}} - - {{'Search.ViewOnEmby' | translate}} + + {{'Search.ViewOnEmby' | translate}} - - {{'Search.ViewOnJellyfin' | translate}} + + {{'Search.ViewOnJellyfin' | translate}} - - - - - - - -
diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts index 97cc75802..b493edae1 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts @@ -107,10 +107,8 @@ export class MovieDetailsComponent { }); dialogRef.afterClosed().subscribe(result => { - this.movieRequest.denied = result; - if (this.movieRequest.denied) { - this.movie.approved = false; - } + this.movieRequest.denied = result.denied; + this.movieRequest.deniedReason = result.reason; }); } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html index eb7f538c0..7af4dd802 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html @@ -53,6 +53,11 @@ {{request.requestedDate | date}}
+
+ {{'Requests.DeniedReason' | translate }}: + {{request.deniedReason}} +
+
{{'MediaDetails.Quality' | translate }}: diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.html b/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.html index 6235d5fe6..654f3a4a5 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.html @@ -1,10 +1,10 @@

{{ 'Requests.DenyReason' | translate}}

- +
- - + +
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.ts index 8ead47144..4e6257b3f 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/shared/deny-dialog/deny-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, Output, EventEmitter } from "@angular/core"; +import { Component, Inject } from "@angular/core"; import { IDenyDialogData } from "../interfaces/interfaces"; import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; import { RequestService, MessageService } from "../../../../services"; @@ -36,8 +36,8 @@ export class DenyDialogComponent { this.messageService.send(result.errorMessage, "Ok"); this.data.denied = false; } - - this.dialogRef.close(); + + this.dialogRef.close({denied: this.data.denied, reason: this.denyReason}); } onNoClick(): void { diff --git a/src/Ombi/wwwroot/translations/en.json b/src/Ombi/wwwroot/translations/en.json index d5c66828f..1f44a9eec 100644 --- a/src/Ombi/wwwroot/translations/en.json +++ b/src/Ombi/wwwroot/translations/en.json @@ -147,6 +147,7 @@ "Remove": "Remove", "Deny": "Deny", "DenyReason": "Deny Reason", + "DeniedReason": "Denied Reason", "Season": "Season", "GridTitle": "Title", "AirDate": "AirDate", diff --git a/tests/cypress/integration/page-objects/details/movies/moviedetails.page.ts b/tests/cypress/integration/page-objects/details/movies/moviedetails.page.ts new file mode 100644 index 000000000..d22d1b7ac --- /dev/null +++ b/tests/cypress/integration/page-objects/details/movies/moviedetails.page.ts @@ -0,0 +1,91 @@ +import { BasePage } from "../../base.page"; + +class MovieInformationPanel { + + get denyReason(): Cypress.Chainable { + return cy.get('#deniedReasonInfo'); + } +} + +class DenyModal { + + get denyReason(): Cypress.Chainable { + return cy.get('#denyInput'); + } + + get denyButton(): Cypress.Chainable { + return cy.get('#denyButton'); + } +} + +class MovieDetailsPage extends BasePage { + + get title(): Cypress.Chainable { + return cy.get('#mediaTitle'); + } + + get availableButton(): Cypress.Chainable { + return cy.get('#availableBtn'); + } + + get requestButton(): Cypress.Chainable { + return cy.get('#requestBtn'); + } + + get requestedButton(): Cypress.Chainable { + return cy.get('#requestedBtn'); + } + + get approveButton(): Cypress.Chainable { + return cy.get('#approveBtn'); + } + + get markAvailableButton(): Cypress.Chainable { + return cy.get('#markAvailableBtn'); + } + + get denyButton(): Cypress.Chainable { + return cy.get('#denyBtn'); + } + + get deniedButton(): Cypress.Chainable { + return cy.get('#deniedButton'); + } + + get reportIssueButton(): Cypress.Chainable { + return cy.get('#reportIssueBtn'); + } + + get viewCollectionButton(): Cypress.Chainable { + return cy.get('#viewCollectionBtn'); + } + + get viewOnPlexButton(): Cypress.Chainable { + return cy.get('#viewOnPlexButton'); + } + + get viewOnEmbyButton(): Cypress.Chainable { + return cy.get('#viewOnEmbyButton'); + } + + get viewOnJellyfinButton(): Cypress.Chainable { + return cy.get('#viewOnJellyfinButton'); + } + + denyModal = new DenyModal(); + informationPanel = new MovieInformationPanel(); + + constructor() { + super(); + } + + visit(options: Cypress.VisitOptions): Cypress.Chainable; + visit(): Cypress.Chainable; + visit(id: string): Cypress.Chainable; + visit(id: string, options: Cypress.VisitOptions): Cypress.Chainable; + visit(id?: any, options?: any) { + return cy.visit(`/details/movie/` + id, options); + } +} + +export const movieDetailsPage = new MovieDetailsPage(); diff --git a/tests/cypress/integration/page-objects/details/tv/tvdetails.page.ts b/tests/cypress/integration/page-objects/details/tv/tvdetails.page.ts index b75e7fb45..4d81051bb 100644 --- a/tests/cypress/integration/page-objects/details/tv/tvdetails.page.ts +++ b/tests/cypress/integration/page-objects/details/tv/tvdetails.page.ts @@ -1,10 +1,5 @@ import { BasePage } from "../../base.page"; -class BaseMediaPage extends BasePage { - get title(): Cypress.Chainable { - return cy.get('#mediaTitle'); - } -} class TvRequestPanel { seasonTab(seasonNumber: number): Cypress.Chainable { @@ -61,8 +56,11 @@ class TvDetailsInformationPanel { } } -class TvDetailsPage extends BaseMediaPage { +class TvDetailsPage extends BasePage { + get title(): Cypress.Chainable { + return cy.get('#mediaTitle'); + } get availableButton(): Cypress.Chainable { return cy.get('#availableBtn'); diff --git a/tests/cypress/integration/page-objects/index.ts b/tests/cypress/integration/page-objects/index.ts index 79ba6635b..b0137c682 100644 --- a/tests/cypress/integration/page-objects/index.ts +++ b/tests/cypress/integration/page-objects/index.ts @@ -5,3 +5,4 @@ export * from './details/tv/tvdetails.page'; export * from './search/search.page'; export * from './user-preferences/user-preferences.page'; export * from './requests/requests.page'; +export * from './details/movies/moviedetails.page'; diff --git a/tests/cypress/tests/details/movie/moviedetials-buttons.spec.ts b/tests/cypress/tests/details/movie/moviedetials-buttons.spec.ts new file mode 100644 index 000000000..62a03e774 --- /dev/null +++ b/tests/cypress/tests/details/movie/moviedetials-buttons.spec.ts @@ -0,0 +1,149 @@ +import { movieDetailsPage as Page } from "@/integration/page-objects"; + +describe("Movie Details Buttons", () => { + it("Movie Requested by Admin should be auto approved", () => { + cy.login(); + + Page.visit("587807"); + Page.requestButton.click(); + cy.verifyNotification("Tom & Jerry (2021) has been successfully added"); + + Page.requestedButton.should("be.visible"); + }); + + it("Movie Requested by Regular user should be pending", () => { + cy.generateUniqueId().then((id) => { + cy.login(); + const roles = []; + roles.push({ value: "RequestMovie", enabled: true }); + cy.createUser(id, "a", roles).then(() => { + cy.loginWithCreds(id, "a"); + + Page.visit("651571"); + + Page.requestButton.click(); + cy.verifyNotification("Breach (2020) has been successfully added"); + + Page.requestedButton.should("be.visible"); + }); + }); + }); + + it("Movie Requested by Regular with no movie permission", () => { + cy.generateUniqueId().then((id) => { + cy.login(); + const roles = []; + roles.push({ value: "RequestTv", enabled: true }); + cy.createUser(id, "a", roles).then(() => { + cy.loginWithCreds(id, "a"); + + Page.visit("791373"); + + Page.requestButton.click(); + cy.verifyNotification("You do not have permissions to Request a Movie"); + + Page.requestedButton.should("not.exist"); + }); + }); + }); + + it("Movie Requested by Regular can be approved by admin", () => { + cy.generateUniqueId().then((id) => { + cy.login(); + const roles = []; + roles.push({ value: "RequestMovie", enabled: true }); + cy.createUser(id, "a", roles).then(() => { + cy.loginWithCreds(id, "a"); + + Page.visit("793723"); + + Page.requestButton.click(); + cy.verifyNotification("Sentinelle (2021) has been successfully added"); + + Page.requestedButton.should("be.visible"); + + // Login as admin now + cy.removeLogin(); + cy.login(); + cy.reload(); + + Page.visit("793723"); + + Page.approveButton.should("exist"); + Page.approveButton.click(); + + cy.verifyNotification("Successfully Approved"); + }); + }); + }); + + it("Movie Requested, mark as available", () => { + cy.login(); + + Page.visit("399566"); + + Page.requestButton.click(); + cy.verifyNotification( + "Godzilla vs. Kong (2021) has been successfully added" + ); + + cy.reload(); + + Page.markAvailableButton.should("exist"); + Page.markAvailableButton.click(); + + cy.verifyNotification("Request is now available"); + Page.availableButton.should("exist"); + }); + + it("Movie Requested, Deny Movie", () => { + cy.login(); + + Page.visit("484718"); + + Page.requestButton.click(); + cy.verifyNotification( + "Coming 2 America (2021) has been successfully added" + ); + + cy.reload(); + + Page.denyButton.should("exist"); + Page.denyButton.click(); + + Page.denyModal.denyReason.type("Automation Tests"); + Page.denyModal.denyButton.click(); + + Page.deniedButton.should('exist'); + + cy.verifyNotification("Denied Request"); + + Page.informationPanel.denyReason.should('have.text', "Automation Tests"); + }); + + it("Movie View Collection should be available", () => { + cy.login(); + + Page.visit("671"); + + Page.viewCollectionButton.should('be.visible'); + }); + + it.only("Non requested movie valid buttons", () => { + cy.login(); + + Page.visit("590706"); + + Page.viewCollectionButton.should('not.exist'); + Page.approveButton.should('not.exist'); + Page.denyButton.should('not.exist'); + Page.deniedButton.should('not.exist'); + Page.markAvailableButton.should('not.exist'); + Page.viewOnEmbyButton.should('not.exist'); + Page.viewOnJellyfinButton.should('not.exist'); + Page.viewOnPlexButton.should('not.exist'); + Page.requestedButton.should('not.exist'); + Page.reportIssueButton.should('not.exist'); // Issuess not enabled + Page.requestButton.should('exist'); + }); +});