Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounty Creation Unit Test #1037

Closed
wants to merge 29 commits into from
Closed

Bounty Creation Unit Test #1037

wants to merge 29 commits into from

Conversation

Khaalid-oh
Copy link
Contributor

@Khaalid-oh Khaalid-oh commented Dec 2, 2023

Describe your changes

Issue ticket number and link

Closes #996

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist before requesting a review

  • I have performed a self-review of my code
Screenshot 2023-12-02 at 01 39 01
  • I have tested on Chrome and Firefox
  • I have tested on a mobile device
  • I have provided a screenshot or recording of changes in my PR if there were updates to the frontend
  • Screenshot 2023-12-02 at 01 39 01

@kevkevinpal
Copy link
Contributor

looks like gitactions checks are failing if you can fix

@ecurrencyhodler
Copy link
Contributor

Hey @Khaalid-oh thanks for this PR. It looks like some tests are failing such as prettier, craco, and jest. Can you address those? If you're not familiar with how, you can join our stand up and you cask raph/kev for help.

@Khaalid-oh
Copy link
Contributor Author

Hey @Khaalid-oh thanks for this PR. It looks like some tests are failing such as prettier, craco, and jest. Can you address those? If you're not familiar with how, you can join our stand up and you cask raph/kev for help.

Alright, I'm sure he can help with some of the questions I have. You can set that up

@ecurrencyhodler
Copy link
Contributor

Invited

@kevkevinpal
Copy link
Contributor

kevkevinpal commented Dec 12, 2023

made some updates in 0293310

I think we still need to add some changes but I got started a bit but we still probably need to make some changes let me know what you think @Khaalid-oh

@Khaalid-oh
Copy link
Contributor Author

made some updates in 0293310

I think we still need to add some changes but I got started a bit but we still probably need to make some changes let me know what you think @Khaalid-oh

Looks nice to me, what other changes do you have in mind?

@ecurrencyhodler
Copy link
Contributor

Hey so we are missing two tests from the issue:

  • Get people bounty test
  • Delete bounty

@Khaalid-oh
Copy link
Contributor Author

Khaalid-oh commented Dec 13, 2023

Hey so we are missing two tests from the issue:

  • Get people bounty test
  • Delete bounty

Done ✅

@ecurrencyhodler
Copy link
Contributor

All tests passed. Let's get one more code review

@@ -3,7 +3,7 @@ const externalDockerHosts = ['localhost:23007', 'localhost:23000'];

export function getHost(): string {
const host = window.location.host.includes('localhost') ? 'localhost:5002' : window.location.host;
return host;
return 'people.sphinx.chat';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please change this back, this will also effect the unit tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also for another issue, I'll create a different PR for it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why there is code change for a unit test PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldnt be including a new yarn.lock file

@@ -1428,6 +1428,7 @@ export class MainStore {

async deleteBounty(created: number, owner_pubkey: string): Promise<void> {
const info = uiStore.meInfo as any;
console.log(uiStore.meInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove console.log I think I may have added this on accident

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this, there should be no changes on a unit test PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for another issue raised, I'll create a new PR for this

Comment on lines 11 to 73
// jest.mock('../store/main.ts', () => ({
// get: jest.fn().mockResolvedValue([
// {
// body: {
// assigned_hours: 0,
// assignee: '',
// award: '',
// bounty_expires: '',
// coding_languages: ['Lightning'],
// commitment_fee: 0,
// created: 1702398254,
// deliverables: 'test',
// description: 'test',
// estimated_completion_date: '',
// estimated_session_length: '',
// github_description: false,
// id: 892,
// one_sentence_summary: '',
// org_uuid: 'ck13rgua5fdkhph1po4g',
// owner_id: '03bfe6723c06fb2b7546df1e8ca1a17ae5c504615da32c945425ccbe8d3ca6260d',
// paid: false,
// paid_date: null,
// price: '1',
// show: true,
// ticket_url: '',
// title: 'test',
// tribe: 'None',
// type: 'freelance_job_request',
// updated: '2023-12-12T16:24:14.585187Z',
// wanted_type: 'Mobile development'
// },
// organization: {
// img: 'https://memes.sphinx.chat/public/l-_K9mJatGvz16Ixw1lPHtG9Om8QWtZtiRS_aIQme9c=',
// name: 'test after jwt',
// uuid: 'ck13rgua5fdkhph1po4g'
// },
// person: {
// created: '2021-11-15T19:09:46.356248Z',
// deleted: false,
// description: 'This is the real kevkevin I like to code alot',
// extras: null,
// github_issues: null,
// id: 38,
// img: 'https://memes.sphinx.chat/public/1jPjjDsrwRoBPzahpWjR8QE5DjQ726MsUSrCOjflSmo=',
// last_login: 1702065128,
// new_ticket_time: 0,
// owner_alias: 'kevkevin',
// owner_contact_key:
// 'MIIBCgKCAQEAxtkwpxx8RjdVhgzx4oUYkmJQttvFzwI+lCWYgngMi/4o8OgUF9eVvW8zSY0t9A1KEY2MdEOTGjv9QiesoN7hmkgTdUqDQd1LIsU4vBtwPVWyJs0d6VEdMySN9veN68S7Fu+S20e5gygj17X8cffoEwLNDPi0dsTgojAC/uggE98zJvHmEd/Ob/W3ADQD68DQErCejvqXK2557GtsDNo35iIN9KlOPLRmvG3S/oV4pIyj5Z/6uMEXlok2b/mtvP0E4ClMP77j9QPs7mQarQ03XM0iRC2Ru/Qg/xWBTeqmYv5zfD8hmtzakBVyMSrHNZKZjSnURVNVpFaEXoB4wBqcvQIDAQAB',
// owner_pubkey: '',
// owner_route_hint: '',
// price_to_meet: 21,
// tags: [],
// twitter_confirmed: true,
// unique_name: 'umbreltest',
// unlisted: false,
// updated: '2023-12-04T19:48:05.641056Z',
// uuid: 'cd9dm5ua5fdtsj2c2nbg',
// wanteds: []
// }
// }
// ]),
// }));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should delete this comment

// }));

const mockedApi = api as jest.Mocked<typeof api>;
//const mockedUiStore = uiStore as jest.Mocked<typeof uiStore>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete comment

beforeEach(() => {
window.localStorage.clear();

//window.localStorage.setItem('peopleBounties', JSON.stringify(mockBounties));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete comment

Comment on lines 93 to 96
//it('should save and retrieve bounties from local storage', () => {
// const storedBounties = JSON.parse(window.localStorage.getItem('peopleBounties') || '[]');
// expect(storedBounties).toEqual(mockBounties);
//}, 8000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete comment

});

it('should save a new bounty and persist to localStorage', async () => {
//mockedApi.post.mockResolvedValue({ data: newBounty });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete comment

Comment on lines 124 to 125
//const bounties = JSON.parse(mockLocalStorage.getItem('peopleBounties'));
//expect(window.localStorage.getItem('peopleBounties')).toContainEqual([]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete comment

Comment on lines 132 to 192
const expectedBountyResponse = [
{
body: {
assigned_hours: 0,
assignee: '',
award: '',
bounty_expires: '',
coding_languages: ['Lightning'],
commitment_fee: 0,
created: 1702398254,
deliverables: 'test',
description: 'test',
estimated_completion_date: '',
estimated_session_length: '',
github_description: false,
id: 892,
one_sentence_summary: '',
org_uuid: 'ck13rgua5fdkhph1po4g',
owner_id: '03bfe6723c06fb2b7546df1e8ca1a17ae5c504615da32c945425ccbe8d3ca6260d',
paid: false,
paid_date: null,
price: '1',
show: true,
ticket_url: '',
title: 'test',
tribe: 'None',
type: 'freelance_job_request',
updated: '2023-12-12T16:24:14.585187Z',
wanted_type: 'Mobile development'
},
organization: {
img: 'https://memes.sphinx.chat/public/l-_K9mJatGvz16Ixw1lPHtG9Om8QWtZtiRS_aIQme9c=',
name: 'test after jwt',
uuid: 'ck13rgua5fdkhph1po4g'
},
person: {
created: '2021-11-15T19:09:46.356248Z',
deleted: false,
description: 'This is the real kevkevin I like to code alot',
extras: null,
github_issues: null,
id: 38,
img: 'https://memes.sphinx.chat/public/1jPjjDsrwRoBPzahpWjR8QE5DjQ726MsUSrCOjflSmo=',
last_login: 1702065128,
new_ticket_time: 0,
owner_alias: 'kevkevin',
owner_contact_key:
'MIIBCgKCAQEAxtkwpxx8RjdVhgzx4oUYkmJQttvFzwI+lCWYgngMi/4o8OgUF9eVvW8zSY0t9A1KEY2MdEOTGjv9QiesoN7hmkgTdUqDQd1LIsU4vBtwPVWyJs0d6VEdMySN9veN68S7Fu+S20e5gygj17X8cffoEwLNDPi0dsTgojAC/uggE98zJvHmEd/Ob/W3ADQD68DQErCejvqXK2557GtsDNo35iIN9KlOPLRmvG3S/oV4pIyj5Z/6uMEXlok2b/mtvP0E4ClMP77j9QPs7mQarQ03XM0iRC2Ru/Qg/xWBTeqmYv5zfD8hmtzakBVyMSrHNZKZjSnURVNVpFaEXoB4wBqcvQIDAQAB',
owner_pubkey: '',
owner_route_hint: '',
price_to_meet: 21,
tags: [],
twitter_confirmed: true,
unique_name: 'umbreltest',
unlisted: false,
updated: '2023-12-04T19:48:05.641056Z',
uuid: 'cd9dm5ua5fdtsj2c2nbg',
wanteds: []
}
}
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should move this into the mockBounties.data.ts file

frontend/app/yarn.lock Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this file modifed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the [glitch when moving from a tab on profile to default profile view]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should not be modified in this PR

@Khaalid-oh Khaalid-oh closed this Dec 20, 2023
@Khaalid-oh Khaalid-oh deleted the saif branch December 20, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bounty Creation Unit Test] Create mock data for bounty creation
3 participants