-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix gitcoin bugs, add query tests and update .envs
- Loading branch information
Showing
7 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,78 @@ import { | |
SEED_DATA, | ||
} from '../../test/testUtils'; | ||
import axios from 'axios'; | ||
import { updateUser, userByAddress } from '../../test/graphqlQueries'; | ||
import { | ||
refreshUserScores, | ||
updateUser, | ||
userByAddress, | ||
} from '../../test/graphqlQueries'; | ||
import { assert } from 'chai'; | ||
import { errorMessages } from '../utils/errorMessages'; | ||
import { insertSinglePowerBoosting } from '../repositories/powerBoostingRepository'; | ||
import { create } from 'domain'; | ||
import { DONATION_STATUS } from '../entities/donation'; | ||
import { getGitcoinAdapter } from '../adapters/adaptersFactory'; | ||
|
||
describe('updateUser() test cases', updateUserTestCases); | ||
describe('userByAddress() test cases', userByAddressTestCases); | ||
describe('refreshUserScores() test cases', refreshUserScoresTestCases); | ||
// TODO I think we can delete addUserVerification query | ||
// describe('addUserVerification() test cases', addUserVerificationTestCases); | ||
function refreshUserScoresTestCases() { | ||
it('should refresh user scores if the user has registered passport', async () => { | ||
const userData = { | ||
firstName: 'firstName', | ||
lastName: 'lastName', | ||
email: '[email protected]', | ||
avatar: 'pinata address', | ||
url: 'website url', | ||
loginType: 'wallet', | ||
walletAddress: generateRandomEtheriumAddress(), | ||
}; | ||
const user = await User.create(userData).save(); | ||
await getGitcoinAdapter().submitPassport({ | ||
address: userData.walletAddress, | ||
scorer: '200', | ||
signature: 'any', | ||
nonce: 'any', | ||
}); | ||
const result = await axios.post(graphqlUrl, { | ||
query: refreshUserScores, | ||
variables: { | ||
address: userData.walletAddress, | ||
}, | ||
}); | ||
|
||
const updatedUser = result.data.data.refreshUserScores; | ||
assert.equal(updatedUser.walletAddress, user.walletAddress); | ||
assert.isTrue(updatedUser.passportScore > 0); | ||
assert.isTrue(updatedUser.passportStamps > 0); | ||
}); | ||
it('should not refresh user scores if not registered to gitcoin', async () => { | ||
const userData = { | ||
firstName: 'firstName', | ||
lastName: 'lastName', | ||
email: '[email protected]', | ||
avatar: 'pinata address', | ||
url: 'website url', | ||
loginType: 'wallet', | ||
walletAddress: generateRandomEtheriumAddress(), | ||
}; | ||
const user = await User.create(userData).save(); | ||
const result = await axios.post(graphqlUrl, { | ||
query: refreshUserScores, | ||
variables: { | ||
address: userData.walletAddress, | ||
}, | ||
}); | ||
|
||
const updatedUser = result.data.data.refreshUserScores; | ||
assert.equal(updatedUser.walletAddress, user.walletAddress); | ||
// if score remains null the user has not registered | ||
assert.isNull(updatedUser.passportScore); | ||
assert.equal(updatedUser.passportStamps, 0); | ||
}); | ||
} | ||
|
||
function userByAddressTestCases() { | ||
it('Get non-sensitive fields of a user', async () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters