Fixed up tests to be aware of the new dialog

pull/4112/head
tidusjar 4 years ago
parent 5e6edc2ad8
commit 5678f43f41

@ -21,7 +21,7 @@
</div>
<div class="row button-request-container" *ngIf="!result.available && !result.approved && !result.requested">
<div class="button-request poster-overlay">
<button id="requestButton{{result.id}}{{result.type}}" mat-raised-button class="btn-green full-width poster-request-btn" (click)="request($event)">
<button id="requestButton{{result.id}}{{result.type}}{{discoverType}}" mat-raised-button class="btn-green full-width poster-request-btn" (click)="request($event)">
<i *ngIf="!loading" class="fa-lg fas fa-cloud-download-alt"></i>
<i *ngIf="loading" class="fas fa-spinner fa-pulse fa-2x fa-fw" aria-hidden="true"></i>
</button>

@ -7,6 +7,7 @@ import { ISearchTvResultV2 } from "../../../interfaces/ISearchTvResultV2";
import { ISearchMovieResultV2 } from "../../../interfaces/ISearchMovieResultV2";
import { EpisodeRequestComponent } from "../../../shared/episode-request/episode-request.component";
import { AdminRequestDialogComponent } from "../../../shared/admin-request-dialog/admin-request-dialog.component";
import { DiscoverType } from "../carousel-list/carousel-list.component";
@Component({
selector: "discover-card",
@ -15,6 +16,7 @@ import { AdminRequestDialogComponent } from "../../../shared/admin-request-dialo
})
export class DiscoverCardComponent implements OnInit {
@Input() public discoverType: DiscoverType;
@Input() public result: IDiscoverCardResult;
@Input() public isAdmin: boolean;
public RequestType = RequestType;
@ -126,7 +128,18 @@ export class DiscoverCardComponent implements OnInit {
const dialog = this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.movie, id: this.result.id }, panelClass: 'modal-panel' });
dialog.afterClosed().subscribe((result) => {
if (result) {
this.result.requested = true;
this.requestService.requestMovie({ theMovieDbId: +this.result.id,
languageCode: null,
qualityPathOverride: result.radarrPathId,
requestOnBehalf: result.username?.id,
rootFolderOverride: result.radarrFolderId, }).subscribe(x => {
if (x.result) {
this.result.requested = true;
this.messageService.send(x.message, "Ok");
} else {
this.messageService.send(x.errorMessage, "Ok");
}
});
}
});
} else {

@ -8,6 +8,6 @@
<p-carousel #carousel [numVisible]="10" [numScroll]="10" [page]="0" [value]="discoverResults" [responsiveOptions]="responsiveOptions" (onPage)="newPage()">
<ng-template let-result pTemplate="item">
<discover-card [isAdmin]="isAdmin" [result]="result"></discover-card>
<discover-card [discoverType]="discoverType" [isAdmin]="isAdmin" [result]="result"></discover-card>
</ng-template>
</p-carousel>

@ -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();

@ -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> {

@ -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);
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','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");
});
});
});
});
});

Loading…
Cancel
Save