Some small fixes, and more automation tests to cover the breaking scenario from earlier

pull/4113/head v4.0.1262
tidusjar 4 years ago
parent cb3916f773
commit 9109350f2e

@ -292,7 +292,7 @@ export class CarouselListComponent implements OnInit {
const tempResults = <IDiscoverCardResult[]>[];
this.tvShows.forEach(m => {
tempResults.push({
available: m.available,
available: m.fullyAvailable,
posterPath: m.backdropPath ? `https://image.tmdb.org/t/p/w500/${m.backdropPath}` : "../../../images/default_tv_poster.png",
requested: m.requested,
title: m.title,

@ -2,7 +2,7 @@
<div class="rating medium-font">
<span *ngIf="movie.voteAverage"
matTooltip="{{'MediaDetails.Votes' | translate }} {{movie.voteCount | thousandShort: 1}}">
<img class="rating-small" src="{{baseUrl}}images/tmdb-logo.svg"> {{movie.voteAverage | number:'1.0-1'}}/10
<img class="rating-small" src="{{baseUrl}}/images/tmdb-logo.svg"> {{movie.voteAverage | number:'1.0-1'}}/10
</span>
<span *ngIf="ratings?.critics_rating && ratings?.critics_score">
<img class="rating-small"

@ -4,12 +4,12 @@
</div>
<div *ngIf="requestable" class="row">
<div class="col-12 action-buttons-right">
<button (click)="requestAllSeasons()" color="primary" mat-raised-button class="btn-spacing"
<button id="episodeModalAllSeasons" (click)="requestAllSeasons()" color="primary" mat-raised-button class="btn-spacing"
matTooltip="{{'MediaDetails.EpisodeSelector.AllSeasonsTooltip' | translate}}">{{'Search.TvShows.AllSeasons' | translate }}</button>
<button (click)="requestFirstSeason()" color="accent" mat-raised-button class="btn-spacing"
<button id="episodeModalFirstSeason" (click)="requestFirstSeason()" color="accent" mat-raised-button class="btn-spacing"
matTooltip="{{'MediaDetails.EpisodeSelector.FirstSeasonTooltip' | translate}}">{{ 'Search.TvShows.FirstSeason' | translate }}</button>
<button (click)="requestLatestSeason()" color="warn" mat-raised-button class="btn-spacing"
<button id="episodeModalLatestSeason" (click)="requestLatestSeason()" color="warn" mat-raised-button class="btn-spacing"
matTooltip="{{'MediaDetails.EpisodeSelector.LatestSeasonTooltip' | translate}}">{{ 'Search.TvShows.LatestSeason' | translate }}</button>
</div>
</div>

@ -1,7 +1,10 @@
import { EpisodeRequestModal } from "./EpisodeRequestModal";
export class DiscoverCard {
private id: string;
private movie: boolean;
episodeRequestModal = new EpisodeRequestModal();
constructor(id: string, movie: boolean) {
this.id = id;
this.movie = movie;

@ -0,0 +1,13 @@
export class EpisodeRequestModal {
get allSeasonsButton(): Cypress.Chainable<any> {
return cy.get(`#episodeModalAllSeasons`);
}
get firstSeasonButton(): Cypress.Chainable<any> {
return cy.get(`#episodeModalFirstSeason`);
}
get latestSeasonButton(): Cypress.Chainable<any> {
return cy.get(`#episodeModalLatestSeason`);
}
}

@ -0,0 +1,208 @@
import { discoverPage as Page } from "@/integration/page-objects";
describe("Discover Cards Requests Tests", () => {
beforeEach(() => {
cy.login();
});
it("Not requested movie allows us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[0];
movie.available = false;
movie.approved = false;
movie.requested = false;
body[0] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[0].id;
var title = body[0].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.requestButton.should("exist");
// Not visible until hover
card.requestButton.should("not.be.visible");
cy.wait(500)
card.topLevelCard.realHover();
card.requestButton.should("be.visible");
card.requestButton.click();
cy.verifyNotification("has been successfully added!");
card.requestButton.should("not.be.visible");
card.availabilityText.should('have.text','Pending');
card.statusClass.should('have.class','requested');
});
});
it("Available movie does not allow us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[1];
movie.available = true;
movie.approved = false;
movie.requested = false;
body[1] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Available');
card.statusClass.should('have.class','available');
});
});
it("Requested movie does not allow us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[1];
movie.available = false;
movie.approved = false;
movie.requested = true;
body[1] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Pending');
card.statusClass.should('have.class','requested');
});
});
it("Approved movie does not allow us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[1];
movie.available = false;
movie.approved = true;
movie.requested = true;
body[1] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Approved');
card.statusClass.should('have.class','approved');
});
});
it("Available TV does not allow us to request", () => {
cy.intercept("GET", "**/search/Tv/popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const tv = body[1];
tv.fullyAvailable = true;
body[1] = tv;
res.send(body);
});
}).as("cardsResponse");
window.localStorage.setItem("DiscoverOptions2", "3");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Available');
card.statusClass.should('have.class','available');
});
});
it.only("Not available TV does not allow us to request", () => {
cy.intercept("GET", "**/search/Tv/popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const tv = body[3];
tv.fullyAvailable = false;
body[3] = tv;
res.send(body);
});
}).as("cardsResponse");
window.localStorage.setItem("DiscoverOptions2", "3");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[3].id;
var title = body[3].title;
const card = Page.popularCarousel.getCard(expectedId, false);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("be.visible");
card.requestButton.click();
const modal = card.episodeRequestModal;
modal.latestSeasonButton.click();
cy.verifyNotification("has been added successfully")
});
});
});

@ -64,142 +64,4 @@ describe("Discover Cards Tests", () => {
cy.wait("@moviePopular");
cy.wait("@tvPopular");
});
it("Not requested movie allows us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[0];
movie.available = false;
movie.approved = false;
movie.requested = false;
body[0] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[0].id;
var title = body[0].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.requestButton.should("exist");
// Not visible until hover
card.requestButton.should("not.be.visible");
cy.wait(500)
card.topLevelCard.realHover();
card.requestButton.should("be.visible");
card.requestButton.click();
cy.verifyNotification("has been successfully added!");
card.requestButton.should("not.be.visible");
card.availabilityText.should('have.text','Pending');
card.statusClass.should('have.class','requested');
});
});
it("Available movie does not allow us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[1];
movie.available = true;
movie.approved = false;
movie.requested = false;
body[1] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Available');
card.statusClass.should('have.class','available');
});
});
it("Requested movie does not allow us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[1];
movie.available = false;
movie.approved = false;
movie.requested = true;
body[1] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Pending');
card.statusClass.should('have.class','requested');
});
it("Approved movie does not allow us to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[1];
movie.available = false;
movie.approved = true;
movie.requested = true;
body[1] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.be.visible");
card.availabilityText.should('have.text','Approved');
card.statusClass.should('have.class','approved');
});
});
});
});

@ -8,14 +8,14 @@ describe("Search Tests", () => {
it("Single result when TV Search Only", () => {
Page.navbar.searchFilter.applyFilter(true, false, false);
Page.visit("Game Of Thrones");
Page.visit("Dexters Laboratory");
cy.wait('@searchResponse');
const card = Page.getCard('1399', false);
const card = Page.getCard('4229', false);
card.topLevelCard.realHover();
card.title.should('have.text', 'Game of Thrones');
card.overview.contains('noble');
card.title.should('have.text', "Dexter's Laboratory");
card.overview.contains('Cartoon Network');
card.requestType.contains('Tv Show');
card.requestButton.should('exist');
});

Loading…
Cancel
Save