Skip to content

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fvalentiner committed May 21, 2024
1 parent c62c9ca commit f775955
Show file tree
Hide file tree
Showing 2 changed files with 290 additions and 27 deletions.
124 changes: 116 additions & 8 deletions cypress/e2e/07_add_bounty_to_phase.cy.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,129 @@
import { User, HostName, Bounties } from '../support/objects/objects';
import { User, HostName, Phases, Bounties } from '../support/objects/objects';


describe('Create Bounty', () => {
//This test passes! It only asserts that response contains workspace_uuid
describe('Create Bounties - don\'t check phase_uuid', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for (let i = 0; i <= 2; i++) {
for (let i = 0; i < Bounties.length; i++) {
cy.request({
method: 'POST',
url: `${HostName}/gobounties/`,
headers: { 'x-jwt': `${value}` },
body: Bounties[i],
failOnStatusCode: false
})//.its('body').should('have.property', 'id', Workspaces[i].name.trim())
.then(value => {
console.log(value);
});
}).then((resp) => {
expect(resp.status).to.eq(200);
expect(resp.body).to.have.property('workspace_uuid').and.equal(Bounties[i].workspace_uuid);
console.log(resp);
})
}
})
})
})
});

//This test initially does not pass! It asserts that the response should contain phase_uuid
//You need to add phase_uuid to bounties
describe('Create Bounties - with check phase_uuid', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for (let i = 0; i < Bounties.length; i++) {
cy.request({
method: 'POST',
url: `${HostName}/gobounties/`,
headers: { 'x-jwt': `${value}` },
body: Bounties[i],
failOnStatusCode: false
}).then((resp) => {
expect(resp.status).to.eq(200);
expect(resp.body).to.have.property('phase_uuid').and.equal(Bounties[i].phase_uuid);
console.log(resp);
})
}
})
})
});


//This test passes! It only asserts that response contains workspace_uuid
describe('Get All Bounties - don\'t check phase_uuid', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
cy.request({
method: 'GET',
url: `${HostName}/gobounties/all?limit=10&sortBy=created&search=&page=1&resetPage=true&Open=true&Assigned=false&Completed=false&Paid=false&languages=`,
headers: { 'x-jwt': `${value}` },
failOnStatusCode: false
}).then((resp) => {
expect(resp.status).to.eq(200);
JSON.parse(resp.body).forEach((bounty) => {
expect(bounty).to.have.property('bounty').to.have.property('workspace_uuid');
})
})
})
})
});

//This test initially does not pass! It asserts that the response should contain phase_uuid
//You need to add phase_uuid to bounties
describe('Get All Bounties - check phase_uuid', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
cy.request({
method: 'GET',
url: `${HostName}/gobounties/all?limit=10&sortBy=created&search=&page=1&resetPage=true&Open=true&Assigned=false&Completed=false&Paid=false&languages=`,
headers: { 'x-jwt': `${value}` },
//body: Bounties[i],
failOnStatusCode: false
}).then((resp) => {
expect(resp.status).to.eq(200);
JSON.parse(resp.body).forEach((bounty) => {
expect(bounty).to.have.property('bounty').to.have.property('phase_uuid');
})
})
})
})
});

//This test initially does not pass! It asserts that the response should contain phase_uuid
//You need to create the endpoint in /handlers/features.go and the route in /routes/features.go
describe('Get Bounties for Phase', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
cy.request({
method: 'GET',
url: `${HostName}${HostName}/features/${Phases[0].feature_uuid}/phase/${Phases[0].feature_uuid}/bounty`,
headers: { 'x-jwt': `${value}` },
//body: Bounties[i],
failOnStatusCode: false
}).then((resp) => {
expect(resp.status).to.eq(200);
JSON.parse(resp.body).forEach((bounty) => {
expect(bounty).to.have.property('bounty').to.have.property('phase_uuid');
})
})
})
})
});

//This test initially does not pass! It asserts that the endpoint should not receive a phase_uuid that doesn't exist
describe('Create Bounties with wrong phase_uuid', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
cy.request({
method: 'POST',
url: `${HostName}/gobounties/`,
headers: { 'x-jwt': `${value}` },
body: {...Bounties[0], phase_uuid: 'cp68lagn1e462l489mu0'}, //phase_uuid does not exist
failOnStatusCode: false
}).then((resp) => {
expect(resp.status).to.eq(400);
})
})
})
});





193 changes: 174 additions & 19 deletions cypress/support/objects/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,36 +144,191 @@ export const Phases = [
];

export const Bounties = [
{
owner_id: 'alice',
paid: false,
show: true,
completed: false,
type: 'bug',
award: '1000 USD',
assigned_hours: 5,
bounty_expires: '2024-06-01T00:00:00Z',
commitment_fee: 1000,
price: 21,
title: 'Phase 1 Bounty 1',
ticket_url: 'http://ticket.url',
workspace_uuid: 'workspace-uuid-123',
phase_uuid: Phases[0].uuid,
description: 'Detailed bug description',
wanted_type: 'Bugfix',
deliverables: 'Bug should be fixed',
github_description: true,
one_sentence_summary: 'Fix bug in production',
estimated_session_length: '2 hours',
estimated_completion_date: '2024-05-25T00:00:00Z',
created: Date.now(),
coding_languages: ['JavaScript', 'Python']
},
{
id: 0,
owner_id: 'alice',
paid: false,
show: true,
completed: false,
type: 'freelance_job_request',
award: '',
assigned_hours: 2,
bounty_expires: '2024-06-01T00:00:00Z',
commitment_fee: 0,
price: 21,
title: 'Phase 1 Bounty 2',
tribe: '',
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
description: 'detailed bounty description',
wanted_type: 'Web development',
deliverables: '',
github_description: true,
one_sentence_summary: '',
estimated_session_length: 'Less than 3 hours',
estimated_completion_date: '2024-05-25T00:00:00Z',
coding_languages: ['Golang'],
},
{
id: 0,
owner_id: 'alice',
paid: false,
show: true,
completed: false,
type: 'freelance_job_request',
award: '',
assigned_hours: 2,
bounty_expires: '2024-06-01T00:00:00Z',
commitment_fee: 0,
price: 21,
title: 'Phase 1 Bounty 3',
tribe: '',
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
description: 'detailed bounty description',
wanted_type: 'Web development',
deliverables: '',
github_description: true,
one_sentence_summary: '',
estimated_session_length: 'Less than 3 hours',
estimated_completion_date: '2024-05-25T00:00:00Z',
coding_languages: ['Golang'],
},
{
id: 0,
owner_id: 'alice',
paid: false,
show: true,
completed: false,
type: 'freelance_job_request',
award: '',
assigned_hours: 2,
bounty_expires: '2024-06-01T00:00:00Z',
commitment_fee: 0,
price: 21,
title: 'Phase 1 Bounty 4',
tribe: '',
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
description: 'detailed bounty description',
wanted_type: 'Web development',
deliverables: '',
github_description: true,
one_sentence_summary: '',
estimated_session_length: 'Less than 3 hours',
estimated_completion_date: '2024-05-25T00:00:00Z',
coding_languages: ['Golang'],
},
{
id: 0,
owner_id: 'alice',
paid: false,
show: true,
completed: false,
type: 'freelance_job_request',
award: '',
assigned_hours: 2,
bounty_expires: '2024-06-01T00:00:00Z',
commitment_fee: 0,
price: 21,
title: 'Phase 1 Bounty 5',
tribe: '',
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
description: 'detailed bounty description',
wanted_type: 'Web development',
deliverables: '',
github_description: true,
one_sentence_summary: '',
estimated_session_length: 'Less than 3 hours',
estimated_completion_date: '2024-05-25T00:00:00Z',
coding_languages: ['Golang'],
},
{
id: 0,
owner_id: 'alice',
paid: false,
show: true,
completed: false,
type: 'freelance_job_request',
award: '',
assigned_hours: 2,
bounty_expires: '2024-06-01T00:00:00Z',
commitment_fee: 0,
price: 21,
title: 'Phase 2 Bounty 1',
tribe: '',
assignee: '',
ticket_url: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[0].uuid,
description: 'detailed bounty description',
wanted_type: 'Web development',
deliverables: '',
github_description: true,
one_sentence_summary: '',
estimated_session_length: 'Less than 3 hours',
estimated_completion_date: '2024-05-25T00:00:00Z',
coding_languages: ['Golang'],
},
{
id: 0,
owner_id: '',
owner_id: 'alice',
paid: false,
show: true,
completed: false,
type: '', //TODO find out more
award: '', //TODO find out more
type: 'freelance_job_request',
award: '',
assigned_hours: 2,
bounty_expires: '',
commitment_fee: 0, //TODO find out more
bounty_expires: '2024-06-01T00:00:00Z',
commitment_fee: 0,
price: 21,
title: 'Add Features endpoints',
title: 'Phase 2 Bounty 2',
tribe: '',
assignee: '',
ticket_url: '',
workspace_id: Workspaces[0],
description: '',
wanted_type: '', //TODO find out more
deliverables: '', //TODO find out more
github_description: '',
workspace_uuid: Workspaces[0].uuid,
phase_uuid: Phases[1].uuid,
description: 'detailed bounty description',
wanted_type: 'Web development',
deliverables: '',
github_description: true,
one_sentence_summary: '',
estimated_session_length: '', //TODO find out more
estimated_completion_date: '2024-05-31',
created: '',
updated: '',
assigned_date: '',
completion_date: '',
mark_as_paid_date: '',
paid_date: '',
estimated_session_length: 'Less than 3 hours',
estimated_completion_date: '2024-05-25T00:00:00Z',
coding_languages: ['Golang'],
},
]

0 comments on commit f775955

Please sign in to comment.