Fixed all the automation tests, and the bugs that the tests found

pull/4112/head
tidusjar 4 years ago
parent c5f123b903
commit e34ce215ac

@ -2,4 +2,5 @@
result: boolean; result: boolean;
message: string; message: string;
errorMessage: string; errorMessage: string;
requestId: number | undefined;
} }

@ -9,6 +9,7 @@ export interface IUser {
emailAddress: string; emailAddress: string;
password: string; password: string;
userType: UserType; userType: UserType;
userAlias: string;
lastLoggedIn: Date; lastLoggedIn: Date;
hasLoggedIn: boolean; hasLoggedIn: boolean;
movieRequestLimit: number; movieRequestLimit: number;

@ -75,7 +75,7 @@
</ng-template> </ng-template>
</span> </span>
<span *ngIf="isAdmin && hasRequest"> <span *ngIf="isAdmin && hasRequest">
<button id="approveBtn" *ngIf="!movie.approved" (click)="approve()" mat-raised-button class="btn-spacing" color="accent"> <button id="approveBtn" *ngIf="!movie.approved " (click)="approve()" mat-raised-button class="btn-spacing" color="accent">
<i class="fas fa-plus"></i> {{ 'Common.Approve' | translate }} <i class="fas fa-plus"></i> {{ 'Common.Approve' | translate }}
</button> </button>
<button id="markAvailableBtn" *ngIf="!movie.available" (click)="markAvailable()" mat-raised-button class="btn-spacing" <button id="markAvailableBtn" *ngIf="!movie.available" (click)="markAvailable()" mat-raised-button class="btn-spacing"

@ -86,9 +86,16 @@ export class MovieDetailsComponent {
public async request(userId?: string) { public async request(userId?: string) {
if (this.isAdmin) { if (this.isAdmin) {
this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.movie, id: this.movie.id }, panelClass: 'modal-panel' }); const dialog = this.dialog.open(AdminRequestDialogComponent, { width: "700px", data: { type: RequestType.movie, id: this.movie.id }, panelClass: 'modal-panel' });
dialog.afterClosed().subscribe(async (result) => {
if (result) {
this.movie.requested = true;
this.movie.requestId = result.requestId;
this.movieRequest = await this.requestService.getMovieRequest(this.movie.requestId);
}
});
} else { } else {
const result = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, languageCode: null, requestOnBehalf: userId, qualityPathOverride: 0, rootFolderOverride: 0 }).toPromise(); const result = await this.requestService.requestMovie({ theMovieDbId: this.theMovidDbId, languageCode: null, requestOnBehalf: userId, qualityPathOverride: undefined, rootFolderOverride: undefined }).toPromise();
if (result.result) { if (result.result) {
this.movie.requested = true; this.movie.requested = true;
this.messageService.send(result.message, "Ok"); this.messageService.send(result.message, "Ok");

@ -2,7 +2,7 @@
<div class="rating medium-font"> <div class="rating medium-font">
<span *ngIf="movie.voteAverage" <span *ngIf="movie.voteAverage"
matTooltip="{{'MediaDetails.Votes' | translate }} {{movie.voteCount | thousandShort: 1}}"> 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>
<span *ngIf="ratings?.critics_rating && ratings?.critics_score"> <span *ngIf="ratings?.critics_rating && ratings?.critics_score">
<img class="rating-small" <img class="rating-small"

@ -1,9 +1,9 @@
<form [formGroup]="form" *ngIf="form"> <form [formGroup]="form" *ngIf="form">
<h1>Advanced Options</h1> <h1 id="advancedOptionsTitle">{{'MediaDetails.AdvancedOptions' | translate }}</h1>
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">
You can configure the request here, once requested it will be send to your DVR application and will be auto approved! {{'MediaDetails.AutoApproveOptions' | translate }}
</div> </div>
<div style="max-width: 0; max-height: 0; overflow: hidden;"> <div style="max-width: 0; max-height: 0; overflow: hidden;">
@ -14,7 +14,8 @@
<h3>{{'MediaDetails.RequestOnBehalf' | translate }}</h3> <h3>{{'MediaDetails.RequestOnBehalf' | translate }}</h3>
<mat-form-field class="example-full-width" appearance="outline" floatLabel=auto> <mat-form-field class="example-full-width" appearance="outline" floatLabel=auto>
<mat-label>{{ 'MediaDetails.PleaseSelectUser' | translate}}</mat-label> <mat-label>{{ 'MediaDetails.PleaseSelectUser' | translate}}</mat-label>
<input type="text" <input id="requestOnBehalfUserInput"
type="text"
matInput matInput
formControlName="username" formControlName="username"
[matAutocomplete]="auto"> [matAutocomplete]="auto">
@ -35,16 +36,16 @@
<h3>Sonarr Overrides</h3> <h3>Sonarr Overrides</h3>
<mat-form-field appearance="outline" floatLabel=auto> <mat-form-field appearance="outline" floatLabel=auto>
<mat-label>{{'MediaDetails.QualityProfilesSelect' | translate }}</mat-label> <mat-label>{{'MediaDetails.QualityProfilesSelect' | translate }}</mat-label>
<mat-select formControlName="sonarrPathId"> <mat-select id="sonarrQualitySelect" formControlName="sonarrPathId">
<mat-option *ngFor="let profile of sonarrProfiles" value="{{profile.id}}">{{profile.name}}</mat-option> <mat-option id="sonarrQualitySelect{{profile.id}}" *ngFor="let profile of sonarrProfiles" value="{{profile.id}}">{{profile.name}}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div > <div >
<mat-form-field appearance="outline" floatLabel=auto> <mat-form-field appearance="outline" floatLabel=auto>
<mat-label>{{'MediaDetails.RootFolderSelect' | translate }}</mat-label> <mat-label>{{'MediaDetails.RootFolderSelect' | translate }}</mat-label>
<mat-select formControlName="sonarrFolderId"> <mat-select id="sonarrFolderSelect" formControlName="sonarrFolderId">
<mat-option *ngFor="let profile of sonarrRootFolders" value="{{profile.id}}">{{profile.path}}</mat-option> <mat-option id="sonarrFolderSelect{{profile.id}}" *ngFor="let profile of sonarrRootFolders" value="{{profile.id}}">{{profile.path}}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
@ -52,21 +53,21 @@
<!-- End Sonarr--> <!-- End Sonarr-->
<!-- Radarr --> <!-- Radarr -->
<div *ngIf="data.type === RequestType.movie"> <div *ngIf="data.type === RequestType.movie && radarrEnabled">
<div> <div>
<h3>Radarr Overrides</h3> <h3>Radarr Overrides</h3>
<mat-form-field appearance="outline" floatLabel=auto> <mat-form-field appearance="outline" floatLabel=auto>
<mat-label>{{'MediaDetails.QualityProfilesSelect' | translate }}</mat-label> <mat-label>{{'MediaDetails.QualityProfilesSelect' | translate }}</mat-label>
<mat-select formControlName="radarrPathId"> <mat-select id="radarrQualitySelect" formControlName="radarrPathId">
<mat-option *ngFor="let profile of radarrProfiles" value="{{profile.id}}">{{profile.name}}</mat-option> <mat-option id="radarrQualitySelect{{profile.id}}" *ngFor="let profile of radarrProfiles" value="{{profile.id}}">{{profile.name}}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div mat-dialog-content> <div mat-dialog-content>
<mat-form-field appearance="outline" floatLabel=auto> <mat-form-field appearance="outline" floatLabel=auto>
<mat-label>{{'MediaDetails.RootFolderSelect' | translate }}</mat-label> <mat-label>{{'MediaDetails.RootFolderSelect' | translate }}</mat-label>
<mat-select formControlName="radarrFolderId"> <mat-select id="radarrFolderSelect" formControlName="radarrFolderId">
<mat-option *ngFor="let profile of radarrRootFolders" value="{{profile.id}}">{{profile.path}}</mat-option> <mat-option id="radarrFolderSelect{{profile.id}}" *ngFor="let profile of radarrRootFolders" value="{{profile.id}}">{{profile.path}}</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
@ -75,8 +76,8 @@
<div mat-dialog-actions> <div mat-dialog-actions>
<button mat-raised-button [mat-dialog-close]="" color="warn">{{ 'Common.Cancel' | translate }}</button> <button mat-raised-button id="cancelButton" [mat-dialog-close]="" color="warn">{{ 'Common.Cancel' | translate }}</button>
<button mat-raised-button (click)="submitRequest()" color="accent">{{ 'Common.Request' | translate }}</button> <button mat-raised-button id="requestButton" (click)="submitRequest()" color="accent">{{ 'Common.Request' | translate }}</button>
</div> </div>
</form> </form>

@ -112,11 +112,17 @@ export class AdminRequestDialogComponent implements OnInit {
}).subscribe((x) => { }).subscribe((x) => {
if (x.result) { if (x.result) {
this.notificationService.send(x.message, "Ok"); this.notificationService.send(x.message, "Ok");
model.radarrQualityOverrideTitle = this.radarrProfiles?.filter(x => x.id == model.radarrPathId)[0]?.name;
model.radarrRootFolderTitle = this.radarrRootFolders?.filter(x => x.id == model.radarrFolderId)[0]?.path;
model.requestId = x.requestId;
this.dialogRef.close(model);
} else { } else {
this.notificationService.send(x.errorMessage, "Ok"); this.notificationService.send(x.errorMessage, "Ok");
} }
this.dialogRef.close();
}) })
} }

@ -78,6 +78,7 @@ export class UserManagementUserComponent implements OnInit {
episodeRequestQuota: null, episodeRequestQuota: null,
movieRequestQuota: null, movieRequestQuota: null,
language: null, language: null,
userAlias: "",
streamingCountry: "US", streamingCountry: "US",
userQualityProfiles: { userQualityProfiles: {
radarrQualityProfile: 0, radarrQualityProfile: 0,

@ -252,6 +252,7 @@
"ViewCollection":"View Collection", "ViewCollection":"View Collection",
"NotEnoughInfo": "Unfortunately there is not enough information about this show yet!", "NotEnoughInfo": "Unfortunately there is not enough information about this show yet!",
"AdvancedOptions":"Advanced Options", "AdvancedOptions":"Advanced Options",
"AutoApproveOptions":"You can configure the request here, once requested it will be send to your DVR application and will be auto approved!",
"QualityProfilesSelect":"Select A Quality Profile", "QualityProfilesSelect":"Select A Quality Profile",
"RootFolderSelect":"Select A Root Folder", "RootFolderSelect":"Select A Root Folder",
"Status":"Status", "Status":"Status",

@ -1,10 +1,15 @@
import { BasePage } from "../../base.page"; import { BasePage } from "../../base.page";
import { AdminRequestDialog } from "../../shared/AdminRequestDialog";
class MovieInformationPanel { class MovieInformationPanel {
get denyReason(): Cypress.Chainable<any> { get denyReason(): Cypress.Chainable<any> {
return cy.get('#deniedReasonInfo'); return cy.get('#deniedReasonInfo');
} }
get requestedBy(): Cypress.Chainable<any> {
return cy.get('#requestedByInfo');
}
} }
class DenyModal { class DenyModal {
@ -74,6 +79,7 @@ class MovieDetailsPage extends BasePage {
denyModal = new DenyModal(); denyModal = new DenyModal();
informationPanel = new MovieInformationPanel(); informationPanel = new MovieInformationPanel();
adminOptionsDialog = new AdminRequestDialog();
constructor() { constructor() {
super(); super();

@ -0,0 +1,58 @@
export class AdminRequestDialog {
isOpen(): Cypress.Chainable<any> {
return cy.waitUntil(x => {
return this.title.should('exist');
});
}
get title(): Cypress.Chainable<any> {
return cy.get(`#advancedOptionsTitle`);
}
get requestOnBehalfUserInput(): Cypress.Chainable<any> {
return cy.get(`#requestOnBehalfUserInput`);
}
get sonarrQualitySelect(): Cypress.Chainable<any> {
return cy.get(`#sonarrQualitySelect`);
}
selectSonarrQuality(id: number): Cypress.Chainable<any> {
return cy.get(`#sonarrQualitySelect${id}`);
}
get sonarrFolderSelect(): Cypress.Chainable<any> {
return cy.get(`#sonarrFolderSelect`);
}
selectSonarrFolder(id: number): Cypress.Chainable<any> {
return cy.get(`#sonarrFolderSelect${id}`);
}
get radarrQualitySelect(): Cypress.Chainable<any> {
return cy.get(`#radarrQualitySelect`);
}
selectradarrQuality(id: number): Cypress.Chainable<any> {
return cy.get(`#radarrQualitySelect${id}`);
}
get radarrFolderSelect(): Cypress.Chainable<any> {
return cy.get(`#radarrFolderSelect`);
}
selectradarrFolder(id: number): Cypress.Chainable<any> {
return cy.get(`#radarrFolderSelect${id}`);
}
get cancelButton(): Cypress.Chainable<any> {
return cy.get(`#cancelButton`);
}
get requestButton(): Cypress.Chainable<any> {
return cy.get(`#requestButton`);
}
}

@ -6,6 +6,10 @@ describe("Movie Details Buttons", () => {
Page.visit("587807"); Page.visit("587807");
Page.requestButton.click(); Page.requestButton.click();
Page.adminOptionsDialog.isOpen();
Page.adminOptionsDialog.requestButton.click();
cy.verifyNotification("Tom & Jerry (2021) has been successfully added"); cy.verifyNotification("Tom & Jerry (2021) has been successfully added");
Page.requestedButton.should("be.visible"); Page.requestedButton.should("be.visible");
@ -83,6 +87,8 @@ describe("Movie Details Buttons", () => {
Page.visit("399566"); Page.visit("399566");
Page.requestButton.click(); Page.requestButton.click();
Page.adminOptionsDialog.isOpen();
Page.adminOptionsDialog.requestButton.click();
cy.verifyNotification( cy.verifyNotification(
"Godzilla vs. Kong (2021) has been successfully added" "Godzilla vs. Kong (2021) has been successfully added"
); );
@ -96,12 +102,14 @@ describe("Movie Details Buttons", () => {
Page.availableButton.should("exist"); Page.availableButton.should("exist");
}); });
it("Movie Requested, Deny Movie", () => { it.only("Movie Requested, Deny Movie", () => {
cy.login(); cy.login();
Page.visit("671"); Page.visit("671");
Page.requestButton.click(); Page.requestButton.click();
Page.adminOptionsDialog.isOpen();
Page.adminOptionsDialog.requestButton.click();
cy.verifyNotification( cy.verifyNotification(
"Harry Potter and the Philosopher's Stone (2001) has been successfully added" "Harry Potter and the Philosopher's Stone (2001) has been successfully added"
); );
@ -112,6 +120,7 @@ describe("Movie Details Buttons", () => {
Page.denyButton.click(); Page.denyButton.click();
Page.denyModal.denyReason.type("Automation Tests"); Page.denyModal.denyReason.type("Automation Tests");
cy.wait(500);
Page.denyModal.denyButton.click(); Page.denyModal.denyButton.click();
Page.deniedButton.should('exist'); Page.deniedButton.should('exist');

@ -173,7 +173,7 @@ describe("Discover Cards Requests Tests", () => {
}); });
}); });
it.only("Not available TV does not allow us to request", () => { it("Not available TV does not allow us to request", () => {
cy.intercept("GET", "**/search/Tv/popular/**", (req) => { cy.intercept("GET", "**/search/Tv/popular/**", (req) => {
req.reply((res) => { req.reply((res) => {
const body = res.body; const body = res.body;

Loading…
Cancel
Save