From f2ea1d0e136756ca01f89d6911c0d765005cae5b Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 1 Apr 2021 23:56:37 +0100 Subject: [PATCH] Fixed up some more tests --- .../card/discover-card.component.html | 2 +- .../card/discover-card.component.ts | 19 ++--- .../src/app/my-nav/my-nav.component.html | 4 +- .../integration/page-objects/shared/NavBar.ts | 4 + .../tests/api/v1/tv-request.api.spec.ts | 85 +++++++++++++++++++ .../tests/navigation/navigation-bar.spec.ts | 2 + 6 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 tests/cypress/tests/api/v1/tv-request.api.spec.ts diff --git a/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.html b/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.html index 1dcf4824c..651634a0c 100644 --- a/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.html +++ b/src/Ombi/ClientApp/src/app/discover/components/card/discover-card.component.html @@ -21,7 +21,7 @@
-
diff --git a/tests/cypress/integration/page-objects/shared/NavBar.ts b/tests/cypress/integration/page-objects/shared/NavBar.ts index 8ca5e70db..fb55aca92 100644 --- a/tests/cypress/integration/page-objects/shared/NavBar.ts +++ b/tests/cypress/integration/page-objects/shared/NavBar.ts @@ -72,6 +72,10 @@ class NavBar { return cy.getByData('profile-image'); } + get username(): Cypress.Chainable { + return cy.getByData('profile-username'); + } + get logout(): Cypress.Chainable { return cy.get('#nav-logout'); } diff --git a/tests/cypress/tests/api/v1/tv-request.api.spec.ts b/tests/cypress/tests/api/v1/tv-request.api.spec.ts new file mode 100644 index 000000000..526fc40dd --- /dev/null +++ b/tests/cypress/tests/api/v1/tv-request.api.spec.ts @@ -0,0 +1,85 @@ +describe("TV Request V1 API tests", () => { + beforeEach(() => { + cy.login(); + }); + + it("Request All of TV Show (Fear the Walking Dead)", () => { + const request = { + TvDbId: 290853, + RequestAll: true, + }; + + cy.api({ + url: "/api/v1/request/tv", + body: JSON.stringify(request), + method: "POST", + headers: { + Authorization: "Bearer " + window.localStorage.getItem("id_token"), + "Content-Type": "application/json", + }, + }).then((res) => { + expect(res.status).equal(200); + const body = res.body; + expect(body.result).to.be.true; + expect(body.requestId).not.to.be.null; + expect(body.isError).to.be.false; + expect(body.errorMessage).to.be.null; + }); + }); + + it("Request First Season of TV Show (American Horror Story)", () => { + const request = { + TvDbId: 250487, + FirstSeason: true, + }; + + cy.api({ + url: "/api/v1/request/tv", + body: JSON.stringify(request), + method: "POST", + headers: { + Authorization: "Bearer " + window.localStorage.getItem("id_token"), + "Content-Type": "application/json", + }, + }).then((res) => { + expect(res.status).equal(200); + const body = res.body; + expect(body.result).to.be.true; + expect(body.requestId).not.to.be.null; + expect(body.isError).to.be.false; + expect(body.errorMessage).to.be.null; + }); + }); + + it("Request Two Episode of First Season TV Show (The Sopranos)", () => { + const request = { + TvDbId: 75299, + Seasons: [ + { + SeasonNumber: 1, + Episodes: [ + { EpisodeNumber: 1 }, + { EpisodeNumber: 2 }, + ], + }, + ], + }; + + cy.api({ + url: "/api/v1/request/tv", + body: JSON.stringify(request), + method: "POST", + headers: { + Authorization: "Bearer " + window.localStorage.getItem("id_token"), + "Content-Type": "application/json", + }, + }).then((res) => { + expect(res.status).equal(200); + const body = res.body; + expect(body.result).to.be.true; + expect(body.requestId).not.to.be.null; + expect(body.isError).to.be.false; + expect(body.errorMessage).to.be.null; + }); + }); +}); diff --git a/tests/cypress/tests/navigation/navigation-bar.spec.ts b/tests/cypress/tests/navigation/navigation-bar.spec.ts index 01e8d29e4..b633f6db4 100644 --- a/tests/cypress/tests/navigation/navigation-bar.spec.ts +++ b/tests/cypress/tests/navigation/navigation-bar.spec.ts @@ -11,6 +11,7 @@ describe("Navigation Bar Tests", () => { Page.navbar.requests.should("be.visible"); Page.navbar.discover.should("be.visible"); Page.navbar.userPreferences.should("be.visible"); + Page.navbar.username.contains("a"); Page.navbar.logout.should("be.visible"); }); @@ -34,6 +35,7 @@ describe("Navigation Bar Tests", () => { Page.navbar.requests.should("be.visible"); Page.navbar.discover.should("be.visible"); Page.navbar.userPreferences.should("be.visible"); + Page.navbar.username.contains(id); Page.navbar.logout.should("be.visible"); }); });