More UI tests !wip

pull/2588/head^2
TidusJar 6 years ago
parent 2d0c48a867
commit 1b13d6e6b7

@ -12,6 +12,7 @@ namespace Ombi.Core.Engine.Interfaces
Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search);
Task RemoveMovieRequest(int requestId);
Task RemoveAllMovieRequests();
Task<MovieRequests> UpdateMovieRequest(MovieRequests request);
Task<RequestEngineResult> ApproveMovie(MovieRequests request);

@ -416,6 +416,12 @@ namespace Ombi.Core.Engine
await MovieRepository.Delete(request);
}
public async Task RemoveAllMovieRequests()
{
var request = MovieRepository.GetAll();
await MovieRepository.DeleteRange(request);
}
public async Task<bool> UserHasRequest(string userId)
{
return await MovieRepository.GetAll().AnyAsync(x => x.RequestedUserId == userId);

@ -32,16 +32,16 @@
<tbody>
<tr *ngFor="let vm of currentVotes">
<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>
<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>
</td>
<td style="width: 10%"> <img *ngIf="vm.image" class="img-responsive poster" style="max-width: 100%;
height: auto;
width: 100%;"
(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>
</tr>
</tbody>

@ -117,6 +117,18 @@ namespace Ombi.Controllers
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>
/// Updates the specified movie request.
/// </summary>

@ -0,0 +1,4 @@
{
"username": "automation",
"password": "password"
}

@ -4,6 +4,7 @@ describe('Voting Feature', function () {
beforeEach(function () {
cy.login('automation', 'password').then(() => {
cy.removeAllMovieRequests();
cy.createUser('basicUser', 'password', [{
value: "requestmovie",
@ -28,6 +29,7 @@ describe('Voting Feature', function () {
Enabled: "true",
},
]);
// Enable voting
cy.request({
method: 'POST',
@ -43,22 +45,26 @@ describe('Voting Feature', function () {
}
});
// Login as the regular user now
cy.clearLocalStorage();
// Login as regular user
cy.login('basicUser', 'password').then(() => {
cy.visit('/vote');
cy.visit('/vote');
});
});
});
///
/// Make sure we can load the page
///
it('Loads votes page', function () {
// cy.login('basicUser','password');
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 () {
cy.requestMovie(335983).then(() => {
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 () {
cy.requestAllTv(305288).then(() => {
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() {
it('Setup Wizard User', function() {
cy.visit('http://localhost:3577/');
cy.url().should('include', '/Wizard')
cy.visit('/');
cy.url().should('include', 'Wizard')
cy.get('[data-test=nextbtn]').click();

@ -25,6 +25,7 @@
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Cypress.Commands.add('login', (username, password) => {
cy.clearLocalStorage();
cy.request({
method: 'POST',
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').next().contains(text)
});

@ -36,5 +36,15 @@ Cypress.Commands.add('requestAllTv', (tvId) => {
headers: {
'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…
Cancel
Save