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

chore: remove duplicate tests #907

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/examples/sdk-backend-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@pushprotocol/restapi": "0.0.1-alpha.53",
"@pushprotocol/restapi": "@latest",
"@pushprotocol/socket": "^0.5.2"
}
}
61 changes: 58 additions & 3 deletions packages/restapi/tests/lib/chat/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dotenv.config({ path: path.resolve(__dirname, '../../.env') });
import { PushAPI } from '../../../src/lib/pushapi/PushAPI'; // Ensure correct import path
import { expect } from 'chai';
import { ethers } from 'ethers';
import { MessageType } from '../../../src/lib/constants';
import CONSTANTS from '../../../src/lib/constantsV2';

describe('PushAPI.chat functionality', () => {
let userAlice: PushAPI;
Expand Down Expand Up @@ -38,24 +38,79 @@ describe('PushAPI.chat functionality', () => {
expect(response).to.be.an('array');
expect(response.length).to.equal(1);
});

it('Should list request read only', async () => {
await userAlice.chat.send(account2, { content: MESSAGE });

const account = (await userBob.info()).did;

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

const response = await userBobReadOnly.chat.list('REQUESTS', {
page: 1,
limit: 10,
});
expect(response).to.be.an('array');
expect(response.length).to.equal(1);
});

it('Should list chats ', async () => {
const response = await userAlice.chat.list('CHATS', {
page: 1,
limit: 10,
});
expect(response).to.be.an('array');
});
it('Should list chats read only', async () => {
const account = (await userAlice.info()).did;

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

const response = await userAliceReadOnly.chat.list('CHATS', {
page: 1,
limit: 10,
});
expect(response).to.be.an('array');
});
it('Should send message ', async () => {
const response = await userAlice.chat.send(account2, {
content: 'Hello',
type: MessageType.TEXT,
type: CONSTANTS.CHAT.MESSAGE_TYPE.TEXT,
});
expect(response).to.be.an('object');
});
it('Should send message read only', async () => {
const account = (await userAlice.info()).did;

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

let errorCaught: any = null;

try {
await userAliceReadOnly.chat.send(account2, {
content: 'Hello',
type: CONSTANTS.CHAT.MESSAGE_TYPE.TEXT,
});
} catch (error) {
errorCaught = error;
}

expect(errorCaught).to.be.an('error');
expect(errorCaught.message).to.equal(
'Operation not allowed in read-only mode. Signer is required.'
);
});

it('Should decrypt message ', async () => {
await userAlice.chat.send(account2, {
content: 'Hello',
type: MessageType.TEXT,
type: CONSTANTS.CHAT.MESSAGE_TYPE.TEXT,
});
const messagePayloads = await userAlice.chat.history(account2);
const decryptedMessagePayloads = await userBob.chat.decrypt(
Expand Down
121 changes: 0 additions & 121 deletions packages/restapi/tests/lib/pushapi/chat.test.ts

This file was deleted.

Loading