Skip to content

Commit

Permalink
Fixed up some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Apr 1, 2021
1 parent 0eeb163 commit f2ea1d0
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}}{{discoverType}}" mat-raised-button class="btn-ombi full-width poster-request-btn" (click)="request($event)">
<button id="requestButton{{result.id}}{{result.type}}{{discoverType}}" *ngIf="requestable" mat-raised-button class="btn-ombi 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>
{{'Common.Request' | translate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class DiscoverCardComponent implements OnInit {
public fullyLoaded = false;
public loading: boolean;

public requestable: boolean;

// This data is needed to open the dialog
private tvSearchResult: ISearchTvResultV2;

Expand All @@ -44,19 +46,10 @@ export class DiscoverCardComponent implements OnInit {
}

public async getExtraTvInfo() {
// if (this.result.tvMovieDb) {
this.tvSearchResult = await this.searchService.getTvInfoWithMovieDbId(+this.result.id);
// } else {
// this.tvSearchResult = await this.searchService.getTvInfo(+this.result.id);
// }
// if (!this.tvSearchResult || this.tvSearchResult?.status.length > 0 && this.tvSearchResult?.status === "404") {
// this.hide = true;
// return;
// }

this.tvSearchResult = await this.searchService.getTvInfoWithMovieDbId(+this.result.id);
this.requestable = true;
this.setTvDefaults(this.tvSearchResult);
this.updateTvItem(this.tvSearchResult);

}

public async getAlbumInformation() {
Expand All @@ -69,12 +62,13 @@ export class DiscoverCardComponent implements OnInit {
if (art.image) {
this.result.posterPath = art.image;

this.fullyLoaded = true;
}
})
}
this.result.title = x.startYear ? `${x.name} (${x.startYear})` : x.name;
this.result.overview = x.overview;
this.fullyLoaded = true;
this.requestable = true;
});
}

Expand Down Expand Up @@ -166,6 +160,7 @@ export class DiscoverCardComponent implements OnInit {
} else {
this.fullyLoaded = true;
}
this.requestable = true;
}

private updateMovieItem(updated: ISearchMovieResultV2) {
Expand Down
4 changes: 2 additions & 2 deletions src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
</div>
<div class="profile-block">
<a routerLink="/user-preferences">
<div class="profile-username">{{username}}</div>
<div class="profile-img" data-test="profile-image"><img [matTooltip]="username" [src]="getUserImage()" /></div>
<div class="profile-username" data-test="profile-username">{{username}}</div>
<div class="profile-img" data-test="profile-image"><img [src]="getUserImage()" /></div>
</a>
</div>

Expand Down
4 changes: 4 additions & 0 deletions tests/cypress/integration/page-objects/shared/NavBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class NavBar {
return cy.getByData('profile-image');
}

get username(): Cypress.Chainable<any> {
return cy.getByData('profile-username');
}

get logout(): Cypress.Chainable<any> {
return cy.get('#nav-logout');
}
Expand Down
85 changes: 85 additions & 0 deletions tests/cypress/tests/api/v1/tv-request.api.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
describe("TV Request V1 API tests", () => {
beforeEach(() => {
cy.login();
});

it("Request All of TV Show (Fear the Walking Dead)", () => {
const request = {
TvDbId: 290853,
RequestAll: true,
};

cy.api({
url: "/api/v1/request/tv",
body: JSON.stringify(request),
method: "POST",
headers: {
Authorization: "Bearer " + window.localStorage.getItem("id_token"),
"Content-Type": "application/json",
},
}).then((res) => {
expect(res.status).equal(200);
const body = res.body;
expect(body.result).to.be.true;
expect(body.requestId).not.to.be.null;
expect(body.isError).to.be.false;
expect(body.errorMessage).to.be.null;
});
});

it("Request First Season of TV Show (American Horror Story)", () => {
const request = {
TvDbId: 250487,
FirstSeason: true,
};

cy.api({
url: "/api/v1/request/tv",
body: JSON.stringify(request),
method: "POST",
headers: {
Authorization: "Bearer " + window.localStorage.getItem("id_token"),
"Content-Type": "application/json",
},
}).then((res) => {
expect(res.status).equal(200);
const body = res.body;
expect(body.result).to.be.true;
expect(body.requestId).not.to.be.null;
expect(body.isError).to.be.false;
expect(body.errorMessage).to.be.null;
});
});

it("Request Two Episode of First Season TV Show (The Sopranos)", () => {
const request = {
TvDbId: 75299,
Seasons: [
{
SeasonNumber: 1,
Episodes: [
{ EpisodeNumber: 1 },
{ EpisodeNumber: 2 },
],
},
],
};

cy.api({
url: "/api/v1/request/tv",
body: JSON.stringify(request),
method: "POST",
headers: {
Authorization: "Bearer " + window.localStorage.getItem("id_token"),
"Content-Type": "application/json",
},
}).then((res) => {
expect(res.status).equal(200);
const body = res.body;
expect(body.result).to.be.true;
expect(body.requestId).not.to.be.null;
expect(body.isError).to.be.false;
expect(body.errorMessage).to.be.null;
});
});
});
2 changes: 2 additions & 0 deletions tests/cypress/tests/navigation/navigation-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe("Navigation Bar Tests", () => {
Page.navbar.requests.should("be.visible");
Page.navbar.discover.should("be.visible");
Page.navbar.userPreferences.should("be.visible");
Page.navbar.username.contains("a");
Page.navbar.logout.should("be.visible");
});

Expand All @@ -34,6 +35,7 @@ describe("Navigation Bar Tests", () => {
Page.navbar.requests.should("be.visible");
Page.navbar.discover.should("be.visible");
Page.navbar.userPreferences.should("be.visible");
Page.navbar.username.contains(id);
Page.navbar.logout.should("be.visible");
});
});
Expand Down

0 comments on commit f2ea1d0

Please sign in to comment.