Fixed up some tests

This commit is contained in:
tidusjar 2021-03-29 08:30:22 +01:00
commit 4af31f165b
4 changed files with 523 additions and 470 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,51 +1,102 @@
import { movieDetailsPage as Page } from "@/integration/page-objects";
describe("TV Search V1 API tests", () => {
beforeEach(() => {
cy.login();
beforeEach(() => {
cy.login();
});
it("Get Extra TV Info", () => {
cy.api({
url: "/api/v1/search/tv/info/287247",
headers: {
Authorization: "Bearer " + window.localStorage.getItem("id_token"),
},
}).then((res) => {
expect(res.status).equal(200);
const body = res.body;
cy.fixture("api/v1/tv-search-extra-info").then((x) => {
expect(res.body.title).equal(x.title);
expect(res.body.status).equal(x.status);
expect(res.body.id).equal(x.id);
expect(res.body.firstAired).equal(x.firstAired);
expect(res.body.network).equal(x.network);
expect(res.body.seriesId).equal(x.seriesId);
expect(res.body.runtime).equal(x.runtime);
expect(res.body.networkId).equal(x.networkId);
expect(res.body.overview).equal(x.overview);
expect(res.body.seasonRequests.length).equal(x.seasonRequests.length);
expect(res.body.seasonRequests[0].seasonNumber).equal(
x.seasonRequests[0].seasonNumber
);
expect(res.body.seasonRequests[0].episodes.length).equal(
x.seasonRequests[0].episodes.length
);
expect(res.body.seasonRequests[0].episodes[0].episodeNumber).equal(
x.seasonRequests[0].episodes[0].episodeNumber
);
expect(res.body.seasonRequests[0].episodes[0].title).equal(
x.seasonRequests[0].episodes[0].title
);
expect(res.body.seasonRequests[0].episodes[0].airDate).equal(
x.seasonRequests[0].episodes[0].airDate
);
expect(res.body.seasonRequests[0].episodes[0].url).equal(
x.seasonRequests[0].episodes[0].url
);
expect(res.body.seasonRequests[0].episodes[0].available).equal(
x.seasonRequests[0].episodes[0].available
);
expect(res.body.seasonRequests[0].episodes[0].requested).equal(
x.seasonRequests[0].episodes[0].requested
);
expect(res.body.seasonRequests[0].episodes[0].approved).equal(
x.seasonRequests[0].episodes[0].approved
);
expect(res.body.seasonRequests[0].episodes[0].airDateDisplay).equal(
x.seasonRequests[0].episodes[0].airDateDisplay
);
expect(res.body.seasonRequests[0].seasonAvailable).equal(
x.seasonRequests[0].seasonAvailable
);
expect(res.body.id).equal(x.id);
expect(res.body.imdbId).equal(x.imdbId);
expect(res.body.theMovieDbId).equal(x.theMovieDbId);
});
});
});
it("Get Extra TV Info", () => {
cy.api({url: '/api/v1/search/tv/info/287247', headers: { 'Authorization': 'Bearer ' + window.localStorage.getItem('id_token')} })
.then((res) => {
expect(res.status).equal(200);
cy.fixture('api/v1/tv-search-extra-info').then(x => {
expect(res.body).deep.equal(x);
})
});
});
it("TV Basic Search", () => {
cy.api({
url: "/api/v1/search/tv/Shitts Creek",
headers: {
Authorization: "Bearer " + window.localStorage.getItem("id_token"),
},
}).then((res) => {
expect(res.status).equal(200);
const body = res.body;
expect(body[0].title).is.equal("Schitt's Creek");
expect(body[0].status).is.equal("Ended");
expect(body[0].id).is.not.null;
expect(body[0].id).to.be.an("number");
});
});
it("TV Basic Search", () => {
cy.api({url: '/api/v1/search/tv/Shitts Creek', headers: { 'Authorization': 'Bearer ' + window.localStorage.getItem('id_token')} })
.then((res) => {
expect(res.status).equal(200);
const body = res.body;
expect(body[0].title).is.equal("Schitt's Creek")
expect(body[0].status).is.equal("Ended");
expect(body[0].id).is.not.null;
expect(body[0].id).to.be.an('number');
});
});
const types = [
'popular',
'trending',
'anticipated',
'mostwatched'
];
const types = ["popular", "trending", "anticipated", "mostwatched"];
types.forEach((type) => {
// derive test name from data
it(`${type} TV List`, () => {
cy.api({url: '/api/v1/search/tv/'+type, headers: { 'Authorization': 'Bearer ' + window.localStorage.getItem('id_token')} })
.then((res) => {
expect(res.status).equal(200);
const body = res.body;
expect(body.length).is.greaterThan(0);
expect(body[0].title).is.not.null;
expect(body[0].id).is.not.null;
expect(body[0].id).to.be.an('number');
});
// derive test name from data
it(`${type} TV List`, () => {
cy.api({
url: "/api/v1/search/tv/" + type,
headers: {
Authorization: "Bearer " + window.localStorage.getItem("id_token"),
},
}).then((res) => {
expect(res.status).equal(200);
const body = res.body;
expect(body.length).is.greaterThan(0);
expect(body[0].title).is.not.null;
expect(body[0].id).is.not.null;
expect(body[0].id).to.be.an("number");
});
});
});
});
});

View file

@ -127,6 +127,7 @@ describe("Movie Details Buttons", () => {
cy.verifyNotification("Denied Request");
cy.wait(1000);
Page.informationPanel.denyReason.should('have.text', "Automation Tests");
});

View file

@ -227,23 +227,24 @@ describe("Discover Cards Requests Tests", () => {
});
});
it.only("Available TV (From Details Call) does not allow us to request", () => {
cy.intercept("GET", "**/search/Tv/popular/**").as("cardsResponse");
it("Available TV (From Details Call) does not allow us to request", () => {
cy.intercept("GET", "**/search/Tv/popular/**", { fixture: '/discover/popularTv'}).as("cardsResponse");
cy.intercept("GET", "**/search/Tv/moviedb/88396", (req) => {
req.reply((res2) => {
const body = res2.body;
body.fullyAvailable = true;
res2.send(body);
});
}).as("movieDbResponse");
window.localStorage.setItem("DiscoverOptions2", "3");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = res.response.body;
var expectedId = body[1].id;
cy.intercept("GET", "**/search/Tv/moviedb/"+expectedId, (req) => {
req.reply((res2) => {
const body = res2.body;
body.fullyAvailable = true;
res2.send(body);
});
}).as("movieDbResponse");
var title = body[1].title;
var expectedId = "88396";
var title = body[0].title;
cy.wait("@movieDbResponse")