Skip to content

Commit

Permalink
test: fix testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman035 committed Apr 4, 2024
1 parent a12e1be commit ace0f86
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 83 deletions.
1 change: 1 addition & 0 deletions packages/restapi/tests/lib/chat/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('PushAPI.chat functionality', () => {

const userBobReadOnly = await PushAPI.initialize({
account: account,
env,
});

const response = await userBobReadOnly.chat.list('REQUESTS', {
Expand Down
72 changes: 5 additions & 67 deletions packages/restapi/tests/lib/notification/delegate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,65 +105,16 @@ describe('PushAPI.delegate functionality', () => {
});

it('With viem signer: Should add delegate', async () => {
// create polygon mumbai provider
const provider = (ethers as any).providers
? new (ethers as any).providers.JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
)
: new (ethers as any).JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
);
signer2 = new ethers.Wallet(
`0x${process.env['WALLET_PRIVATE_KEY']}`,
provider
);
userKate = await PushAPI.initialize(signer2);
const res = await userKate.channel.delegate.add(
'0x74415Bc4C4Bf4Baecc2DD372426F0a1D016Fa924'
);
console.log(res);
expect(res).not.null;
}, 10000000);

it('With viem signer: Should add delegate', async () => {
// create polygon mumbai provider
const provider = (ethers as any).providers
? new (ethers as any).providers.JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
)
: new (ethers as any).JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
);

signer2 = new ethers.Wallet(
`0x${process.env['WALLET_PRIVATE_KEY']}`,
provider
);
userKate = await PushAPI.initialize(signer2);
const res = await userKate.channel.delegate.add(
const res = await viemUser.channel.delegate.add(
'0x74415Bc4C4Bf4Baecc2DD372426F0a1D016Fa924'
);
console.log(res);
expect(res).not.null;
}, 10000000);

it('With viem signer: Should add delegate', async () => {
// create polygon mumbai provider
const provider = (ethers as any).providers
? new (ethers as any).providers.JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
)
: new (ethers as any).JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
);

signer2 = new ethers.Wallet(
`0x${process.env['WALLET_PRIVATE_KEY']}`,
provider
);
userKate = await PushAPI.initialize(signer2);
const res = await userKate.channel.delegate.add(
'eip155:80001:0x74415Bc4C4Bf4Baecc2DD372426F0a1D016Fa924'
const res = await viemUser.channel.delegate.add(
'eip155:11155111:0x74415Bc4C4Bf4Baecc2DD372426F0a1D016Fa924'
);
// console.log(res);
expect(res).not.null;
Expand Down Expand Up @@ -205,21 +156,8 @@ describe('PushAPI.delegate functionality', () => {
});

it('With viem signer: Should remove delegate', async () => {
// create polygon mumbai provider
const provider = (ethers as any).providers
? new (ethers as any).providers.JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
)
: new (ethers as any).JsonRpcProvider(
'https://rpc-mumbai.maticvigil.com/v1'
);
signer2 = new ethers.Wallet(
`0x${process.env['WALLET_PRIVATE_KEY']}`,
provider
);
userKate = await PushAPI.initialize(signer2);
const res = await userKate.channel.delegate.remove(
'eip155:80001:0x74415Bc4C4Bf4Baecc2DD372426F0a1D016Fa924'
const res = await viemUser.channel.delegate.remove(
'eip155:11155111:0x74415Bc4C4Bf4Baecc2DD372426F0a1D016Fa924'
);
// console.log(res);
expect(res).not.null;
Expand Down
4 changes: 1 addition & 3 deletions packages/restapi/tests/lib/notification/notification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,13 @@ describe('PushAPI.notification functionality', () => {

it('Signer with no account: Should return response', async () => {
const response = await userAlice.notification.subscriptions();
console.log(response);
expect(response).not.null;
});

it('Signer with account: Should return response', async () => {
const response = await userAlice.notification.subscriptions({
account: 'eip155:80001:0xD8634C39BBFd4033c0d3289C4515275102423681',
});
// console.log(response);
expect(response).not.null;
expect(response.length).not.equal(0);
});
Expand All @@ -287,7 +285,7 @@ describe('PushAPI.notification functionality', () => {
const response = await userKate.notification.subscriptions({
account: '0xD8634C39BBFd4033c0d3289C4515275102423681',
raw: false,
channel: "0xD8634C39BBFd4033c0d3289C4515275102423681"
channel: '0xD8634C39BBFd4033c0d3289C4515275102423681',
});
// console.log(JSON.stringify(response));
expect(response).not.null;
Expand Down
20 changes: 10 additions & 10 deletions packages/restapi/tests/lib/progressHook/progressHookData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const PROGRESSHOOK: Record<
progressId: 'PUSH-CREATE-01',
progressTitle: 'Generating Secure Profile Signature',
progressInfo:
'This step is only done for first time users and might take a few seconds. PGP keys are getting generated to provide you with secure yet seamless chat',
'This step is only done for first time users and might take a few seconds. PGP keys are getting generated to provide you with secure yet seamless web3 communication',
level: 'INFO',
},
'PUSH-CREATE-02': {
Expand All @@ -32,7 +32,7 @@ const PROGRESSHOOK: Record<
progressId: 'PUSH-CREATE-04',
progressTitle: 'Syncing Generated Profile',
progressInfo:
'Please sign the message to continue. Steady lads, chat is almost ready!',
'Please sign the message to continue. Great job! You are almost fully onboarded to Push Protocol!',
level: 'INFO',
},
'PUSH-CREATE-05': {
Expand All @@ -58,7 +58,7 @@ const PROGRESSHOOK: Record<
progressId: 'PUSH-UPGRADE-02',
progressTitle: 'Decrypting Old Profile',
progressInfo:
'Trying to Upgrade Push Chat Keys to latest version. Please sign the message to continue.',
'Trying to Upgrade Push Keys to latest version. Please sign the message to continue.',
level: 'INFO',
},
/**
Expand All @@ -83,7 +83,7 @@ const PROGRESSHOOK: Record<
},
'PUSH-UPGRADE-05': {
progressId: 'PUSH-UPGRADE-05',
progressTitle: 'Upgrade Completed, Welcome to Push Chat',
progressTitle: 'Upgrade Completed, Welcome to Push Protocol',
progressInfo: '',
level: 'SUCCESS',
},
Expand All @@ -109,28 +109,28 @@ const PROGRESSHOOK: Record<
return {
progressId: 'PUSH-AUTH-UPDATE-01',
progressTitle: 'Generating New Profile Signature',
progressInfo: `Trying to Update Push Chat Keys to ${pgpEncryptionVersion} version. Please sign the message to continue.`,
progressInfo: `Trying to Update Push Keys to ${pgpEncryptionVersion} version. Please sign the message to continue.`,
level: 'INFO',
};
},
'PUSH-AUTH-UPDATE-02': (pgpEncryptionVersion: string) => {
return {
progressId: 'PUSH-AUTH-UPDATE-02',
progressTitle: 'Generating New Encrypted Profile',
progressInfo: `Encrypting Push Chat Keys with ${pgpEncryptionVersion} version. Please sign the message to continue.`,
progressInfo: `Encrypting Push Keys with ${pgpEncryptionVersion} version. Please sign the message to continue.`,
level: 'INFO',
};
},
'PUSH-AUTH-UPDATE-03': {
progressId: 'PUSH-AUTH-UPDATE-03',
progressTitle: 'Syncing Updated Profile',
progressInfo:
'Please sign the message to continue. Steady lads, chat is almost ready!',
'Please sign the message to continue. Updated keys are almost ready!',
level: 'INFO',
},
'PUSH-AUTH-UPDATE-04': {
progressId: 'PUSH-AUTH-UPDATE-04',
progressTitle: 'Update Completed, Welcome to Push Chat',
progressTitle: 'Update Completed, Welcome to Push Protocol',
progressInfo: '',
level: 'SUCCESS',
},
Expand All @@ -143,7 +143,7 @@ const PROGRESSHOOK: Record<
'PUSH-AUTH-UPDATE-06': {
progressId: 'PUSH-AUTH-UPDATE-06',
progressTitle: 'Generating New Profile Signature',
progressInfo: `Encrypting Push Chat Keys with new creds. Please sign the message to continue.`,
progressInfo: `Encrypting Push Keys with new creds. Please sign the message to continue.`,
level: 'INFO',
},
/**
Expand Down Expand Up @@ -172,7 +172,7 @@ const PROGRESSHOOK: Record<
},
'PUSH-PROFILE-UPDATE-02': {
progressId: 'PUSH-PROFILE-UPDATE-02',
progressTitle: 'Profile Update Completed, Welcome to Push Chat',
progressTitle: 'Profile Update Completed, Welcome to Push Protocol',
progressInfo: '',
level: 'SUCCESS',
},
Expand Down
21 changes: 21 additions & 0 deletions packages/restapi/tests/lib/space/space.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ describe('PushAPI.space', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
});
Expand All @@ -69,6 +72,9 @@ describe('PushAPI.space', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
});
Expand All @@ -95,6 +101,9 @@ describe('PushAPI.space', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
});
Expand Down Expand Up @@ -123,6 +132,9 @@ describe('PushAPI.space', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
});
Expand Down Expand Up @@ -150,6 +162,9 @@ describe('PushAPI.space', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
});
Expand Down Expand Up @@ -182,6 +197,9 @@ describe('PushAPI.space', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
});
Expand Down Expand Up @@ -216,6 +234,9 @@ describe('PushAPI.space', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
});
Expand Down
7 changes: 5 additions & 2 deletions packages/restapi/tests/lib/stream/space.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ describe('PushStream.initialize functionality', () => {
const signer = new ethers.Wallet(WALLET.privateKey, provider);

const userAlice = await PushAPI.initialize(signer, {
env: CONSTANTS.ENV.LOCAL,
env: CONSTANTS.ENV.DEV,
});

const WALLET2 = ethers.Wallet.createRandom();
const signer2 = new ethers.Wallet(WALLET2.privateKey);
const account2 = `eip155:${signer2.address}`;
const userBob = await PushAPI.initialize(signer2, {
env: CONSTANTS.ENV.LOCAL,
env: CONSTANTS.ENV.DEV,
});

const userAliceStream = await userAlice.initStream(
Expand Down Expand Up @@ -59,6 +59,9 @@ describe('PushStream.initialize functionality', () => {
participants: { listeners: [], speakers: [] },
schedule: {
start: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
end: new Date(
new Date().getTime() + 24 * 60 * 60 * 1000 + 60 * 60 * 1000
),
},
private: false,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum ENV {
LOCAL = 'local',
}

const env = ENV.LOCAL;
const env = ENV.DEV;

// Test suite for sendNotification functionality for video calls
describe('sendNotification functionality for video calls', () => {
Expand Down

0 comments on commit ace0f86

Please sign in to comment.