mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
Added automation tests for the voting feature
This commit is contained in:
parent
4508f79a5f
commit
2d0c48a867
5 changed files with 136 additions and 5 deletions
|
@ -65,10 +65,10 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let vm of completedVotes">
|
<tr *ngFor="let vm of completedVotes">
|
||||||
<td class="vcenter">
|
<td class="vcenter">
|
||||||
<button class="btn btn-info-outline col-md-6" [ngClass]="{'btn-success-outline': vm.myVote == VoteType.Upvote, 'btn-info-outline': vm.myVote != VoteType.Upvote}"
|
<button id="{{vm.requestId}}upvote" class="btn btn-info-outline col-md-6" [ngClass]="{'btn-success-outline': vm.myVote == VoteType.Upvote, 'btn-info-outline': vm.myVote != VoteType.Upvote}"
|
||||||
(click)="upvote(vm)" [disabled]="vm.myVote == VoteType.Upvote"><i class="fa fa-thumbs-o-up"
|
(click)="upvote(vm)" [disabled]="vm.myVote == VoteType.Upvote"><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" [ngClass]="{'btn-danger-outline': vm.myVote == VoteType.Downvote, 'btn-info-outline': vm.myVote != VoteType.Downvote}"
|
<button id="{{vm.requestId}}downvote" class="btn btn-info-outline col-md-6" [ngClass]="{'btn-danger-outline': vm.myVote == VoteType.Downvote, 'btn-info-outline': vm.myVote != VoteType.Downvote}"
|
||||||
(click)="downvote(vm)" [disabled]="vm.myVote == VoteType.Downvote"><i class="fa fa-thumbs-o-down"
|
(click)="downvote(vm)" [disabled]="vm.myVote == VoteType.Downvote"><i class="fa fa-thumbs-o-down"
|
||||||
aria-hidden="true"></i></button>
|
aria-hidden="true"></i></button>
|
||||||
</td>
|
</td>
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
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>
|
||||||
|
|
86
src/Ombi/cypress/integration/vote.feature.spec.js
Normal file
86
src/Ombi/cypress/integration/vote.feature.spec.js
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/// <reference types="Cypress" />
|
||||||
|
|
||||||
|
describe('Voting Feature', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
cy.login('automation', 'password').then(() => {
|
||||||
|
|
||||||
|
|
||||||
|
cy.createUser('basicUser', 'password', [{
|
||||||
|
value: "requestmovie",
|
||||||
|
Enabled: "true",
|
||||||
|
}, {
|
||||||
|
value: "requesttv",
|
||||||
|
Enabled: "true",
|
||||||
|
}, {
|
||||||
|
value: "requestmusic",
|
||||||
|
Enabled: "true",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
cy.createUser('basicUser2', 'password', [{
|
||||||
|
value: "requestmovie",
|
||||||
|
Enabled: "true",
|
||||||
|
}, {
|
||||||
|
value: "requesttv",
|
||||||
|
Enabled: "true",
|
||||||
|
}, {
|
||||||
|
value: "requestmusic",
|
||||||
|
Enabled: "true",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
// Enable voting
|
||||||
|
cy.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/api/v1/Settings/vote',
|
||||||
|
body: {
|
||||||
|
Enabled: true,
|
||||||
|
MovieVoteMax: 2,
|
||||||
|
MusicVoteMax: 2,
|
||||||
|
TvShowVoteMax: 2,
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Login as the regular user now
|
||||||
|
cy.clearLocalStorage();
|
||||||
|
|
||||||
|
cy.login('basicUser', 'password').then(() => {
|
||||||
|
|
||||||
|
cy.visit('/vote');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Loads votes page', function () {
|
||||||
|
// cy.login('basicUser','password');
|
||||||
|
cy.contains("Vote");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Request Movie automatically upvotes when I am the requestor', function () {
|
||||||
|
cy.requestMovie(335983).then(() => {
|
||||||
|
cy.visit('/vote');
|
||||||
|
cy.get('#completedVotes').click();
|
||||||
|
cy.contains('Venom').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('Request TV automatically upvotes when I am the requestor', function () {
|
||||||
|
cy.requestAllTv(305288).then(() => {
|
||||||
|
cy.visit('/vote');
|
||||||
|
cy.get('#completedVotes').click();
|
||||||
|
cy.contains('Stranger Things').should('have.attr', 'data-test').then(($id) => {
|
||||||
|
cy.get('#' + $id + 'upvote').should('have.attr', 'disabled');
|
||||||
|
cy.get('#' + $id + 'downvote').should('not.have.attr', 'disabled');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
|
@ -34,9 +34,12 @@ Cypress.Commands.add('login', (username, password) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
window.localStorage.setItem('id_token', resp.body.access_token)
|
window.localStorage.setItem('id_token', resp.body.access_token);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Cypress.Commands.add('removeLogin', () => {
|
||||||
|
window.localStorage.removeItem('id_token');
|
||||||
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('createUser', (username, password, claims) => {
|
Cypress.Commands.add('createUser', (username, password, claims) => {
|
||||||
cy.request({
|
cy.request({
|
||||||
|
@ -57,3 +60,4 @@ 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)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
|
|
||||||
// Import commands.js using ES2015 syntax:
|
// Import commands.js using ES2015 syntax:
|
||||||
import './commands'
|
import './commands';
|
||||||
|
import './request.commands';
|
||||||
|
|
||||||
// Alternatively you can use CommonJS syntax:
|
// Alternatively you can use CommonJS syntax:
|
||||||
// require('./commands')
|
// require('./commands')
|
||||||
|
|
40
src/Ombi/cypress/support/request.commands.js
Normal file
40
src/Ombi/cypress/support/request.commands.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
Cypress.Commands.add('requestGenericMovie', () => {
|
||||||
|
cy.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/api/v1/request/movie',
|
||||||
|
body: {
|
||||||
|
TheMovieDbId: 299536
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add('requestMovie', (movieId) => {
|
||||||
|
cy.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/api/v1/request/movie',
|
||||||
|
body: {
|
||||||
|
TheMovieDbId: movieId
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Cypress.Commands.add('requestAllTv', (tvId) => {
|
||||||
|
cy.request({
|
||||||
|
method: 'POST',
|
||||||
|
url: '/api/v1/request/tv',
|
||||||
|
body: {
|
||||||
|
TvDbId: tvId,
|
||||||
|
RequestAll: true
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ' + window.localStorage.getItem('id_token'),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue