|
1 | 1 | import { expect, test } from 'vitest'
|
2 | 2 | import { FakeAppState } from '../../../../../testSupport/fakes/fakeAppState'
|
3 |
| -import { |
4 |
| - testMikeRobertsUserMembershipOfOrg, |
5 |
| - testOrgTestRepoOneWorkflowRunThree, |
6 |
| - testTestUserMembershipOfOrg |
7 |
| -} from '../../../../../examples/cicada/githubDomainObjects' |
8 |
| -import { |
9 |
| - GITHUB_ACCOUNT_MEMBERSHIP, |
10 |
| - GITHUB_LATEST_WORKFLOW_RUN_EVENT, |
11 |
| - WEB_PUSH_SUBSCRIPTION |
12 |
| -} from '../../../../../../src/app/domain/entityStore/entityTypes' |
| 3 | +import { testOrgTestRepoOneWorkflowRunThree } from '../../../../../examples/cicada/githubDomainObjects' |
13 | 4 | import { processEventBridgeWebPushEvent } from '../../../../../../src/app/domain/webPush/webPushEventBridgeEventProcessor'
|
14 | 5 | import {
|
15 | 6 | testMikeRobertsPushSubscriptionThree,
|
16 |
| - testMikeRobertsPushSubscriptionTwo, |
17 |
| - testTestUserPushSubscription |
| 7 | + testMikeRobertsPushSubscriptionTwo |
18 | 8 | } from '../../../../../examples/cicada/webPushDomainObjects'
|
19 | 9 | import { EVENTBRIDGE_DETAIL_TYPES } from '../../../../../../src/multipleContexts/eventBridge'
|
| 10 | +import { |
| 11 | + stubQueryAccountMembershipsByAccount, |
| 12 | + stubQueryAccountMembershipsByUser, |
| 13 | + stubQueryLatestWorkflowRuns, |
| 14 | + stubQueryWebPushSubscription |
| 15 | +} from '../../../../../testSupport/fakes/fakeTableRecords' |
20 | 16 |
|
21 | 17 | test('newWorkflowRunEvent', async () => {
|
22 | 18 | const appState = new FakeAppState()
|
23 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
24 |
| - { |
25 |
| - TableName: 'fakeGithubAccountMemberships', |
26 |
| - KeyConditionExpression: 'PK = :pk', |
27 |
| - ExpressionAttributeValues: { ':pk': 'ACCOUNT#162483619' } |
28 |
| - }, |
29 |
| - [ |
30 |
| - { |
31 |
| - $metadata: {}, |
32 |
| - Items: [ |
33 |
| - { ...testTestUserMembershipOfOrg, _et: GITHUB_ACCOUNT_MEMBERSHIP }, |
34 |
| - { ...testMikeRobertsUserMembershipOfOrg, _et: GITHUB_ACCOUNT_MEMBERSHIP } |
35 |
| - ] |
36 |
| - } |
37 |
| - ] |
38 |
| - ) |
39 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
40 |
| - { |
41 |
| - TableName: 'fakeGithubAccountMemberships', |
42 |
| - KeyConditionExpression: 'GSI1PK = :pk', |
43 |
| - IndexName: 'GSI1', |
44 |
| - ExpressionAttributeValues: { ':pk': 'USER#162360409' } |
45 |
| - }, |
46 |
| - [ |
47 |
| - { |
48 |
| - $metadata: {}, |
49 |
| - Items: [{ ...testTestUserMembershipOfOrg, _et: GITHUB_ACCOUNT_MEMBERSHIP }] |
50 |
| - } |
51 |
| - ] |
52 |
| - ) |
53 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
54 |
| - { |
55 |
| - TableName: 'fakeGithubAccountMemberships', |
56 |
| - KeyConditionExpression: 'GSI1PK = :pk', |
57 |
| - IndexName: 'GSI1', |
58 |
| - ExpressionAttributeValues: { ':pk': 'USER#49635' } |
59 |
| - }, |
60 |
| - [ |
61 |
| - { |
62 |
| - $metadata: {}, |
63 |
| - Items: [{ ...testMikeRobertsUserMembershipOfOrg, _et: GITHUB_ACCOUNT_MEMBERSHIP }] |
64 |
| - } |
65 |
| - ] |
66 |
| - ) |
| 19 | + stubQueryAccountMembershipsByAccount(appState) |
67 | 20 |
|
68 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
69 |
| - { |
70 |
| - TableName: 'fakeGithubLatestWorkflowRunsTable', |
71 |
| - KeyConditionExpression: 'GSI1PK = :pk', |
72 |
| - IndexName: 'GSI1', |
73 |
| - ExpressionAttributeValues: { ':pk': 'ACCOUNT#162483619' }, |
74 |
| - ScanIndexForward: false |
75 |
| - }, |
76 |
| - [ |
77 |
| - { |
78 |
| - $metadata: {}, |
79 |
| - Items: [{ ...testOrgTestRepoOneWorkflowRunThree, _et: GITHUB_LATEST_WORKFLOW_RUN_EVENT }] |
80 |
| - } |
81 |
| - ] |
82 |
| - ) |
83 |
| - |
84 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
85 |
| - { |
86 |
| - TableName: 'fakeWebPushSubscriptions', |
87 |
| - KeyConditionExpression: 'PK = :pk', |
88 |
| - ExpressionAttributeValues: { ':pk': 'USER#162360409' } |
89 |
| - }, |
90 |
| - [ |
91 |
| - { |
92 |
| - $metadata: {}, |
93 |
| - Items: [ |
94 |
| - { |
95 |
| - _et: WEB_PUSH_SUBSCRIPTION, |
96 |
| - ...testTestUserPushSubscription |
97 |
| - } |
98 |
| - ] |
99 |
| - } |
100 |
| - ] |
101 |
| - ) |
102 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
103 |
| - { |
104 |
| - TableName: 'fakeWebPushSubscriptions', |
105 |
| - KeyConditionExpression: 'PK = :pk', |
106 |
| - ExpressionAttributeValues: { ':pk': 'USER#49635' } |
107 |
| - }, |
108 |
| - [ |
109 |
| - { |
110 |
| - $metadata: {}, |
111 |
| - Items: [ |
112 |
| - { |
113 |
| - _et: WEB_PUSH_SUBSCRIPTION, |
114 |
| - ...testMikeRobertsPushSubscriptionTwo |
115 |
| - }, |
116 |
| - { |
117 |
| - _et: WEB_PUSH_SUBSCRIPTION, |
118 |
| - ...testMikeRobertsPushSubscriptionThree |
119 |
| - } |
120 |
| - ] |
121 |
| - } |
122 |
| - ] |
123 |
| - ) |
| 21 | + stubQueryAccountMembershipsByUser(appState) |
| 22 | + stubQueryAccountMembershipsByUser(appState, 49635) |
| 23 | + stubQueryLatestWorkflowRuns(appState) |
| 24 | + stubQueryWebPushSubscription(appState) |
| 25 | + stubQueryWebPushSubscription(appState, { |
| 26 | + userId: 49635, |
| 27 | + subscriptions: [testMikeRobertsPushSubscriptionTwo, testMikeRobertsPushSubscriptionThree] |
| 28 | + }) |
124 | 29 |
|
125 | 30 | await processEventBridgeWebPushEvent(appState, {
|
126 | 31 | version: '0',
|
@@ -191,38 +96,9 @@ test('newWorkflowRunEvent', async () => {
|
191 | 96 |
|
192 | 97 | test('newPushTest', async () => {
|
193 | 98 | const appState = new FakeAppState()
|
194 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
195 |
| - { |
196 |
| - TableName: 'fakeGithubAccountMemberships', |
197 |
| - KeyConditionExpression: 'PK = :pk', |
198 |
| - ExpressionAttributeValues: { ':pk': 'ACCOUNT#162483619' } |
199 |
| - }, |
200 |
| - [ |
201 |
| - { |
202 |
| - $metadata: {}, |
203 |
| - Items: [{ ...testTestUserMembershipOfOrg, _et: GITHUB_ACCOUNT_MEMBERSHIP }] |
204 |
| - } |
205 |
| - ] |
206 |
| - ) |
207 | 99 |
|
208 |
| - appState.dynamoDB.stubAllPagesQueries.addResponse( |
209 |
| - { |
210 |
| - TableName: 'fakeWebPushSubscriptions', |
211 |
| - KeyConditionExpression: 'PK = :pk', |
212 |
| - ExpressionAttributeValues: { ':pk': 'USER#162360409' } |
213 |
| - }, |
214 |
| - [ |
215 |
| - { |
216 |
| - $metadata: {}, |
217 |
| - Items: [ |
218 |
| - { |
219 |
| - _et: WEB_PUSH_SUBSCRIPTION, |
220 |
| - ...testTestUserPushSubscription |
221 |
| - } |
222 |
| - ] |
223 |
| - } |
224 |
| - ] |
225 |
| - ) |
| 100 | + stubQueryAccountMembershipsByUser(appState) |
| 101 | + stubQueryWebPushSubscription(appState) |
226 | 102 |
|
227 | 103 | await processEventBridgeWebPushEvent(appState, {
|
228 | 104 | version: '0',
|
|
0 commit comments