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

928 bug failing testcases related to channel and notifications #960

Merged

Conversation

akp111
Copy link
Collaborator

@akp111 akp111 commented Dec 21, 2023

Fixes Issue

Fixes testcases

Changes proposed

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

Screenshots

Note to reviewers

mohammeds1992 and others added 30 commits July 14, 2023 15:34
* fix: signer compatibility with viem and ethers

* fix: revert space changes
@akp111 akp111 requested a review from Aman035 December 21, 2023 15:35
@akp111 akp111 linked an issue Dec 21, 2023 that may be closed by this pull request
Copy link

All looks good.

Copy link

File: packages/restapi/tests/lib/channel/subscribeV2.test.ts

  1. There is a missing closing parenthesis for the first it block. It should be added at the end of the block.

  2. There is a commented out console.log(res) statement that should be removed.

  3. The second it block for unsubscribing has incomplete code. It should be completed with the necessary parameters and assertions.

  4. There are commented out blocks of code that are not necessary and should be removed.

  5. The third it block for subscribing with settings is commented out. If it's intended to be skipped, it should be marked as a skipped test using it.skip instead of commenting out the code.

File: packages/restapi/tests/lib/notification/channel.test.ts

  1. The first it block for sending notifications has a missing closing parenthesis for the PUSH_CHANNEL.unsubscribeV2 function. It should be added at the end of the block.

  2. There is a commented out console.log(res) statement that should be removed.

  3. The second it block for sending notifications with signer and channel should be completed with the necessary parameters and assertions.

  4. The third it block for sending notifications with signer, subset, and additional options has incomplete code. It should be completed with the necessary parameters and assertions.

  5. The fourth it block for sending notifications with signer, subset, and additional options is skipped. If it's intended to be skipped, it should be marked as a skipped test using it.skip instead of commenting out the code.

  6. The fifth it block for sending notifications with simulated signer and title/body has incomplete code. It should be completed with the necessary parameters and assertions.

  7. The describe.skip block for updating channel meta has a missing closing parenthesis for the userKate.channel.update function. It should be added at the end of the block.

  8. The describe.skip block for creating channel has a missing closing parenthesis for the userKate.channel.create function. It should be added at the end of the block.

  9. The describe block for channel settings has incomplete code. It should be completed with the necessary parameters and assertions.

File: packages/restapi/tests/lib/notification/notification.test.ts

  1. The first import statement for PushAPI has a wrong import path. It should be corrected to import { PushAPI } from '../../../src/lib/notification/PushAPI';

  2. The describe.only block for PushAPI.notification functionality can be changed to describe to include all test cases.

  3. There are several commented out blocks of code that are not necessary and should be removed.

  4. The second describe block for PushAPI.notification functionality has duplicate it blocks. The duplicates should be removed.

  5. The second it block for returning feeds with signer object is missing a closing parenthesis. It should be added at the end of the block.

  6. The third it block for returning feeds with signer object and account passed is missing a closing parenthesis. It should be added at the end of the block.

  7. The fourth it block for returning feeds without signer object and account passed is missing a closing parenthesis. It should be added at the end of the block.

  8. The fifth it block for throwing an error without signer object and account not passed is skipped. If it's intended to be skipped, it should be marked as a skipped test using it.skip instead of commenting out the code.

  9. The sixth it block for returning feeds with signer with provider is missing a closing parenthesis. It should be added at the end of the block.

  10. The seventh it block for returning feeds with viem is missing a closing parenthesis. It should be added at the end of the block.

  11. The eighth it block for returning feeds with userKate and specific channels is missing a closing parenthesis. It should be added at the end of the block.

  12. The describe.skip block for notification :: subscribe has incomplete code. It should be completed with the necessary parameters and assertions.

Note: There may be other logical or functional issues in the code that cannot be identified through a code review. It's recommended to thoroughly test the code to ensure its correctness.

Copy link

File: packages/restapi/tests/lib/channel/subscribeV2.test.ts

  1. Move the import statement for chai to the top, before the import statement for ethers.
  2. Add a closing bracket } after the line expect(res.status).to.be.equal(204);

File: packages/restapi/tests/lib/notification/channel.test.ts

  1. Remove the trailing comma after the closing curly brace } in the call to userAlice.channel.send().
  2. Remove the it.skip line that is commented out.

File: packages/restapi/tests/lib/notification/notification.test.ts

  1. Remove the commented out code block in the notification :: subscribe describe block.
  2. Remove the it.skip line that is commented out.

@Aman035
Copy link
Member

Aman035 commented Dec 22, 2023

Screenshot 2023-12-22 at 2 06 46 PM Hey @akp111 still these 3 tc fails for me ENV - stage Let me know if any changes are to be made to .env

Copy link

File: packages/restapi/tests/lib/channel/subscribeV2.test.ts

import * as path from 'path';
import * as dotenv from 'dotenv';

dotenv.config({ path: path.resolve(__dirname, '../../.env') });

import * as PUSH_CHANNEL from '../../../src/lib/channels/';
import { expect } from 'chai';
import { ethers } from 'ethers';
import CONSTANTS from '../../../src/lib/constantsV2';

describe('PUSH_CHANNEL.subscribeV2 functionality', () => {
let signer1: any;
let account1: string;
let signer2: any;
let account2: string;

beforeEach(async () => {
const WALLET1 = ethers.Wallet.createRandom();
signer1 = new ethers.Wallet(WALLET1.privateKey);
account1 = WALLET1.address;

const WALLET2 = ethers.Wallet.createRandom();
signer2 = new ethers.Wallet(WALLET2.privateKey);
account2 = WALLET2.address;

});

it('Should subscribe to the channel via V2 without settings', async () => {
const res = await PUSH_CHANNEL.subscribeV2({
signer: signer1,
channelAddress: 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
userAddress: eip155:11155111:${account1},
env: CONSTANTS.ENV.STAGING,
});

expect(res.status).to.be.equal(204);

});

it('Should unsubscribe to the channel via V2 without settings', async () => {
const res = await PUSH_CHANNEL.unsubscribeV2({
signer: signer1,
channelAddress: 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
userAddress: eip155:11155111:${account1},
env: CONSTANTS.ENV.STAGING,
});

expect(res.status).to.be.equal(204);

});
});

File: packages/restapi/tests/lib/notification/channel.test.ts

...
'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
'eip155:11155111:0x93A829d16DE51745Db0530A0F8E8A9B8CA5370E5',
],
{
notification: {
title: 'hi',
body: 'test-targeted',
},
payload: {
title: 'testing first notification',
body: 'testing with random body',
cta: 'https://google.com/',
embed: 'https://avatars.githubusercontent.com/u/64157541?s=200&v=4',
category: 3,
}
}
);

  expect(res.status).to.equal(204);
});

it('With signer : subset  : Should send notification with title and body along with additional options', async () => {
  const res = await userAlice.channel.send(
    [
      {
        body: 'test-subset',
        title: 'testing first subset notification',
      },
      'eip155:97:0xD8634C39BBFd4033c0d3289C4515275102423681',
      'eip155:97:0x93A829d16DE51745Db0530A0F8E8A9B8CA5370E5',
      {
        channel: `eip155:97:${account2}`,
      },
      1,
      'fallback-subset-12',
    ]
  );

  expect(res.status).to.equal(204);
});

it.skip('With signer : subset  : Should send notification with title and body along with additional options for alias', async () => {
  const res = await userAlice.channel.send(
    [
      {
        body: 'test-subset',
        title: 'testing first subset notification',
      },
      'eip155:80001:0xC8c243a4fd7F34c49901fe441958953402b7C024',
      'eip155:80001:0x93A829d16DE51745Db0530A0F8E8A9B8CA5370E5',
      {
        channel: `eip155:80001:${account2}`,
      },
      1,
      'fallback-subset-12',
    ]
  );

  expect(res.status).to.equal(204);
});

});
// ...

File: packages/restapi/tests/lib/notification/notification.test.ts

...
userViem = await PushAPI.initialize(viemSigner);
});

describe('PushAPI.notification functionality', () => {
it('Should return feeds with signer object', async () => {
const response = await userAlice.notification.list('SPAM');
expect(response).not.null;
});

it('Should return feeds with signer object when an account is passed', async () => {
  const response = await userAlice.notification.list('SPAM', {
    account: 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
  });

  expect(response).not.null;
});

it('Should return feeds without signer object when an account is passed', async () => {
  const response = await userBob.notification.list('SPAM', {
    account: 'eip155:11155111:0xD8634C39BBFd4033c0d3289C4515275102423681',
  });

  expect(response).not.null;
});

it.skip('Should throw error without signer object when an account is not passed', async () => {
  await expect(() => userBob.notification.list('SPAM')).to.Throw;
});

it('Should return feeds when signer with provider is used', async () => {
  const response = await userKate.notification.list('SPAM');
  expect(response).not.null;
  const responseWithAccount = await userKate.notification.list('SPAM', {
    account: "0xD8634C39BBFd4033c0d3289C4515275102423681"
  });

  expect(responseWithAccount).not.null;
});

it('Should return feeds when viem is used', async () => {
  const response = await userViem.notification.list('SPAM');
  expect(response).not.null;
  const responseWithChannels = await userKate.notification.list('INBOX', {
    channels: ['0xD8634C39BBFd4033c0d3289C4515275102423681'],
    raw: true,
  });

  expect(responseWithChannels).not.null;
});

});

// ...

@Aman035 Aman035 merged commit 334420c into main Jan 2, 2024
1 check passed
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.

🐛 [BUG] - Failing Testcases related to channel and notifications
7 participants