test: Added automation for the new feature

This commit is contained in:
tidusjar 2022-09-14 14:01:41 +01:00
commit 3a03c22d44
4 changed files with 78 additions and 3 deletions

View file

@ -22,7 +22,7 @@
</div> </div>
<div class="row action-items"> <div class="row action-items">
<div class="col-12" *ngIf="isAdmin"> <div class="col-12" *ngIf="isAdmin">
<button *ngIf="!request.approved" id="approve-{{request.mediaId}}" color="accent" mat-raised-button (click)="approve()">{{'Common.Approve' | translate}}</button> <button *ngIf="!request.approved" id="detailed-request-approve-{{request.mediaId}}" color="accent" mat-raised-button (click)="approve()">{{'Common.Approve' | translate}}</button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -1,7 +1,7 @@
{ {
"$schema": "https://on.cypress.io/cypress.schema.json", "$schema": "https://on.cypress.io/cypress.schema.json",
"supportFile": "cypress/support/index.ts", "supportFile": "cypress/support/index.ts",
"baseUrl": "http://localhost:5000", "baseUrl": "http://localhost:3577",
"integrationFolder": "cypress/tests", "integrationFolder": "cypress/tests",
"testFiles": "**/*.spec.ts*", "testFiles": "**/*.spec.ts*",
"watchForFileChanges": true, "watchForFileChanges": true,

View file

@ -43,9 +43,13 @@ class DetailedCard {
return cy.get(`#detailed-request-status-${this.id}`); return cy.get(`#detailed-request-status-${this.id}`);
} }
get approveButton(): Cypress.Chainable<any> {
return cy.get(`#detailed-request-approve-${this.id}`);
}
verifyTitle(expected: string): Cypress.Chainable<any> { verifyTitle(expected: string): Cypress.Chainable<any> {
return this.title.should('have.text',expected); return this.title.should('have.text',expected);
} }
constructor(id: string) { constructor(id: string) {
this.id = id; this.id = id;

View file

@ -44,6 +44,7 @@ describe("Discover Recently Requested Tests", () => {
const card = Page.recentlyRequested.getRequest("626735"); const card = Page.recentlyRequested.getRequest("626735");
card.verifyTitle("Dog"); card.verifyTitle("Dog");
card.status.should('contain.text', 'Pending'); card.status.should('contain.text', 'Pending');
card.approveButton.should('be.visible');
}); });
}); });
@ -69,6 +70,7 @@ describe("Discover Recently Requested Tests", () => {
const card = Page.recentlyRequested.getRequest("675353"); const card = Page.recentlyRequested.getRequest("675353");
card.verifyTitle("Sonic the Hedgehog 2"); card.verifyTitle("Sonic the Hedgehog 2");
card.status.should('contain.text', 'Available'); // Because admin auto request card.status.should('contain.text', 'Available'); // Because admin auto request
card.approveButton.should('not.exist');
}); });
}); });
@ -94,6 +96,7 @@ describe("Discover Recently Requested Tests", () => {
const card = Page.recentlyRequested.getRequest("135647"); const card = Page.recentlyRequested.getRequest("135647");
card.verifyTitle("2 Good 2 Be True"); card.verifyTitle("2 Good 2 Be True");
card.status.should('contain.text', 'Available'); card.status.should('contain.text', 'Available');
card.approveButton.should('not.exist');
}); });
}); });
@ -119,6 +122,7 @@ describe("Discover Recently Requested Tests", () => {
const card = Page.recentlyRequested.getRequest("158415"); const card = Page.recentlyRequested.getRequest("158415");
card.verifyTitle("Pantanal"); card.verifyTitle("Pantanal");
card.status.should('contain.text', 'Partially Available'); card.status.should('contain.text', 'Partially Available');
card.approveButton.should('not.exist');
}); });
}); });
@ -143,6 +147,7 @@ describe("Discover Recently Requested Tests", () => {
const card = Page.recentlyRequested.getRequest("60574"); const card = Page.recentlyRequested.getRequest("60574");
card.verifyTitle("Peaky Blinders"); card.verifyTitle("Peaky Blinders");
card.status.should('contain.text', 'Pending'); card.status.should('contain.text', 'Pending');
card.approveButton.should('be.visible');
}); });
}); });
@ -161,4 +166,70 @@ describe("Discover Recently Requested Tests", () => {
}); });
}); });
it("Approve Requested Movie", () => {
cy.requestMovie(55341);
cy.intercept("GET", "**/v2/Requests/recentlyRequested", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[0];
movie.available = false;
movie.approved = false;
body[0] = movie;
res.send(body);
});
}).as("response");
cy.intercept("POST", "**/v1/Request/Movie/Approve").as("approveCall");
Page.visit();
cy.wait("@response").then((_) => {
const card = Page.recentlyRequested.getRequest("55341");
card.approveButton.should('be.visible');
card.approveButton.click();
cy.wait("@approveCall").then((_) => {
card.status.should('contain.text', 'Approved');
});
});
});
it.only("Approve Requested Tv Show", () => {
cy.requestAllTv(71712);
cy.intercept("GET", "**/v2/Requests/recentlyRequested", (req) => {
req.reply((res) => {
const body = res.body;
const movie = body[0];
movie.available = false;
movie.approved = false;
body[0] = movie;
res.send(body);
});
}).as("response");
cy.intercept("POST", "**/v1/Request/tv/approve").as("approveCall");
Page.visit();
cy.wait("@response").then((_) => {
const card = Page.recentlyRequested.getRequest("71712");
card.approveButton.should('be.visible');
card.approveButton.click();
cy.wait("@approveCall").then((_) => {
card.status.should('contain.text', 'Approved');
});
});
});
}); });