Merge branch 'v2' into MM_30482_data_operator_reviews

This commit is contained in:
Avinash Lingaloo
2021-04-09 11:24:47 +04:00
2 changed files with 86 additions and 0 deletions

View File

@@ -1213,6 +1213,8 @@ describe('*** DataOperator: Handlers tests ***', () => {
team_id: '',
team_type: '',
update_at: 0,
member_count: 0,
timezone_count: 0,
},
},
],
@@ -1303,6 +1305,87 @@ describe('*** DataOperator: Handlers tests ***', () => {
});
});
it('=> HandleTeam: should write to TEAM entity', async () => {
expect.assertions(2);
const spyOnExecuteInDatabase = jest.spyOn(DataOperator as any, 'executeInDatabase');
await createConnection(true);
await DataOperator.handleTeam([
{
id: 'rcgiyftm7jyrxnmdfdfa1osd8zswby',
create_at: 1445538153952,
update_at: 1588876392150,
delete_at: 0,
display_name: 'Contributors',
name: 'core',
description: '',
email: '',
type: 'O',
company_name: '',
allowed_domains: '',
invite_id: 'codoy5s743rq5mk18i7u5dfdfksz7e',
allow_open_invite: true,
last_team_icon_update: 1525181587639,
scheme_id: 'hbwgrncq1pfcdkpotzidfdmarn95o',
group_constrained: null,
},
]);
expect(spyOnExecuteInDatabase).toHaveBeenCalledTimes(1);
expect(spyOnExecuteInDatabase).toHaveBeenCalledWith({
createRaws: [
{
raw: {
id: 'rcgiyftm7jyrxnmdfdfa1osd8zswby',
create_at: 1445538153952,
update_at: 1588876392150,
delete_at: 0,
display_name: 'Contributors',
name: 'core',
description: '',
email: '',
type: 'O',
company_name: '',
allowed_domains: '',
invite_id: 'codoy5s743rq5mk18i7u5dfdfksz7e',
allow_open_invite: true,
last_team_icon_update: 1525181587639,
scheme_id: 'hbwgrncq1pfcdkpotzidfdmarn95o',
group_constrained: null,
},
},
],
tableName: 'Team',
updateRaws: [],
recordOperator: operateTeamRecord,
});
});
it('=> HandleTeamChannelHistory: should write to TEAM_CHANNEL_HISTORY entity', async () => {
expect.assertions(2);
const spyOnExecuteInDatabase = jest.spyOn(DataOperator as any, 'executeInDatabase');
await createConnection(true);
await DataOperator.handleTeamChannelHistory([
{
team_id: 'a',
channel_ids: ['ca', 'cb'],
},
]);
expect(spyOnExecuteInDatabase).toHaveBeenCalledTimes(1);
expect(spyOnExecuteInDatabase).toHaveBeenCalledWith({
createRaws: [{raw: {team_id: 'a', channel_ids: ['ca', 'cb']}}],
tableName: 'TeamChannelHistory',
updateRaws: [],
recordOperator: operateTeamChannelHistoryRecord,
});
});
it('=> HandleTeamSearchHistory: should write to TEAM_SEARCH_HISTORY entity', async () => {
expect.assertions(2);

View File

@@ -713,6 +713,8 @@ export const operateGroupsInTeamRecord = ({action, database, value}: DataFactory
const record = value.record as GroupsInTeam;
const isCreateAction = action === OperationType.CREATE;
// FIXME : should include memberCount and timezoneCount or will it be by update action?
const generator = (groupsInTeam: GroupsInTeam) => {
groupsInTeam._raw.id = isCreateAction ? groupsInTeam.id : record?.id;
groupsInTeam.teamId = raw.team_id;
@@ -740,6 +742,7 @@ export const operateGroupsInChannelRecord = ({action, database, value}: DataFact
const record = value.record as GroupsInChannel;
const isCreateAction = action === OperationType.CREATE;
// FIXME : should include memberCount and timezoneCount or will it be by update action?
const generator = (groupsInChannel: GroupsInChannel) => {
groupsInChannel._raw.id = isCreateAction ? groupsInChannel.id : record?.id;
groupsInChannel.channelId = raw.channel_id;