Fixed up tests to be aware of the new dialog

This commit is contained in:
tidusjar 2021-03-25 08:54:35 +00:00
commit 5678f43f41
6 changed files with 168 additions and 38 deletions

View file

@ -1,5 +1,6 @@
import { BasePage } from "../base.page";
import { DiscoverCard } from "../shared/DiscoverCard";
import { AdminRequestDialog } from "../shared/AdminRequestDialog";
import { DiscoverCard, DiscoverType } from "../shared/DiscoverCard";
class CarouselComponent {
private type: string;
@ -16,8 +17,8 @@ class CarouselComponent {
return cy.get(`#${this.type}Tv-button`);
}
getCard(id: string, movie: boolean): DiscoverCard {
return new DiscoverCard(id, movie);
getCard(id: string, movie: boolean, type?: DiscoverType): DiscoverCard {
return new DiscoverCard(id, movie, type);
}
constructor(id: string) {
@ -27,6 +28,7 @@ class CarouselComponent {
class DiscoverPage extends BasePage {
popularCarousel = new CarouselComponent("popular");
adminOptionsDialog = new AdminRequestDialog();
constructor() {
super();

View file

@ -1,13 +1,22 @@
import { EpisodeRequestModal } from "./EpisodeRequestModal";
export enum DiscoverType {
Upcoming,
Trending,
Popular,
RecentlyRequested,
}
export class DiscoverCard {
private id: string;
private movie: boolean;
private type: DiscoverType;
episodeRequestModal = new EpisodeRequestModal();
constructor(id: string, movie: boolean) {
constructor(id: string, movie: boolean, type?: DiscoverType) {
this.id = id;
this.movie = movie;
this.type = type;
}
get topLevelCard(): Cypress.Chainable<any> {
@ -35,7 +44,7 @@ export class DiscoverCard {
}
get requestButton(): Cypress.Chainable<any> {
return cy.get(`#requestButton${this.id}${this.movie ? '1' : '0'}`);
return cy.get(`#requestButton${this.id}${this.movie ? '1' : '0'}${this.type}`);
}
verifyTitle(expected: string): Cypress.Chainable<any> {

View file

@ -1,11 +1,12 @@
import { discoverPage as Page } from "@/integration/page-objects";
import { DiscoverType } from "@/integration/page-objects/shared/DiscoverCard";
describe("Discover Cards Requests Tests", () => {
beforeEach(() => {
cy.login();
});
it("Not requested movie allows us to request", () => {
it("Not requested movie allows admin to request", () => {
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
@ -27,22 +28,76 @@ describe("Discover Cards Requests Tests", () => {
var expectedId = body[0].id;
var title = body[0].title;
const card = Page.popularCarousel.getCard(expectedId, true);
const card = Page.popularCarousel.getCard(expectedId, true, DiscoverType.Popular);
card.verifyTitle(title);
card.requestButton.should("exist");
// Not visible until hover
card.requestButton.should("not.be.visible");
cy.wait(500)
cy.wait(500);
card.topLevelCard.realHover();
card.requestButton.should("be.visible");
card.requestButton.click();
Page.adminOptionsDialog.isOpen();
Page.adminOptionsDialog.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');
card.requestButton.should("not.exist");
card.availabilityText.should("have.text", "Pending");
card.statusClass.should("have.class", "requested");
});
});
it.only("Not requested movie allows non-admin to request", () => {
cy.generateUniqueId().then((id) => {
cy.login();
const roles = [];
roles.push({ value: "RequestMovie", enabled: true });
cy.createUser(id, "a", roles).then(() => {
cy.removeLogin();
cy.loginWithCreds(id, "a");
window.localStorage.setItem("DiscoverOptions2", "2");
cy.intercept("GET", "**/search/Movie/Popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[6];
movie.available = false;
movie.approved = false;
movie.requested = false;
body[6] = movie;
res.send(body);
});
}).as("cardsResponse");
Page.visit();
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[6].id;
var title = body[6].title;
const card = Page.popularCarousel.getCard(expectedId, true, DiscoverType.Popular);
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.exist");
card.availabilityText.should("have.text", "Pending");
card.statusClass.should("have.class", "requested");
});
});
});
});
@ -68,13 +123,13 @@ describe("Discover Cards Requests Tests", () => {
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
const card = Page.popularCarousel.getCard(expectedId, true, DiscoverType.Popular);
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Available');
card.statusClass.should('have.class','available');
card.availabilityText.should("have.text", "Available");
card.statusClass.should("have.class", "available");
});
});
@ -100,14 +155,13 @@ describe("Discover Cards Requests Tests", () => {
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
const card = Page.popularCarousel.getCard(expectedId, true, DiscoverType.Popular);
card.title.realHover();
card.verifyTitle(title);
card.topLevelCard.realHover();
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Pending');
card.statusClass.should('have.class','requested');
card.availabilityText.should("have.text", "Pending");
card.statusClass.should("have.class", "requested");
});
});
@ -133,13 +187,13 @@ describe("Discover Cards Requests Tests", () => {
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
const card = Page.popularCarousel.getCard(expectedId, true, DiscoverType.Popular);
card.title.realHover();
card.verifyTitle(title);
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Approved');
card.statusClass.should('have.class','approved');
card.availabilityText.should("have.text", "Approved");
card.statusClass.should("have.class", "approved");
});
});
@ -163,17 +217,17 @@ describe("Discover Cards Requests Tests", () => {
var expectedId = body[1].id;
var title = body[1].title;
const card = Page.popularCarousel.getCard(expectedId, true);
card.verifyTitle(title);
card.topLevelCard.realHover();
const card = Page.popularCarousel.getCard(expectedId, true, DiscoverType.Popular);
card.title.realHover();
card.verifyTitle(title);
card.requestButton.should("not.exist");
card.availabilityText.should('have.text','Available');
card.statusClass.should('have.class','available');
card.availabilityText.should("have.text", "Available");
card.statusClass.should("have.class", "available");
});
});
it("Not available TV does not allow us to request", () => {
it("Not available TV allow admin to request", () => {
cy.intercept("GET", "**/search/Tv/popular/**", (req) => {
req.reply((res) => {
const body = res.body;
@ -184,25 +238,77 @@ describe("Discover Cards Requests Tests", () => {
res.send(body);
});
}).as("cardsResponse");
cy.intercept("GET", "**/search/Tv/**").as("otherResponses");
window.localStorage.setItem("DiscoverOptions2", "3");
Page.visit();
cy.wait("@otherResponses");
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();
const card = Page.popularCarousel.getCard(expectedId, false, DiscoverType.Popular);
card.title.realHover();
card.verifyTitle(title);
card.requestButton.should("be.visible");
card.requestButton.click();
const modal = card.episodeRequestModal;
modal.latestSeasonButton.click();
cy.verifyNotification("has been added successfully")
Page.adminOptionsDialog.isOpen();
Page.adminOptionsDialog.requestButton.click();
cy.verifyNotification("has been added successfully");
});
});
it("Not available TV allow non-admin to request", () => {
cy.generateUniqueId().then((id) => {
cy.login();
const roles = [];
roles.push({ value: "RequestTv", enabled: true });
cy.createUser(id, "a", roles).then(() => {
cy.removeLogin();
cy.loginWithCreds(id, "a");
cy.intercept("GET", "**/search/Tv/popular/**", (req) => {
req.reply((res) => {
const body = res.body;
const tv = body[5];
tv.fullyAvailable = false;
body[5] = tv;
res.send(body);
});
}).as("cardsResponse");
cy.intercept("GET", "**/search/Tv/**").as("otherResponses");
window.localStorage.setItem("DiscoverOptions2", "3");
Page.visit();
cy.wait("@otherResponses");
cy.wait("@cardsResponse").then((res) => {
const body = JSON.parse(res.response.body);
var expectedId = body[5].id;
var title = body[5].title;
const card = Page.popularCarousel.getCard(expectedId, false, DiscoverType.Popular);
card.title.realHover();
card.verifyTitle(title);
card.requestButton.should("be.visible");
card.requestButton.click();
const modal = card.episodeRequestModal;
modal.latestSeasonButton.click();
cy.verifyNotification("has been added successfully");
});
});
});
});
});