Skip to content

Commit

Permalink
Fixed issue in test graphql query
Browse files Browse the repository at this point in the history
Added some tests
  • Loading branch information
aminlatifi committed Dec 13, 2023
1 parent d516e86 commit 1caa8ef
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/entities/projectAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ProjectAddress extends BaseEntity {
@Column()
networkId: number;

@Field()
@Field(type => String)
@Column({
type: 'enum',
enum: ChainType,
Expand Down
44 changes: 42 additions & 2 deletions src/resolvers/projectResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3812,7 +3812,7 @@ function addRecipientAddressToProjectTestCases() {
SEED_DATA.DAI_SMART_CONTRACT_ADDRESS,
);
});
it('Should add address successfully', async () => {
it('Should add address successfully - EVM', async () => {
const user = await saveUserDirectlyToDb(generateRandomEtheriumAddress());
const accessToken = await generateTestAccessToken(user.id);
const project = await saveProjectDirectlyToDb({
Expand Down Expand Up @@ -3841,7 +3841,46 @@ function addRecipientAddressToProjectTestCases() {
assert.isOk(response.data.data.addRecipientAddressToProject);
assert.isOk(
response.data.data.addRecipientAddressToProject.addresses.find(
projectAddress => projectAddress.address === newWalletAddress,
projectAddress =>
projectAddress.address === newWalletAddress &&
projectAddress.chainType === ChainType.EVM,
),
);
});

it('Should add address successfully - EVM', async () => {
const user = await saveUserDirectlyToDb(generateRandomEtheriumAddress());
const accessToken = await generateTestAccessToken(user.id);
const project = await saveProjectDirectlyToDb({
...createProjectData(),
admin: String(user.id),
});
const newWalletAddress = generateRandomSolanaAddress();

const response = await axios.post(
graphqlUrl,
{
query: addRecipientAddressToProjectQuery,
variables: {
projectId: project.id,
networkId: 0,
address: newWalletAddress,
chainType: ChainType.SOLANA,
},
},
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
},
);
// assert.equal(JSON.stringify(response.data, null, 4), 'hi');
assert.isOk(response.data.data.addRecipientAddressToProject);
assert.isOk(
response.data.data.addRecipientAddressToProject.addresses.find(
projectAddress =>
projectAddress.address === newWalletAddress &&
projectAddress.chainType === ChainType.SOLANA,
),
);
});
Expand Down Expand Up @@ -3940,6 +3979,7 @@ function addRecipientAddressToProjectTestCases() {
projectId: project.id,
networkId: NETWORK_IDS.POLYGON,
address: newWalletAddress,
chainType: ChainType.EVM,
},
},
{
Expand Down
6 changes: 3 additions & 3 deletions test/graphqlQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export const updateProjectQuery = `
`;

export const addRecipientAddressToProjectQuery = `
mutation ($projectId: Float!, $networkId: Float!, $address: String!) {
addRecipientAddressToProject(projectId: $projectId, networkId: $networkId, address: $address) {
mutation ($projectId: Float!, $networkId: Float!, $address: String!, $chainType: ChainType) {
addRecipientAddressToProject(projectId: $projectId, networkId: $networkId, address: $address, chainType: $chainType) {
id
title
description
Expand Down Expand Up @@ -1365,7 +1365,7 @@ export const projectByIdQuery = `
address
isRecipient
networkId
chaintype
chainType
}
organization {
name
Expand Down

0 comments on commit 1caa8ef

Please sign in to comment.