Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 2bca8b1

Browse files
authored
Merge pull request #5013 from withspectrum/3.1.2
3.1.2
2 parents 31450a3 + 3d0b596 commit 2bca8b1

File tree

37 files changed

+449
-790
lines changed

37 files changed

+449
-790
lines changed

Diff for: api/mutations/directMessageThread/createDirectMessageThread.js

+16-57
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
setUserLastSeenInDirectMessageThread,
1414
createMemberInDirectMessageThread,
1515
} from '../../models/usersDirectMessageThreads';
16+
import { addMessage } from '../message/addMessage';
1617
import type { FileUpload } from 'shared/types';
1718
import { events } from 'shared/analytics';
1819
import { trackQueue } from 'shared/bull/queues';
@@ -25,7 +26,7 @@ export type CreateDirectMessageThreadInput = {
2526
participants: Array<string>,
2627
message: {
2728
messageType: MessageType,
28-
threadType: string,
29+
threadType: 'directMessageThread',
2930
content: {
3031
body: string,
3132
},
@@ -81,65 +82,17 @@ export default requireAuth(
8182
threadId = threadToReturn.id;
8283
}
8384

84-
const handleStoreMessage = async message => {
85-
if (
86-
message.messageType === messageTypeObj.text ||
87-
message.messageType === messageTypeObj.draftjs
88-
) {
89-
// once we have an id we can generate a proper message object
90-
const messageWithThread = {
91-
...message,
92-
threadId,
93-
};
94-
95-
return await storeMessage(messageWithThread, user.id);
96-
} else if (message.messageType === messageTypeObj.media && message.file) {
97-
let url;
98-
try {
99-
url = await uploadImage(message.file, 'threads', threadId);
100-
} catch (err) {
101-
trackQueue.add({
102-
userId: user.id,
103-
event: events.DIRECT_MESSAGE_THREAD_CREATED_FAILED,
104-
properties: {
105-
reason: 'image upload failed',
106-
},
107-
});
108-
return new UserError(err.message);
109-
}
110-
111-
// build a new message object with a new file field with metadata
112-
const newMessage = Object.assign({}, message, {
113-
...message,
114-
threadId: threadId,
115-
content: {
116-
body: url,
117-
},
118-
file: {
119-
name: message.file && message.file.filename,
120-
size: null,
121-
type: message.file && message.file.mimetype,
122-
},
123-
});
124-
125-
return await storeMessage(newMessage, user.id);
126-
} else {
127-
trackQueue.add({
128-
userId: user.id,
129-
event: events.DIRECT_MESSAGE_THREAD_CREATED_FAILED,
130-
properties: {
131-
reason: 'unknown message type',
132-
},
133-
});
134-
return new UserError('Unknown message type on this bad boy.');
135-
}
136-
};
137-
13885
if (existingThread) {
13986
return await Promise.all([
14087
setUserLastSeenInDirectMessageThread(threadId, user.id),
14188
setDirectMessageThreadLastActive(threadId),
142-
handleStoreMessage(message),
89+
addMessage(
90+
{
91+
...message,
92+
threadId,
93+
},
94+
user.id
95+
),
14396
]).then(() => threadToReturn);
14497
}
14598

@@ -150,7 +103,13 @@ export default requireAuth(
150103

151104
return await Promise.all([
152105
createMemberInDirectMessageThread(threadId, user.id, true),
153-
handleStoreMessage(message),
106+
addMessage(
107+
{
108+
...message,
109+
threadId,
110+
},
111+
user.id
112+
),
154113
participants.map(participant => {
155114
trackQueue.add({
156115
userId: participant,

Diff for: athena/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"now-env": "^3.1.0",
2424
"performance-now": "^2.1.0",
2525
"raven": "^2.6.4",
26-
"react": "^16.8.5",
27-
"react-dom": "^16.8.5",
26+
"react": "^16.8.6",
27+
"react-dom": "^16.8.6",
2828
"redis-tag-cache": "^1.2.1",
2929
"rethinkdb-inspector": "^0.3.3",
3030
"rethinkdbdash": "^2.3.31",

Diff for: athena/yarn.lock

+14-14
Original file line numberDiff line numberDiff line change
@@ -713,30 +713,30 @@ rc@^1.0.0:
713713
minimist "^1.2.0"
714714
strip-json-comments "~2.0.1"
715715

716-
react-dom@^16.8.5:
717-
version "16.8.5"
718-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.5.tgz#b3e37d152b49e07faaa8de41fdf562be3463335e"
719-
integrity sha512-VIEIvZLpFafsfu4kgmftP5L8j7P1f0YThfVTrANMhZUFMDOsA6e0kfR6wxw/8xxKs4NB59TZYbxNdPCDW34x4w==
716+
react-dom@^16.8.6:
717+
version "16.8.6"
718+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f"
719+
integrity sha512-1nL7PIq9LTL3fthPqwkvr2zY7phIPjYrT0jp4HjyEQrEROnw4dG41VVwi/wfoCneoleqrNX7iAD+pXebJZwrwA==
720720
dependencies:
721721
loose-envify "^1.1.0"
722722
object-assign "^4.1.1"
723723
prop-types "^15.6.2"
724-
scheduler "^0.13.5"
724+
scheduler "^0.13.6"
725725

726726
react-is@^16.8.1:
727727
version "16.8.4"
728728
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2"
729729
integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA==
730730

731-
react@^16.8.5:
732-
version "16.8.5"
733-
resolved "https://registry.yarnpkg.com/react/-/react-16.8.5.tgz#49be3b655489d74504ad994016407e8a0445de66"
734-
integrity sha512-daCb9TD6FZGvJ3sg8da1tRAtIuw29PbKZW++NN4wqkbEvxL+bZpaaYb4xuftW/SpXmgacf1skXl/ddX6CdOlDw==
731+
react@^16.8.6:
732+
version "16.8.6"
733+
resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe"
734+
integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==
735735
dependencies:
736736
loose-envify "^1.1.0"
737737
object-assign "^4.1.1"
738738
prop-types "^15.6.2"
739-
scheduler "^0.13.5"
739+
scheduler "^0.13.6"
740740

741741
[email protected], redis-commands@^1.2.0:
742742
version "1.4.0"
@@ -813,10 +813,10 @@ sax@>=0.6.0:
813813
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
814814
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
815815

816-
scheduler@^0.13.5:
817-
version "0.13.5"
818-
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.5.tgz#b7226625167041298af3b98088a9dbbf6d7733a8"
819-
integrity sha512-K98vjkQX9OIt/riLhp6F+XtDPtMQhqNcf045vsh+pcuvHq+PHy1xCrH3pq1P40m6yR46lpVvVhKdEOtnimuUJw==
816+
scheduler@^0.13.6:
817+
version "0.13.6"
818+
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889"
819+
integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ==
820820
dependencies:
821821
loose-envify "^1.1.0"
822822
object-assign "^4.1.1"

Diff for: cypress/integration/channel/settings/edit_spec.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ describe('edit a channel', () => {
4040
.click();
4141

4242
cy.visit(`/${community.slug}/${channel.slug}`);
43-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
44-
cy.get('[data-cy="channel-profile-card"]').contains(NEW_NAME);
45-
cy.get('[data-cy="channel-profile-card"]').contains(NEW_DESCRIPTION);
43+
cy.contains(NEW_NAME);
4644
});
4745
});

Diff for: cypress/integration/channel/view/membership_spec.js

+14-27
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ const community = data.communities.find(
88
community => community.id === publicChannel.communityId
99
);
1010

11-
const { userId: ownerInChannelId } = data.usersChannels.find(
12-
({ channelId, isOwner }) => channelId === publicChannel.id && isOwner
13-
);
14-
1511
const { userId: memberInChannelId } = data.usersChannels.find(
1612
({ channelId, isMember, isOwner }) =>
1713
channelId === publicChannel.id && isMember && !isOwner
@@ -25,20 +21,26 @@ const QUIET_USER_ID = constants.QUIET_USER_ID;
2521

2622
const leave = () => {
2723
cy.get('[data-cy="channel-leave-button"]')
24+
.last()
2825
.should('be.visible')
2926
.contains('Member');
3027

31-
cy.get('[data-cy="channel-leave-button"]').click();
28+
cy.get('[data-cy="channel-leave-button"]')
29+
.last()
30+
.click();
3231

33-
cy.get('[data-cy="channel-join-button"]').contains(`Join channel`);
32+
cy.get('[data-cy="channel-join-button"]').contains(`Join`);
3433
};
3534

3635
const join = () => {
3736
cy.get('[data-cy="channel-join-button"]')
37+
.last()
3838
.should('be.visible')
39-
.contains('Join channel');
39+
.contains('Join');
4040

41-
cy.get('[data-cy="channel-join-button"]').click();
41+
cy.get('[data-cy="channel-join-button"]')
42+
.last()
43+
.click();
4244

4345
cy.get('[data-cy="channel-leave-button"]').contains(`Member`);
4446
};
@@ -48,8 +50,8 @@ describe('logged out channel membership', () => {
4850
cy.visit(`/${community.slug}/${publicChannel.slug}`);
4951
});
5052

51-
it('should render join button that links to login view', () => {
52-
cy.get('[data-cy="channel-login-join-button"]').should('be.visible');
53+
it('should render community join button that links to login view', () => {
54+
cy.get('[data-cy="profile-join-button"]').should('be.visible');
5355
});
5456
});
5557

@@ -73,23 +75,8 @@ describe('channel profile as non-member', () => {
7375
);
7476
});
7577

76-
it('should render join channel button', () => {
77-
join();
78-
leave();
79-
});
80-
});
81-
82-
describe('channel profile as owner', () => {
83-
beforeEach(() => {
84-
cy.auth(ownerInChannelId).then(() =>
85-
cy.visit(`/${community.slug}/${publicChannel.slug}`)
86-
);
87-
});
88-
89-
it('should render settings button', () => {
90-
cy.get('[data-cy="channel-settings-button"]')
91-
.should('be.visible')
92-
.contains('Settings');
78+
it('should render join community button', () => {
79+
cy.get('[data-cy="profile-join-button"]').should('be.visible');
9380
});
9481
});
9582

Diff for: cypress/integration/channel/view/notifications_spec.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ describe('channel notification preferences logged out', () => {
1919
it('should not render notifications settings', () => {
2020
cy.get('[data-cy="channel-view"]').should('be.visible');
2121

22-
cy.get('[data-cy="notifications-checkbox"]').should('not.be.visible');
22+
cy.get('[data-cy="channel-notifications-muted"]').should('not.be.visible');
23+
cy.get('[data-cy="channel-notifications-enabled"]').should(
24+
'not.be.visible'
25+
);
2326
});
2427
});
2528

@@ -33,13 +36,21 @@ describe('channel notification preferences as member', () => {
3336
it('should render notification settings', () => {
3437
cy.get('[data-cy="channel-view"]').should('be.visible');
3538

36-
cy.get('[data-cy="notifications-checkbox-checked"]')
37-
.should('be.visible')
38-
.click();
39+
cy.get('[data-cy="channel-notifications-enabled"]').should($p => {
40+
expect($p).to.have.length(2);
41+
});
3942

40-
cy.get('[data-cy="notifications-checkbox-unchecked"]')
41-
.should('be.visible')
43+
cy.get('[data-cy="channel-notifications-enabled"]')
44+
.first()
4245
.click();
46+
47+
cy.get('[data-cy="channel-notifications-enabled"]').should($p => {
48+
expect($p).to.have.length(1);
49+
});
50+
51+
cy.get('[data-cy="channel-notifications-muted"]').should($p => {
52+
expect($p).to.have.length(1);
53+
});
4354
});
4455
});
4556

@@ -53,7 +64,8 @@ describe('channel profile as non-member', () => {
5364
it('should not render notifications settings', () => {
5465
cy.get('[data-cy="channel-view"]').should('be.visible');
5566

56-
cy.get('[data-cy="notifications-checkbox-checked"]').should(
67+
cy.get('[data-cy="channel-notifications-muted"]').should('not.be.visible');
68+
cy.get('[data-cy="channel-notifications-enabled"]').should(
5769
'not.be.visible'
5870
);
5971
});

Diff for: cypress/integration/channel/view/profile_spec.js

-12
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ describe('public channel', () => {
3939
it('should render profile', () => {
4040
cy.get('[data-cy="channel-view"]').should('be.visible');
4141
});
42-
43-
it('should contain channel metadata', () => {
44-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
45-
cy.contains(community.name);
46-
cy.contains(publicChannel.description);
47-
cy.contains(publicChannel.name);
48-
});
4942
});
5043

5144
describe('public channel in private community signed out', () => {
@@ -96,11 +89,6 @@ describe('archived channel', () => {
9689
it('should render profile', () => {
9790
cy.get('[data-cy="channel-view"]').should('be.visible');
9891
});
99-
100-
it('should contain archived tag', () => {
101-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
102-
cy.contains('Archived');
103-
});
10492
});
10593

10694
describe('deleted channel', () => {

Diff for: cypress/integration/thread/action_bar_spec.js

+20-7
Original file line numberDiff line numberDiff line change
@@ -29,34 +29,46 @@ const memberInChannelUser = data.users.find(u => u.id === constants.BRYN_ID);
2929
const lockThread = () => {
3030
// lock the thread
3131
cy.get('[data-cy="thread-dropdown-lock"]').contains('Lock chat');
32-
cy.get('[data-cy="thread-dropdown-lock"]').click();
32+
cy.get('[data-cy="thread-dropdown-lock"]')
33+
.first()
34+
.click();
3335
cy.get('[data-cy="thread-dropdown-lock"]').contains('Unlock chat');
3436

3537
// unlock the thread
36-
cy.get('[data-cy="thread-dropdown-lock"]').click();
38+
cy.get('[data-cy="thread-dropdown-lock"]')
39+
.first()
40+
.click();
3741
cy.get('[data-cy="thread-dropdown-lock"]').contains('Lock chat');
3842
};
3943

4044
const pinThread = () => {
4145
// pin the thread
42-
cy.get('[data-cy="thread-dropdown-pin"]').click();
46+
cy.get('[data-cy="thread-dropdown-pin"]')
47+
.first()
48+
.click();
4349
cy.get('[data-cy="thread-dropdown-pin"]').contains('Unpin');
4450

4551
// unpin the thread
46-
cy.get('[data-cy="thread-dropdown-pin"]').click();
52+
cy.get('[data-cy="thread-dropdown-pin"]')
53+
.first()
54+
.click();
4755
cy.get('[data-cy="thread-dropdown-pin"]').contains('Pin');
4856
};
4957

5058
const triggerThreadDelete = () => {
51-
cy.get('[data-cy="thread-dropdown-delete"]').click();
59+
cy.get('[data-cy="thread-dropdown-delete"]')
60+
.first()
61+
.click();
5262
cy.get('[data-cy="delete-button"]').should('be.visible');
5363
cy.get('div.ReactModal__Overlay')
5464
.should('be.visible')
5565
.click('topLeft');
5666
};
5767

5868
const triggerMovingThread = () => {
59-
cy.get('[data-cy="thread-dropdown-move"]').click();
69+
cy.get('[data-cy="thread-dropdown-move"]')
70+
.first()
71+
.click();
6072
cy.get('[data-cy="move-thread-modal"]').should('be.visible');
6173
cy.get('div.ReactModal__Overlay')
6274
.should('be.visible')
@@ -65,8 +77,9 @@ const triggerMovingThread = () => {
6577

6678
const openSettingsDropdown = () => {
6779
cy.get('[data-cy="thread-actions-dropdown-trigger"]')
80+
.last()
6881
.should('be.visible')
69-
.click();
82+
.click({ force: true });
7083
};
7184

7285
describe('action bar renders', () => {

0 commit comments

Comments
 (0)