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

Commit 125c117

Browse files
authored
Merge pull request #4781 from withspectrum/2.8.0
2.8.0
2 parents 24d41f0 + bfdbfeb commit 125c117

File tree

109 files changed

+2718
-1284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2718
-1284
lines changed

.circleci/config.yml

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,24 @@ jobs:
8080
root: .
8181
paths: .
8282

83-
# Start db and servers, then run e2e and unit tests
84-
test_web:
83+
build_web:
84+
<<: *js_defaults
85+
steps:
86+
- attach_workspace:
87+
at: ~/spectrum
88+
- run: *setup-and-build-web
89+
- run: *build-api
90+
- persist_to_workspace:
91+
root: .
92+
paths:
93+
- build-api
94+
- build
95+
96+
test_unit:
8597
<<: *defaults
8698
docker:
87-
- image: circleci/node:8-browsers
99+
- image: circleci/node:8
88100
- image: redis:3.2.7
89-
- image: cypress/base:6
90101
- image: rethinkdb:2.3.5
91102
environment:
92103
TERM: xterm
@@ -98,42 +109,40 @@ jobs:
98109
- run:
99110
name: Run Unit Tests
100111
command: yarn run test:ci
101-
- run: *setup-and-build-web
102-
- run: *build-api
112+
113+
114+
# Start db and servers, then run e2e and unit tests
115+
test_e2e:
116+
<<: *defaults
117+
docker:
118+
- image: circleci/node:8-browsers
119+
- image: redis:3.2.7
120+
- image: cypress/base:6
121+
- image: rethinkdb:2.3.5
122+
parallel: true
123+
parallelism: 9
124+
environment:
125+
TERM: xterm
126+
steps:
127+
- attach_workspace:
128+
at: ~/spectrum
129+
- run: yarn run db:migrate
130+
- run: yarn run db:seed
103131
- run: *start-api
104132
- run: *start-web
105133
# Wait for the API and webserver to start
106134
- run: ./node_modules/.bin/wait-on http://localhost:3000 http://localhost:3001
107-
- run:
108-
name: Run Unit Tests
109-
command: yarn run test:ci
110135
- run:
111136
name: Install Cypress
112137
command: yarn run cypress:install
113138
- run:
114139
name: Run E2E Tests
115-
command: test $CYPRESS_RECORD_KEY && yarn run test:e2e -- --record || yarn run test:e2e
116-
- run:
117-
name: Test desktop apps
118-
command: yarn run test:desktop
119-
120-
# deploy_alpha:
121-
# <<: *js_defaults
122-
# docker:
123-
# - image: circleci/node:8-browsers
124-
# steps:
125-
# - attach_workspace:
126-
# at: ~/spectrum
127-
# - run: *build-api
128-
# - run:
129-
# name: Deploy and alias API
130-
# command: |
131-
# cd build-api
132-
# npx now-cd --alias "alpha=api.alpha.spectrum.chat" --team space-program
133-
# cd ..
134-
# - run:
135-
# name: Deploy and alias Hyperion
136-
# command: npx now-cd --alias "alpha=hyperion.alpha.spectrum.chat" --team space-program
140+
command: |
141+
if [ $CYPRESS_RECORD_KEY ]; then
142+
yarn run test:e2e -- --record --parallel
143+
else
144+
yarn run test:e2e
145+
fi
137146
138147
# Run eslint, flow etc.
139148
test_static_js:
@@ -154,20 +163,15 @@ workflows:
154163
test:
155164
jobs:
156165
- checkout_environment
157-
158-
# Testing
159-
- test_web:
166+
- test_unit:
160167
requires:
161168
- checkout_environment
162169
- test_static_js:
163170
requires:
164171
- checkout_environment
165-
166-
# Deployment
167-
# - deploy_alpha:
168-
# requires:
169-
# - test_static_js
170-
# - test_web
171-
# filters:
172-
# branches:
173-
# only: alpha
172+
- build_web:
173+
requires:
174+
- checkout_environment
175+
- test_e2e:
176+
requires:
177+
- build_web

api/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ app.use(statsd);
4444
// Trust the now proxy
4545
app.set('trust proxy', true);
4646
app.use(toobusy);
47-
// Allow bursts of up to 40 req for initial page loads, but block more than 40 / 10s
48-
app.use(
49-
rateLimiter({
50-
max: 40,
51-
duration: '10s',
52-
})
53-
);
47+
48+
if (!process.env.TEST_DB) {
49+
// Allow bursts of up to 40 req for initial page loads, but block more than 40 / 10s
50+
app.use(
51+
rateLimiter({
52+
max: 40,
53+
duration: '10s',
54+
})
55+
);
56+
}
5457

5558
// Security middleware.
5659
addSecurityMiddleware(app, { enableNonce: false, enableCSP: false });
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
exports.up = function(r, conn) {
2+
return r
3+
.table('users')
4+
.insert({
5+
id: 'sam',
6+
description: "Spectrum's automated bot.",
7+
createdAt: new Date(),
8+
email: null,
9+
providerId: null,
10+
fbProviderId: null,
11+
githubProviderId: null,
12+
githubUsername: 'withspectrum',
13+
googleProviderId: null,
14+
isOnline: true,
15+
lastSeen: new Date(),
16+
modifiedAt: new Date(),
17+
name: 'Spectrum Bot',
18+
termsLastAcceptedAt: new Date(),
19+
username: 'spectrumbot',
20+
website: 'https://spectrum.chat',
21+
profilePhoto: '/default_images/sam.png',
22+
})
23+
.run(conn);
24+
};
25+
exports.down = function(r, conn) {
26+
return r
27+
.table('users')
28+
.get('sam')
29+
.delete()
30+
.run(conn);
31+
};

api/migrations/seed/default/channels.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ const {
66
PAYMENTS_COMMUNITY_ID,
77
DELETED_COMMUNITY_ID,
88
PRIVATE_COMMUNITY_ID,
9+
SINGLE_CHANNEL_COMMUNITY_ID,
910
SPECTRUM_GENERAL_CHANNEL_ID,
1011
SPECTRUM_PRIVATE_CHANNEL_ID,
1112
PAYMENTS_GENERAL_CHANNEL_ID,
1213
PAYMENTS_PRIVATE_CHANNEL_ID,
14+
PAYMENTS_FEATURES_CHANNEL_ID,
1315
SPECTRUM_ARCHIVED_CHANNEL_ID,
1416
SPECTRUM_DELETED_CHANNEL_ID,
1517
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
1618
MODERATOR_CREATED_CHANNEL_ID,
1719
PRIVATE_GENERAL_CHANNEL_ID,
20+
SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
1821
} = constants;
1922

2023
module.exports = [
@@ -66,6 +69,18 @@ module.exports = [
6669
memberCount: 5,
6770
},
6871

72+
{
73+
id: PAYMENTS_FEATURES_CHANNEL_ID,
74+
communityId: PAYMENTS_COMMUNITY_ID,
75+
createdAt: new Date(DATE),
76+
name: 'Payments Features',
77+
description: 'Payments Features',
78+
slug: 'features',
79+
isPrivate: false,
80+
isDefault: false,
81+
memberCount: 5,
82+
},
83+
6984
{
7085
id: SPECTRUM_ARCHIVED_CHANNEL_ID,
7186
communityId: SPECTRUM_COMMUNITY_ID,
@@ -128,4 +143,16 @@ module.exports = [
128143
isDefault: false,
129144
memberCount: 1,
130145
},
146+
147+
{
148+
id: SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
149+
communityId: SINGLE_CHANNEL_COMMUNITY_ID,
150+
createdAt: new Date(DATE),
151+
name: 'General',
152+
description: 'General',
153+
slug: 'general',
154+
isPrivate: false,
155+
isDefault: false,
156+
memberCount: 1,
157+
},
131158
];

api/migrations/seed/default/communities.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const {
66
PAYMENTS_COMMUNITY_ID,
77
DELETED_COMMUNITY_ID,
88
PRIVATE_COMMUNITY_ID,
9+
SINGLE_CHANNEL_COMMUNITY_ID,
910
} = constants;
1011

1112
module.exports = [
@@ -66,4 +67,18 @@ module.exports = [
6667
slug: 'private',
6768
memberCount: 1,
6869
},
70+
{
71+
id: SINGLE_CHANNEL_COMMUNITY_ID,
72+
createdAt: new Date(DATE),
73+
isPrivate: false,
74+
name: 'Single channel community',
75+
description: 'Single channel community',
76+
website: 'https://spectrum.chat',
77+
profilePhoto:
78+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Profile.png.0.6225566835336693',
79+
coverPhoto:
80+
'https://spectrum.imgix.net/communities/-Kh6RfPYjmSaIWbkck8i/Twitter Header.png.0.3303118636071434',
81+
slug: 'single',
82+
memberCount: 1,
83+
},
6984
];

api/migrations/seed/default/constants.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,29 @@ const PENDING_USER_ID = '7';
1717
const CHANNEL_MODERATOR_USER_ID = '8';
1818
// this user is moderator in all communities
1919
const COMMUNITY_MODERATOR_USER_ID = '9';
20+
// this user is only a member of one community, and that community only has
21+
// one channel - use for testing the composer community+channel selection
22+
const SINGLE_CHANNEL_COMMUNITY_USER_ID = '10';
2023

2124
// communities
2225
const SPECTRUM_COMMUNITY_ID = '1';
2326
const PAYMENTS_COMMUNITY_ID = '2';
2427
const DELETED_COMMUNITY_ID = '3';
2528
const PRIVATE_COMMUNITY_ID = '4';
29+
const SINGLE_CHANNEL_COMMUNITY_ID = '5';
2630

2731
// channels
2832
const SPECTRUM_GENERAL_CHANNEL_ID = '1';
2933
const SPECTRUM_PRIVATE_CHANNEL_ID = '2';
3034
const PAYMENTS_GENERAL_CHANNEL_ID = '3';
3135
const PAYMENTS_PRIVATE_CHANNEL_ID = '4';
36+
const PAYMENTS_FEATURES_CHANNEL_ID = '10';
3237
const SPECTRUM_ARCHIVED_CHANNEL_ID = '5';
3338
const SPECTRUM_DELETED_CHANNEL_ID = '6';
3439
const DELETED_COMMUNITY_DELETED_CHANNEL_ID = '7';
3540
const MODERATOR_CREATED_CHANNEL_ID = '8';
3641
const PRIVATE_GENERAL_CHANNEL_ID = '9';
42+
const SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID = '11';
3743

3844
module.exports = {
3945
DATE,
@@ -46,17 +52,21 @@ module.exports = {
4652
PENDING_USER_ID,
4753
CHANNEL_MODERATOR_USER_ID,
4854
COMMUNITY_MODERATOR_USER_ID,
55+
SINGLE_CHANNEL_COMMUNITY_USER_ID,
4956
SPECTRUM_COMMUNITY_ID,
5057
PAYMENTS_COMMUNITY_ID,
5158
DELETED_COMMUNITY_ID,
5259
PRIVATE_COMMUNITY_ID,
60+
SINGLE_CHANNEL_COMMUNITY_ID,
5361
SPECTRUM_GENERAL_CHANNEL_ID,
5462
SPECTRUM_PRIVATE_CHANNEL_ID,
5563
PAYMENTS_GENERAL_CHANNEL_ID,
5664
PAYMENTS_PRIVATE_CHANNEL_ID,
65+
PAYMENTS_FEATURES_CHANNEL_ID,
5766
SPECTRUM_ARCHIVED_CHANNEL_ID,
5867
SPECTRUM_DELETED_CHANNEL_ID,
5968
DELETED_COMMUNITY_DELETED_CHANNEL_ID,
6069
MODERATOR_CREATED_CHANNEL_ID,
6170
PRIVATE_GENERAL_CHANNEL_ID,
71+
SINGLE_CHANNEL_COMMUNITY_GENERAL_CHANNEL_ID,
6272
};

api/migrations/seed/default/messages.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,21 @@ module.exports = [
186186
senderId: BRYN_ID,
187187
timestamp: new Date(DATE + 300000),
188188
},
189+
{
190+
id: '14',
191+
threadId: 'thread-6',
192+
threadType: 'story',
193+
content: {
194+
body: JSON.stringify(
195+
toJSON(
196+
fromPlainText(
197+
'http://localhost:3000/spectrum/general/yet-another-thread~thread-9'
198+
)
199+
)
200+
),
201+
},
202+
messageType: 'draftjs',
203+
senderId: BRIAN_ID,
204+
timestamp: new Date(DATE + 300000),
205+
},
189206
];

api/migrations/seed/default/users.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
PREVIOUS_MEMBER_USER_ID,
1010
CHANNEL_MODERATOR_USER_ID,
1111
COMMUNITY_MODERATOR_USER_ID,
12+
SINGLE_CHANNEL_COMMUNITY_USER_ID,
1213
DATE,
1314
} = constants;
1415

@@ -128,4 +129,18 @@ module.exports = [
128129
createdAt: new Date(DATE),
129130
lastSeen: new Date(DATE),
130131
},
132+
{
133+
id: SINGLE_CHANNEL_COMMUNITY_USER_ID,
134+
name: 'Single community person',
135+
description: 'Im a member of one community',
136+
website: '',
137+
username: 'single-community-user',
138+
profilePhoto:
139+
'https://pbs.twimg.com/profile_images/848823167699230721/-9CbPtto_bigger.jpg',
140+
coverPhoto:
141+
'https://pbs.twimg.com/profile_banners/17106008/1491444958/1500x500',
142+
143+
createdAt: new Date(DATE),
144+
lastSeen: new Date(DATE),
145+
},
131146
];

0 commit comments

Comments
 (0)