* Feature 🚀 : Ability to delete messages in chat channels - Sending message ID to frontend - Deleting Message - Use pusher to delete message realtime * Minor Bug 🐞: Show message action only for current user - User can delete or edit their own messages * Test cases added * Bug 🐞: Update message id for receiver Message id was not sent to receiver by pusher * Refactoring🛠: Message controller refactoring * Test Cases📝 : Specs for Delete message added * Feature 🚀 : Ability to edit messages * Test Cases📝 : Specs for Edit message added * added new column discoverable for public channel and changes in elasticsearch * fix corrections * changes in serializer file, added channel_discoverable * added checkbox with discoverable policy * changes in code for discoverable channels * accept and reject member invitation by mod * add joining request to closed groups * fixed merge error * changes in joining member to closed groups * join to closed group * changes in message action of joining * changes in chat upopened json * 🚀Feature : Ability to search Global Channels * touch updated_at in after commit update * 🚀Feature : Ability to send request to discoverable channel * 🚀Feature : Ability to send request to discoverable channel * created new route for joining closed channel * 🚀 Success handle on joining request sent * removed redundant code * join_channel improvement, removed authorization for join channel * list of joining requests * added joining_request status channels on search list * changes in mailer and query builder optimized * 🛠 Adding filter for new Query * added rspec for add membership method in controller * rspec for sending join channel request * invite join request channel list rspec * test case for query builder discoverable * viewable and discoverable channel list * refactored logic for search channels * 🚀 Check if Request already sent * 🛠 Optimizing code and making channelButton Component * 🛠 Optimizing codefor SVG problem * 🛠 Optimized action.js * changes in search controller query * hot fix * removed unwanted code * 🛠 Fix the Channel Name problem * 🛠 Optimizing code further for CodeClimate * added new column discoverable for public channel and changes in elasticsearch * fix corrections * changes in serializer file, added channel_discoverable * added checkbox with discoverable policy * changes in code for discoverable channels * accept and reject member invitation by mod * add joining request to closed groups * fixed merge error * changes in joining member to closed groups * join to closed group * changes in message action of joining * changes in chat upopened json * touch updated_at in after commit update * 🚀Feature : Ability to search Global Channels * 🚀Feature : Ability to send request to discoverable channel * 🚀Feature : Ability to send request to discoverable channel * created new route for joining closed channel * 🚀 Success handle on joining request sent * removed redundant code * join_channel improvement, removed authorization for join channel * list of joining requests * added joining_request status channels on search list * changes in mailer and query builder optimized * added rspec for add membership method in controller * rspec for sending join channel request * invite join request channel list rspec * 🛠 Adding filter for new Query * test case for query builder discoverable * viewable and discoverable channel list * refactored logic for search channels * 🚀 Check if Request already sent * 🛠 Optimizing code and making channelButton Component * 🛠 Optimizing codefor SVG problem * 🛠 Optimized action.js * changes in search controller query * hot fix * 🛠 Fix the Channel Name problem * 🛠 Fixing merge problem * 🛠 Optimizing code further for CodeClimate * updated UI for membership edit * fixed test casses and fixed UI for chat_channel_edit * 🛠napshots added * test cases fixed * 🛠 Test cases added for new component * channel settings accesible only by mod * 🛠 More Test cases added * 🛠 Svg code optimized * 🛠 Svg code optimized in videocontent * optimized code for search query * fix test case for query builder * changes in joining closed channel logic * refactored join channel * redirect to edit channel after joining request * changes in test case for redirect * optimized code * 🛠 Eslint bugs fixed * test case fixed * optimization * olving channel repetition problem * optimization of code for query builder * changes in query builder * test cases fixed * 🛠 Handling reduntant data on frontend * 🛠 Don't show data if no filter query * 🛠 Optimized code for fixing bugs and code coverage * 🛠 Optimizing code further for CodeClimate Co-authored-by: Parasgr-code <paras.gaur@skynox.tech>
207 lines
6.3 KiB
JavaScript
207 lines
6.3 KiB
JavaScript
import { h } from 'preact';
|
|
import render from 'preact-render-to-json';
|
|
import { shallow } from 'preact-render-spy';
|
|
import { JSDOM } from 'jsdom';
|
|
import Channels from '../channels';
|
|
|
|
const doc = new JSDOM('<!doctype html><html><body></body></html>');
|
|
global.document = doc;
|
|
global.window = doc.defaultView;
|
|
global.window.currentUser = { id: 'fake_username' };
|
|
|
|
let channelSwitched = false;
|
|
|
|
const fakeSwitchChannel = () => {
|
|
channelSwitched = !channelSwitched;
|
|
};
|
|
|
|
const fakeChannels = [
|
|
{
|
|
channel_name: 'channel name 1',
|
|
last_opened_at: 'September 2, 2018',
|
|
channel_users: [],
|
|
last_message_at: 'September 21, 2018',
|
|
channel_type: 'group',
|
|
slug: '0',
|
|
channel_modified_slug: '@0',
|
|
id: 12345,
|
|
status: 'active',
|
|
messages_count: 124,
|
|
},
|
|
{
|
|
channel_name: 'group channel 2',
|
|
status: 'active',
|
|
last_opened_at: 'September 12, 2018',
|
|
channel_users: [
|
|
{
|
|
profile_image: 'fake_profile_image',
|
|
darker_color: '#111111',
|
|
last_opened_at: 'some last open date',
|
|
},
|
|
{
|
|
profile_image: 'fake_profile_pic',
|
|
darker_color: '#222222',
|
|
last_opened_at: 'some other last open date',
|
|
},
|
|
],
|
|
last_message_at: 'September 14, 2018',
|
|
channel_type: 'direct',
|
|
slug: '1',
|
|
channel_modified_slug: '@1',
|
|
id: 12345,
|
|
messages_count: 83,
|
|
},
|
|
{
|
|
channel_name: 'group channel 3',
|
|
last_opened_at: 'September 30, 2018',
|
|
channel_users: [
|
|
{
|
|
profile_image: 'fake_profile_image',
|
|
darker_color: '#111111',
|
|
last_opened_at: 'some last open date',
|
|
},
|
|
{
|
|
profile_image: 'fake_profile_pic',
|
|
darker_color: '#222222',
|
|
last_opened_at: 'some other last open date',
|
|
},
|
|
],
|
|
last_message_at: 'September 29, 2018',
|
|
channel_type: 'group',
|
|
status: 'active',
|
|
slug: '2',
|
|
channel_modified_slug: '@2',
|
|
id: 67890,
|
|
messages_count: 56,
|
|
},
|
|
];
|
|
|
|
const getChannels = (mod, chatChannels) => (
|
|
<Channels
|
|
incomingVideoCallChannelIds={[]} // no incoming calls
|
|
activeChannelId={12345}
|
|
chatChannels={chatChannels}
|
|
unopenedChannelIds={[]}
|
|
handleSwitchChannel={fakeSwitchChannel}
|
|
channelsLoaded
|
|
filterQuery=""
|
|
expanded={mod}
|
|
/>
|
|
);
|
|
|
|
describe('<Channels />', () => {
|
|
describe('expanded', () => {
|
|
describe('with chat channels', () => {
|
|
it('should render and test snapshot', () => {
|
|
const tree = render(getChannels(true, fakeChannels));
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should have the proper elements, attributes, and content', () => {
|
|
const context = shallow(getChannels(true, fakeChannels));
|
|
|
|
// configFooter should exist
|
|
expect(context.find('.chatchannels__config').exists()).toEqual(true);
|
|
expect(context.find('.chatchannels__configmenu').exists()).toEqual(
|
|
true,
|
|
);
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(0).text(),
|
|
).toEqual('DEV Settings');
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(0).attr('href'),
|
|
).toEqual('/settings');
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(1).text(),
|
|
).toEqual('Report Abuse');
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(1).attr('href'),
|
|
).toEqual('/report-abuse');
|
|
|
|
// welcome message should not exist because there are channels
|
|
expect(
|
|
context.find('.chatchannels__channelslistheader').exists(),
|
|
).toEqual(false);
|
|
});
|
|
});
|
|
|
|
describe('without chat channels', () => {
|
|
it('should render and test snapshot', () => {
|
|
const tree = render(getChannels(true, []));
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should have the proper elements, attributes, and content', () => {
|
|
const context = shallow(getChannels(true, []));
|
|
|
|
// should show "Welcome to DEV Connect message....."
|
|
expect(
|
|
context.find('.chatchannels__channelslistheader').exists(),
|
|
).toEqual(true);
|
|
expect(
|
|
context.find('.chatchannels__channelslistheader').text(),
|
|
).toEqual(
|
|
'👋 Welcome to DEV Connect! You may message anyone you mutually follow.',
|
|
);
|
|
|
|
expect(context.find('.chatchannels__config').exists()).toEqual(true);
|
|
expect(context.find('.chatchannels__configmenu').exists()).toEqual(
|
|
true,
|
|
);
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(0).text(),
|
|
).toEqual('DEV Settings');
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(0).attr('href'),
|
|
).toEqual('/settings');
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(1).text(),
|
|
).toEqual('Report Abuse');
|
|
expect(
|
|
context.find('.chatchannels__configmenu').childAt(1).attr('href'),
|
|
).toEqual('/report-abuse');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('not expanded', () => {
|
|
describe('with chat channels', () => {
|
|
it('should render and test snapshot', () => {
|
|
const tree = render(getChannels(false, fakeChannels));
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should have the proper elements, attributes, and content', () => {
|
|
const context = shallow(getChannels(false, fakeChannels));
|
|
|
|
// should have group names but no user names
|
|
expect(context.find('.chatchannels__channelslist').exists()).toEqual(
|
|
true,
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('without chat channels', () => {
|
|
it('should render and test snapshot', () => {
|
|
const tree = render(getChannels(false, []));
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should have the proper elements, attributes, and content', () => {
|
|
const context = shallow(getChannels(false, []));
|
|
|
|
// should have nothing but empty str
|
|
expect(context.find('.chatchannels__channelslist').exists()).toEqual(
|
|
true,
|
|
);
|
|
expect(context.find('.chatchannels__channelslist').text()).toEqual('');
|
|
expect(
|
|
context.find('.chatchannels__channelslist').children().length,
|
|
).toEqual(1);
|
|
expect(
|
|
context.find('.chatchannels__channelslist').children()[0],
|
|
).toEqual(''); // empty child
|
|
});
|
|
});
|
|
});
|
|
});
|