Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: disable demo request emails with env var (#352)

* fix: disable demo requests with env var

* test: deflake moderationConfigService by using longer random names

faker.random.alphaNumeric() defaults to a single character, producing
only 62 possible values. Many tests in this file share the same
dummyOrgId and insert into item_types / actions, which are unique on
(org_id, name). Collisions are therefore frequent and cause the suite
to fail intermittently (e.g. CI failure on PR #352 hit
duplicate key value violates unique constraint "org_id_name_key" with
name="m").

Pass a length of 16 so the chance of collision is negligible. No
production code is touched.

---------

Co-authored-by: Juan S. Mrad <juansmrad@gmail.com>

authored by

Caleb McQuaid
Juan S. Mrad
and committed by
GitHub
165c5117 2edd495e

+24 -16
+2
.env.githubci
··· 73 73 74 74 ITEM_QUEUE_TRAFFIC_PERCENTAGE='0' 75 75 UI_URL=https://getcoop.com 76 + 77 + ENABLE_DEMO_REQUEST=false
+3
server/.env.example
··· 57 57 SUPPORT_EMAIL=support@example.com 58 58 TEAM_EMAIL=team@example.com 59 59 60 + # Set to 'true' to enable the public demo request endpoint 61 + ENABLE_DEMO_REQUEST=false 62 + 60 63 # Other API Keys 61 64 SENDGRID_API_KEY=SG.REAL_API_KEY_HERE 62 65 GOOGLE_PLACES_API_KEY=
+3
server/graphql/datasources/OrgApi.ts
··· 180 180 } 181 181 182 182 async requestDemo(input: GQLRequestDemoInput) { 183 + if (process.env.ENABLE_DEMO_REQUEST !== 'true') { 184 + return false; 185 + } 183 186 const { email, company, website, interests, ref, isFromGoogleAds } = input; 184 187 const msg = { 185 188 to: CoopEmailAddress.Support,
+16 -16
server/services/moderationConfigService/moderationConfigService.test.ts
··· 579 579 580 580 it('should round-trip a non-null customMrtApiParams value', async () => { 581 581 const action = await sutWithPrimary.createAction(dummyOrgId, { 582 - name: faker.random.alphaNumeric(), 582 + name: faker.random.alphaNumeric(16), 583 583 description: null, 584 584 type: 'CUSTOM_ACTION', 585 585 callbackUrl: 'https://example.com', ··· 624 624 describe('#updateCustomAction', () => { 625 625 const testWithAction = makeTestWithFixture(async () => { 626 626 const action = await sutWithPrimary.createAction(dummyOrgId, { 627 - name: faker.random.alphaNumeric(), 627 + name: faker.random.alphaNumeric(16), 628 628 description: 'before', 629 629 type: 'CUSTOM_ACTION', 630 630 callbackUrl: 'https://before.example.com', ··· 743 743 'should reject renaming onto an existing action name', 744 744 async ({ action }) => { 745 745 const other = await sutWithPrimary.createAction(dummyOrgId, { 746 - name: faker.random.alphaNumeric(), 746 + name: faker.random.alphaNumeric(16), 747 747 description: null, 748 748 type: 'CUSTOM_ACTION', 749 749 callbackUrl: 'https://example.com', ··· 778 778 { 779 779 schema: dummySchema, 780 780 description: null, 781 - name: faker.random.alphaNumeric(), 781 + name: faker.random.alphaNumeric(16), 782 782 schemaFieldRoles: { displayName: 'fakeField' }, 783 783 }, 784 784 ); ··· 787 787 { 788 788 schema: dummySchema, 789 789 description: null, 790 - name: faker.random.alphaNumeric(), 790 + name: faker.random.alphaNumeric(16), 791 791 schemaFieldRoles: { displayName: 'fakeField' }, 792 792 }, 793 793 ); ··· 853 853 describe('#deleteCustomAction', () => { 854 854 const testWithAction = makeTestWithFixture(async () => { 855 855 const action = await sutWithPrimary.createAction(dummyOrgId, { 856 - name: faker.random.alphaNumeric(), 856 + name: faker.random.alphaNumeric(16), 857 857 description: null, 858 858 type: 'CUSTOM_ACTION', 859 859 callbackUrl: 'https://example.com', ··· 936 936 { 937 937 schema: dummySchema, 938 938 description: null, 939 - name: faker.random.alphaNumeric(), 939 + name: faker.random.alphaNumeric(16), 940 940 schemaFieldRoles: { displayName: 'fakeField' }, 941 941 }, 942 942 ); ··· 988 988 const itemType = await sutWithPrimary.createContentType(dummyOrgId, { 989 989 schema: dummySchema, 990 990 description: null, 991 - name: faker.random.alphaNumeric(), 991 + name: faker.random.alphaNumeric(16), 992 992 schemaFieldRoles: { displayName: 'fakeField' }, 993 993 }); 994 994 995 995 const viaJunctionAction = await sutWithPrimary.createAction( 996 996 dummyOrgId, 997 997 { 998 - name: faker.random.alphaNumeric(), 998 + name: faker.random.alphaNumeric(16), 999 999 description: null, 1000 1000 type: 'CUSTOM_ACTION', 1001 1001 callbackUrl: 'https://example.com', ··· 1008 1008 const viaAppliesAllAction = await sutWithPrimary.createAction( 1009 1009 dummyOrgId, 1010 1010 { 1011 - name: faker.random.alphaNumeric(), 1011 + name: faker.random.alphaNumeric(16), 1012 1012 description: null, 1013 1013 type: 'CUSTOM_ACTION', 1014 1014 callbackUrl: 'https://example.com', ··· 1023 1023 1024 1024 // Action satisfying both branches; result should still include it once. 1025 1025 const viaBothAction = await sutWithPrimary.createAction(dummyOrgId, { 1026 - name: faker.random.alphaNumeric(), 1026 + name: faker.random.alphaNumeric(16), 1027 1027 description: null, 1028 1028 type: 'CUSTOM_ACTION', 1029 1029 callbackUrl: 'https://example.com', ··· 1116 1116 const testWithRuleAndAction = makeTestWithFixture(async () => { 1117 1117 const rule = await createRule(container.Sequelize, dummyOrgId); 1118 1118 const action = await sutWithPrimary.createAction(dummyOrgId, { 1119 - name: faker.random.alphaNumeric(), 1119 + name: faker.random.alphaNumeric(16), 1120 1120 description: null, 1121 1121 type: 'CUSTOM_ACTION', 1122 1122 callbackUrl: 'https://example.com', ··· 1440 1440 const itemType = await sutWithPrimary.createContentType(dummyOrgId, { 1441 1441 schema: dummySchema, 1442 1442 description: null, 1443 - name: faker.random.alphaNumeric(), 1443 + name: faker.random.alphaNumeric(16), 1444 1444 schemaFieldRoles: { 1445 1445 displayName: 'fakeField', 1446 1446 }, ··· 1461 1461 const itemType = await sutWithPrimary.createContentType(dummyOrgId, { 1462 1462 schema: dummySchema, 1463 1463 description: null, 1464 - name: faker.random.alphaNumeric(), 1464 + name: faker.random.alphaNumeric(16), 1465 1465 schemaFieldRoles: { 1466 1466 displayName: 'fakeField', 1467 1467 }, ··· 1469 1469 1470 1470 const newItemType = await sutWithPrimary.updateContentType(dummyOrgId, { 1471 1471 id: itemType.id, 1472 - name: faker.random.alphaNumeric(), 1472 + name: faker.random.alphaNumeric(16), 1473 1473 schemaFieldRoles: { 1474 1474 creatorId: undefined, 1475 1475 }, ··· 1546 1546 async ({ itemType }) => { 1547 1547 await sutWithPrimary.updateContentType(dummyOrgId, { 1548 1548 id: itemType.id, 1549 - name: faker.random.alphaNumeric(), 1549 + name: faker.random.alphaNumeric(16), 1550 1550 schemaFieldRoles: { 1551 1551 creatorId: undefined, 1552 1552 },