diff --git a/src/Ombi/ClientApp/src/app/interfaces/IRequestModel.ts b/src/Ombi/ClientApp/src/app/interfaces/IRequestModel.ts index 1ee92f336..1499c8b88 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/IRequestModel.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/IRequestModel.ts @@ -161,6 +161,7 @@ export interface IEpisodesRequests { available: boolean; requested: boolean; approved: boolean; + requestStatus: string; selected: boolean; // This is for the UI only } 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 d6dbc9cab..00ed3c385 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 @@ -3,7 +3,7 @@ -
+
{{ 'Requests.Season' | translate }} {{season.seasonNumber}}
@@ -12,13 +12,13 @@ - - @@ -43,7 +43,7 @@ {{ 'Requests.GridStatus' | translate }} -
+
{{ep.requestStatus | translate}}
@@ -71,11 +71,11 @@ add - + - + - + - + \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts index b6b57f1dd..fbeeccb3b 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-request-grid/tv-request-grid.component.ts @@ -50,6 +50,7 @@ export class TvRequestGridComponent { season.episodes.forEach(ep => { if (this.selection.isSelected(ep)) { ep.requested = true; + ep.requestStatus = "Common.PendingApproval"; seasonsViewModel.episodes.push({ episodeNumber: ep.episodeNumber }); } }); @@ -65,6 +66,27 @@ export class TvRequestGridComponent { this.selection.clear(); + if (this.tv.firstSeason) { + this.tv.seasonRequests[0].episodes.forEach(ep => { + ep.requested = true; + ep.requestStatus = "Common.PendingApproval"; + }); + } + if (this.tv.requestAll) { + this.tv.seasonRequests.forEach(season => { + season.episodes.forEach(ep => { + ep.requested = true; + ep.requestStatus = "Common.PendingApproval"; + }); + }); + } + if (this.requestLatestSeason) { + this.tv.seasonRequests[this.tv.seasonRequests.length - 1].episodes.forEach(ep => { + ep.requested = true; + ep.requestStatus = "Common.PendingApproval"; + }); + } + } else { this.notificationService.send(requestResult.errorMessage ? requestResult.errorMessage : requestResult.message); } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html index c8588b1c7..d4974c1ef 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.html @@ -70,6 +70,7 @@ +
diff --git a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts index 201d4c274..c7b0711b6 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/tv/panels/tv-requests/tv-requests-panel.component.ts @@ -40,6 +40,15 @@ export class TvRequestsPanelComponent { } } + public async delete(request: IChildRequests) { + const result = await this.requestService.deleteChild(request.id).toPromise(); + + if (result) { + this.tvRequest.splice(this.tvRequest.indexOf(request),1); + this.messageService.send("Request has been Deleted", "Ok"); + } + } + public changeAvailability(request: IChildRequests, available: boolean) { request.available = available; request.seasonRequests.forEach((season) => { 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 f869b31a2..44ab21b3f 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 @@ -105,7 +105,7 @@
- +
diff --git a/tests/cypress/config/regression.json b/tests/cypress/config/regression.json index 92c1b4045..d5ed9941c 100644 --- a/tests/cypress/config/regression.json +++ b/tests/cypress/config/regression.json @@ -1,6 +1,7 @@ { "$schema": "https://on.cypress.io/cypress.schema.json", "supportFile": "cypress/support/index.ts", + "baseUrl": "http://localhost:3577", "integrationFolder": "cypress/tests", "testFiles": "**/*.spec.ts*", "retries": { @@ -8,10 +9,11 @@ "openMode": 1 }, "watchForFileChanges": true, + "projectId": "o5451s", + "viewportWidth": 2560, + "viewportHeight": 1440, "chromeWebSecurity": false, "ignoreTestFiles": ["**/snapshots/*"], - "screenshotOnRunFailure": false, - "video": false, "reporter": "junit", "reporterOptions": { "mochaFile": "results/junit/regression-[hash].xml" diff --git a/tests/cypress/support/commands.ts b/tests/cypress/support/commands.ts index bc0a77df4..7b6151d6f 100644 --- a/tests/cypress/support/commands.ts +++ b/tests/cypress/support/commands.ts @@ -32,7 +32,6 @@ Cypress.Commands.add("landingSettings", (enabled) => { }) Cypress.Commands.add('login', (username, password) => { - cy.clearLocalStorage(); cy.request({ method: 'POST', url: '/api/v1/token', @@ -88,4 +87,16 @@ Cypress.Commands.add('generateUniqueId', () => { const uniqueSeed = Date.now().toString(); const id = Cypress._.uniqueId(uniqueSeed); return id; -}); \ No newline at end of file +}); + +Cypress.Commands.add("getByData", (selector, ...args) => { + return cy.get(`[data-test=${selector}]`, ...args); + }); + +Cypress.Commands.add("getByData", (selector) => { + return cy.get(`[data-test=${selector}]`); + }); + + Cypress.Commands.add("getByDataLike", (selector) => { + return cy.get(`[data-test*=${selector}]`); + }); \ No newline at end of file diff --git a/tests/cypress/tests/details/tv/tvdetails-requests-grid.spec.ts b/tests/cypress/tests/details/tv/tvdetails-requests-grid.spec.ts new file mode 100644 index 000000000..1cd7a97b5 --- /dev/null +++ b/tests/cypress/tests/details/tv/tvdetails-requests-grid.spec.ts @@ -0,0 +1,169 @@ +describe("TV Requests Grid", function () { + beforeEach(() => { + cy.login(); + }); + + it("Season not available", () => { + cy.visit("/details/tv/121361"); + + cy.getByData("classStatus1").should("not.have.class", "available"); + cy.getByData("classStatus1").should("not.have.class", "requested"); + cy.getByData("classStatus1").should("not.have.class", "approved"); + + cy.getByData("masterCheckbox1").should("be.visible"); + cy.getByDataLike("episodeCheckbox1").each((element) => { + expect(element.length).to.be.greaterThan(0); + }); + }); + + it("Season is requested", () => { + cy.intercept("GET", "**/v2/search/Tv/121361", (req) => { + req.reply((res) => { + const body = res.body; + const requests = body.seasonRequests[0].episodes; + requests.forEach((req) => { + req.requested = true; + req.approved = false; + req.requestStatus = "Common.PendingApproval"; + }); + body.seasonRequests[0].episodes = requests; + res.send(body); + }); + }).as("detailsResponse"); + + cy.visit("/details/tv/121361"); + + cy.wait("@detailsResponse"); + + cy.getByData("classStatus1").should("not.have.class", "available"); + cy.getByData("classStatus1").should("have.class", "requested"); + cy.getByData("classStatus1").should("not.have.class", "approved"); + + // checkboxes + cy.getByData("masterCheckbox1").should("not.exist"); + cy.getByDataLike("episodeCheckbox1").should("not.exist"); + + cy.getByDataLike("episodeStatus1").each((element) => { + expect(element.hasClass("requested")).to.be.true; + expect(element.text()).contain('Pending Approval'); + }); + }); + + it("Season is approved", () => { + cy.intercept("GET", "**/v2/search/Tv/121361", (req) => { + req.reply((res) => { + const body = res.body; + const requests = body.seasonRequests[0].episodes; + requests.forEach((req) => { + req.approved = true; + req.requested = true; + req.requestStatus = "Common.Approved"; + }); + body.seasonRequests[0].episodes = requests; + res.send(body); + }); + }).as("detailsResponse"); + + cy.visit("/details/tv/121361"); + + cy.wait("@detailsResponse"); + + cy.getByData("classStatus1").should("not.have.class", "available"); + cy.getByData("classStatus1").should("not.have.class", "requested"); + cy.getByData("classStatus1").should("have.class", "approved"); + + // checkboxes + cy.getByData("masterCheckbox1").should("not.exist"); + cy.getByDataLike("episodeCheckbox1").should("not.exist"); + + cy.getByDataLike("episodeStatus1").each((element) => { + expect(element.hasClass("approved")).to.be.true; + expect(element.text()).contain('Approved'); + }); + }); + + it("Season is available", () => { + cy.intercept("GET", "**/v2/search/Tv/121361", (req) => { + req.reply((res) => { + const body = res.body; + const requests = body.seasonRequests[0].episodes; + requests.forEach((req) => { + req.available = true; + req.requestStatus = "Common.Available"; + }); + body.seasonRequests[0].episodes = requests; + res.send(body); + }); + }).as("detailsResponse"); + + cy.visit("/details/tv/121361"); + + cy.wait("@detailsResponse"); + + cy.getByData("classStatus1").should("have.class", "available"); + cy.getByData("classStatus1").should("not.have.class", "requested"); + cy.getByData("classStatus1").should("not.have.class", "approved"); + + // checkboxes + cy.getByData("masterCheckbox1").should("not.exist"); + cy.getByDataLike("episodeCheckbox1").should("not.exist"); + + cy.getByDataLike("episodeStatus1").each((element) => { + expect(element.hasClass("available")).to.be.true; + expect(element.text()).contain('Available'); + }); + }); + + it("Request no episodes", () => { + cy.visit("/details/tv/121361"); + + cy.get('#addFabBtn').click(); + cy.get('#requestSelected').click(); + + cy.verifyNotification('You need to select some episodes!'); + }); + + it("Request single episodes", () => { + cy.visit("/details/tv/121361"); + const episodeCheckbox = 'episodeCheckbox11'; + + cy.getByData(episodeCheckbox).click(); + cy.get('#addFabBtn').click(); + cy.get('#requestSelected').click(); + + cy.verifyNotification('Request for Game of Thrones has been added successfully'); + + cy.getByData('episodeStatus11') + .should('contain.text', 'Pending Approval') + .should('have.class', 'requested') + }); + + + it("Request First Season", () => { + cy.visit("/details/tv/121361"); + + cy.get('#addFabBtn').click(); + cy.get('#requestFirst').click(); + + cy.verifyNotification('Request for Game of Thrones has been added successfully'); + + cy.getByDataLike('episodeStatus1') + .should('contain.text', 'Pending Approval') + .should('have.class', 'requested') + }); + + it.only("Request Latest Season", () => { + cy.visit("/details/tv/121361"); + + cy.get('#addFabBtn').click(); + cy.get('#requestLatest').click(); + + cy.verifyNotification('Request for Game of Thrones has been added successfully'); + + cy.getByData("classStatus8").click(); + cy.getByData("classStatus8").should("have.class", "requested"); + cy.getByDataLike('episodeStatus8') + .should('contain.text', 'Pending Approval') + .should('have.class', 'requested') + }); +}); diff --git a/tests/global.d.ts b/tests/global.d.ts index 4a81b2e86..70a3050e1 100644 --- a/tests/global.d.ts +++ b/tests/global.d.ts @@ -11,6 +11,9 @@ declare namespace Cypress { verifyNotification(text: string): Chainable; createUser(username: string, password: string, claims: any[]): Chainable; generateUniqueId(): Chainable; + getByData(selector: string, args: any[]): Chainable; + getByData(selector: string): Chainable; + getByDataLike(selector: string): Chainable; requestGenericMovie(): Chainable; requestMovie(movieId: number): Chainable; diff --git a/tests/package.json b/tests/package.json index 3a499c121..078b12181 100644 --- a/tests/package.json +++ b/tests/package.json @@ -9,6 +9,10 @@ "main": "index.js", "repository": "https://github.com/ombi-app/ombi.automation", "author": "TidusJar", + "retries": { + "runMode": 2, + "openMode": 1 + }, "scripts": { "cypress:version": "cypress version", "cypress:verify": "cypress verify",