mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-13 00:32:57 -07:00
More UI tests !wip
This commit is contained in:
parent
2d0c48a867
commit
1b13d6e6b7
9 changed files with 101 additions and 12 deletions
|
@ -12,6 +12,7 @@ namespace Ombi.Core.Engine.Interfaces
|
||||||
Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search);
|
Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search);
|
||||||
|
|
||||||
Task RemoveMovieRequest(int requestId);
|
Task RemoveMovieRequest(int requestId);
|
||||||
|
Task RemoveAllMovieRequests();
|
||||||
|
|
||||||
Task<MovieRequests> UpdateMovieRequest(MovieRequests request);
|
Task<MovieRequests> UpdateMovieRequest(MovieRequests request);
|
||||||
Task<RequestEngineResult> ApproveMovie(MovieRequests request);
|
Task<RequestEngineResult> ApproveMovie(MovieRequests request);
|
||||||
|
|
|
@ -416,6 +416,12 @@ namespace Ombi.Core.Engine
|
||||||
await MovieRepository.Delete(request);
|
await MovieRepository.Delete(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task RemoveAllMovieRequests()
|
||||||
|
{
|
||||||
|
var request = MovieRepository.GetAll();
|
||||||
|
await MovieRepository.DeleteRange(request);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<bool> UserHasRequest(string userId)
|
public async Task<bool> UserHasRequest(string userId)
|
||||||
{
|
{
|
||||||
return await MovieRepository.GetAll().AnyAsync(x => x.RequestedUserId == userId);
|
return await MovieRepository.GetAll().AnyAsync(x => x.RequestedUserId == userId);
|
||||||
|
|
|
@ -32,16 +32,16 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let vm of currentVotes">
|
<tr *ngFor="let vm of currentVotes">
|
||||||
<td class="vcenter">
|
<td class="vcenter">
|
||||||
<button class="btn btn-info-outline col-md-6" (click)="upvote(vm)"><i class="fa fa-thumbs-o-up"
|
<button id="{{vm.requestId}}upvote" class="btn btn-info-outline col-md-6" (click)="upvote(vm)"><i class="fa fa-thumbs-o-up"
|
||||||
aria-hidden="true"></i></button>
|
aria-hidden="true"></i></button>
|
||||||
<button class="btn btn-info-outline col-md-6" (click)="downvote(vm)" ><i class="fa fa-thumbs-o-down"
|
<button id="{{vm.requestId}}downvote" class="btn btn-info-outline col-md-6" (click)="downvote(vm)" ><i class="fa fa-thumbs-o-down"
|
||||||
aria-hidden="true"></i></button>
|
aria-hidden="true"></i></button>
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 10%"> <img *ngIf="vm.image" class="img-responsive poster" style="max-width: 100%;
|
<td style="width: 10%"> <img *ngIf="vm.image" class="img-responsive poster" style="max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
width: 100%;"
|
width: 100%;"
|
||||||
(click)="toggle($event, vm.image)" src="{{vm.image}}" alt="poster"></td>
|
(click)="toggle($event, vm.image)" src="{{vm.image}}" alt="poster"></td>
|
||||||
<td class="vcenter">{{vm.title}}</td>
|
<td class="vcenter" [attr.data-test]='vm.requestId'>{{vm.title}}</td>
|
||||||
<td class="vcenter" [innerHTML]="vm.description"></td>
|
<td class="vcenter" [innerHTML]="vm.description"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -117,6 +117,18 @@ namespace Ombi.Controllers
|
||||||
await MovieRequestEngine.RemoveMovieRequest(requestId);
|
await MovieRequestEngine.RemoveMovieRequest(requestId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the specified movie request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestId">The request identifier.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpDelete("movie/all")]
|
||||||
|
[PowerUser]
|
||||||
|
public async Task DeleteAllRequests()
|
||||||
|
{
|
||||||
|
await MovieRequestEngine.RemoveAllMovieRequests();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the specified movie request.
|
/// Updates the specified movie request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
4
src/Ombi/cypress/fixtures/login.json
Normal file
4
src/Ombi/cypress/fixtures/login.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"username": "automation",
|
||||||
|
"password": "password"
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ describe('Voting Feature', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
cy.login('automation', 'password').then(() => {
|
cy.login('automation', 'password').then(() => {
|
||||||
|
|
||||||
|
cy.removeAllMovieRequests();
|
||||||
|
|
||||||
cy.createUser('basicUser', 'password', [{
|
cy.createUser('basicUser', 'password', [{
|
||||||
value: "requestmovie",
|
value: "requestmovie",
|
||||||
|
@ -28,6 +29,7 @@ describe('Voting Feature', function () {
|
||||||
Enabled: "true",
|
Enabled: "true",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Enable voting
|
// Enable voting
|
||||||
cy.request({
|
cy.request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -43,22 +45,26 @@ describe('Voting Feature', function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Login as the regular user now
|
// Login as regular user
|
||||||
cy.clearLocalStorage();
|
|
||||||
|
|
||||||
cy.login('basicUser', 'password').then(() => {
|
cy.login('basicUser', 'password').then(() => {
|
||||||
|
|
||||||
cy.visit('/vote');
|
cy.visit('/vote');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Make sure we can load the page
|
||||||
|
///
|
||||||
it('Loads votes page', function () {
|
it('Loads votes page', function () {
|
||||||
// cy.login('basicUser','password');
|
// cy.login('basicUser','password');
|
||||||
cy.contains("Vote");
|
cy.contains("Vote");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Make sure that when we request a movie it automatically get's upvoted
|
||||||
|
///
|
||||||
it('Request Movie automatically upvotes when I am the requestor', function () {
|
it('Request Movie automatically upvotes when I am the requestor', function () {
|
||||||
cy.requestMovie(335983).then(() => {
|
cy.requestMovie(335983).then(() => {
|
||||||
cy.visit('/vote');
|
cy.visit('/vote');
|
||||||
|
@ -70,7 +76,9 @@ describe('Voting Feature', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Make sure that when we request a tv show it automatically get's upvoted
|
||||||
|
///
|
||||||
it('Request TV automatically upvotes when I am the requestor', function () {
|
it('Request TV automatically upvotes when I am the requestor', function () {
|
||||||
cy.requestAllTv(305288).then(() => {
|
cy.requestAllTv(305288).then(() => {
|
||||||
cy.visit('/vote');
|
cy.visit('/vote');
|
||||||
|
@ -82,5 +90,51 @@ describe('Voting Feature', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Upvotes a movie with a different user, the votes should eq 2
|
||||||
|
/// Meaning it should be approved now
|
||||||
|
///
|
||||||
|
it.only('Upvote Movie to be approved', function () {
|
||||||
|
cy.login('basicUser2', 'password').then(() => {
|
||||||
|
cy.requestMovie(439079).then(() => {
|
||||||
|
cy.login('basicUser', 'password').then(() => {
|
||||||
|
|
||||||
|
cy.visit('/vote');
|
||||||
|
cy.contains('The Nun').should('have.attr', 'data-test').then(($id) => {
|
||||||
|
cy.get('#' + $id + 'upvote').click();
|
||||||
|
cy.verifyNotification('Voted!');
|
||||||
|
|
||||||
|
// Verify it's in the completed panel
|
||||||
|
cy.get('#completedVotes').click(); cy.contains('The Nun').should('have.attr', 'data-test').then(($id) => {
|
||||||
|
cy.get('#' + $id + 'upvote').should('have.attr', 'disabled');
|
||||||
|
cy.get('#' + $id + 'downvote').should('not.have.attr', 'disabled');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it.only('Downvote Movie', function () {
|
||||||
|
cy.login('basicUser2', 'password').then(() => {
|
||||||
|
cy.requestMovie(439079).then(() => {
|
||||||
|
cy.login('basicUser', 'password').then(() => {
|
||||||
|
|
||||||
|
cy.visit('/vote');
|
||||||
|
cy.contains('The Nun').should('have.attr', 'data-test').then(($id) => {
|
||||||
|
cy.get('#' + $id + 'downvote').click();
|
||||||
|
cy.verifyNotification('Voted!');
|
||||||
|
|
||||||
|
// Verify it's in the completed panel
|
||||||
|
cy.get('#completedVotes').click(); cy.contains('The Nun').should('have.attr', 'data-test').then(($id) => {
|
||||||
|
cy.get('#' + $id + 'upvote').should('not.have.attr', 'disabled');
|
||||||
|
cy.get('#' + $id + 'downvote').should('have.attr', 'disabled');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
|
@ -1,7 +1,9 @@
|
||||||
|
/// <reference types="Cypress" />
|
||||||
|
|
||||||
describe('Wizard Setup Tests', function() {
|
describe('Wizard Setup Tests', function() {
|
||||||
it('Setup Wizard User', function() {
|
it('Setup Wizard User', function() {
|
||||||
cy.visit('http://localhost:3577/');
|
cy.visit('/');
|
||||||
cy.url().should('include', '/Wizard')
|
cy.url().should('include', 'Wizard')
|
||||||
|
|
||||||
cy.get('[data-test=nextbtn]').click();
|
cy.get('[data-test=nextbtn]').click();
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||||
|
|
||||||
Cypress.Commands.add('login', (username, password) => {
|
Cypress.Commands.add('login', (username, password) => {
|
||||||
|
cy.clearLocalStorage();
|
||||||
cy.request({
|
cy.request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/v1/token',
|
url: '/api/v1/token',
|
||||||
|
@ -60,4 +61,3 @@ Cypress.Commands.add('verifyNotification', (text) => {
|
||||||
cy.get('.ui-growl-title').should('be.visible');
|
cy.get('.ui-growl-title').should('be.visible');
|
||||||
cy.get('.ui-growl-title').next().contains(text)
|
cy.get('.ui-growl-title').next().contains(text)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -36,5 +36,15 @@ Cypress.Commands.add('requestAllTv', (tvId) => {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add('removeAllMovieRequests', () => {
|
||||||
|
cy.request({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: '/api/v1/request/movie/all',
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
Loading…
Add table
Add a link
Reference in a new issue