@jskit-ai/google-rewarded-core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/docs/protecting-server-actions.md +190 -0
- package/package.descriptor.mjs +186 -0
- package/package.json +10 -0
- package/src/server/GoogleRewardedCoreProvider.js +51 -0
- package/src/server/actions.js +102 -0
- package/src/server/inputSchemas.js +394 -0
- package/src/server/providerConfigs/GoogleRewardedProviderConfigsProvider.js +98 -0
- package/src/server/providerConfigs/actions.js +157 -0
- package/src/server/providerConfigs/registerRoutes.js +176 -0
- package/src/server/providerConfigs/repository.js +107 -0
- package/src/server/providerConfigs/service.js +61 -0
- package/src/server/registerRoutes.js +169 -0
- package/src/server/rules/GoogleRewardedRulesProvider.js +98 -0
- package/src/server/rules/actions.js +157 -0
- package/src/server/rules/registerRoutes.js +176 -0
- package/src/server/rules/repository.js +107 -0
- package/src/server/rules/service.js +61 -0
- package/src/server/service.js +552 -0
- package/src/server/support/requireGoogleRewardedUnlock.js +142 -0
- package/src/server/unlockReceipts/GoogleRewardedUnlockReceiptsProvider.js +98 -0
- package/src/server/unlockReceipts/actions.js +157 -0
- package/src/server/unlockReceipts/registerRoutes.js +176 -0
- package/src/server/unlockReceipts/repository.js +107 -0
- package/src/server/unlockReceipts/service.js +61 -0
- package/src/server/watchSessions/GoogleRewardedWatchSessionsProvider.js +98 -0
- package/src/server/watchSessions/actions.js +157 -0
- package/src/server/watchSessions/registerRoutes.js +176 -0
- package/src/server/watchSessions/repository.js +107 -0
- package/src/server/watchSessions/service.js +61 -0
- package/src/shared/googleRewardedProviderConfigResource.js +94 -0
- package/src/shared/googleRewardedRuleResource.js +136 -0
- package/src/shared/googleRewardedUnlockReceiptResource.js +113 -0
- package/src/shared/googleRewardedWatchSessionResource.js +139 -0
- package/src/shared/index.js +12 -0
- package/templates/migrations/google_rewarded_provider_configs_initial.cjs +27 -0
- package/templates/migrations/google_rewarded_rules_initial.cjs +31 -0
- package/templates/migrations/google_rewarded_unlock_receipts_initial.cjs +35 -0
- package/templates/migrations/google_rewarded_watch_sessions_initial.cjs +36 -0
- package/test/requireGoogleRewardedUnlock.test.js +274 -0
- package/test/routes.test.js +248 -0
- package/test/service.test.js +315 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { requireGoogleRewardedUnlock } from "../src/server/support/requireGoogleRewardedUnlock.js";
|
|
5
|
+
|
|
6
|
+
function createGoogleRewardedService(gateState) {
|
|
7
|
+
const calls = [];
|
|
8
|
+
return {
|
|
9
|
+
calls,
|
|
10
|
+
async getCurrentState(input, options = {}) {
|
|
11
|
+
calls.push({
|
|
12
|
+
input,
|
|
13
|
+
options
|
|
14
|
+
});
|
|
15
|
+
return gateState;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const REQUEST_CONTEXT = Object.freeze({
|
|
21
|
+
actor: {
|
|
22
|
+
id: "7"
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test("requireGoogleRewardedUnlock allows an already unlocked gate", async () => {
|
|
27
|
+
const gateState = {
|
|
28
|
+
gateKey: "progress-logging",
|
|
29
|
+
workspaceSlug: "alpha",
|
|
30
|
+
surface: "app",
|
|
31
|
+
enabled: true,
|
|
32
|
+
available: true,
|
|
33
|
+
blocked: false,
|
|
34
|
+
reason: "already-unlocked",
|
|
35
|
+
unlock: {
|
|
36
|
+
id: "31"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const googleRewardedService = createGoogleRewardedService(gateState);
|
|
40
|
+
|
|
41
|
+
const result = await requireGoogleRewardedUnlock(
|
|
42
|
+
googleRewardedService,
|
|
43
|
+
{
|
|
44
|
+
gateKey: "progress-logging",
|
|
45
|
+
workspaceSlug: "alpha"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
context: REQUEST_CONTEXT
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
assert.equal(result, gateState);
|
|
53
|
+
assert.deepEqual(googleRewardedService.calls[0], {
|
|
54
|
+
input: {
|
|
55
|
+
gateKey: "progress-logging",
|
|
56
|
+
workspaceSlug: "alpha",
|
|
57
|
+
surface: "app"
|
|
58
|
+
},
|
|
59
|
+
options: {
|
|
60
|
+
context: REQUEST_CONTEXT
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("requireGoogleRewardedUnlock bypasses missing configuration by default", async () => {
|
|
66
|
+
const gateState = {
|
|
67
|
+
gateKey: "progress-logging",
|
|
68
|
+
workspaceSlug: "alpha",
|
|
69
|
+
surface: "app",
|
|
70
|
+
enabled: false,
|
|
71
|
+
available: false,
|
|
72
|
+
blocked: false,
|
|
73
|
+
reason: "rule-not-configured",
|
|
74
|
+
unlock: null
|
|
75
|
+
};
|
|
76
|
+
const googleRewardedService = createGoogleRewardedService(gateState);
|
|
77
|
+
|
|
78
|
+
const result = await requireGoogleRewardedUnlock(
|
|
79
|
+
googleRewardedService,
|
|
80
|
+
{
|
|
81
|
+
gateKey: "progress-logging",
|
|
82
|
+
workspaceSlug: "alpha"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
context: REQUEST_CONTEXT
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
assert.equal(result, gateState);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("requireGoogleRewardedUnlock can fail closed when configuration is required", async () => {
|
|
93
|
+
const gateState = {
|
|
94
|
+
gateKey: "progress-logging",
|
|
95
|
+
workspaceSlug: "alpha",
|
|
96
|
+
surface: "app",
|
|
97
|
+
enabled: false,
|
|
98
|
+
available: false,
|
|
99
|
+
blocked: false,
|
|
100
|
+
reason: "provider-not-configured",
|
|
101
|
+
unlock: null
|
|
102
|
+
};
|
|
103
|
+
const googleRewardedService = createGoogleRewardedService(gateState);
|
|
104
|
+
|
|
105
|
+
await assert.rejects(
|
|
106
|
+
() => requireGoogleRewardedUnlock(
|
|
107
|
+
googleRewardedService,
|
|
108
|
+
{
|
|
109
|
+
gateKey: "progress-logging",
|
|
110
|
+
workspaceSlug: "alpha"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
context: REQUEST_CONTEXT,
|
|
114
|
+
requireConfigured: true
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
(error) => {
|
|
118
|
+
assert.equal(error.statusCode, 503);
|
|
119
|
+
assert.equal(error.code, "google_rewarded_not_configured");
|
|
120
|
+
assert.equal(error.details.rewardedGate, gateState);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("requireGoogleRewardedUnlock rejects when a reward is still required", async () => {
|
|
127
|
+
const gateState = {
|
|
128
|
+
gateKey: "progress-logging",
|
|
129
|
+
workspaceSlug: "alpha",
|
|
130
|
+
surface: "app",
|
|
131
|
+
enabled: true,
|
|
132
|
+
available: true,
|
|
133
|
+
blocked: true,
|
|
134
|
+
reason: "reward-required",
|
|
135
|
+
unlock: null
|
|
136
|
+
};
|
|
137
|
+
const googleRewardedService = createGoogleRewardedService(gateState);
|
|
138
|
+
|
|
139
|
+
await assert.rejects(
|
|
140
|
+
() => requireGoogleRewardedUnlock(
|
|
141
|
+
googleRewardedService,
|
|
142
|
+
{
|
|
143
|
+
gateKey: "progress-logging",
|
|
144
|
+
workspaceSlug: "alpha"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
context: REQUEST_CONTEXT,
|
|
148
|
+
errorMessage: "Watch a rewarded ad before logging progress."
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
(error) => {
|
|
152
|
+
assert.equal(error.statusCode, 423);
|
|
153
|
+
assert.equal(error.code, "google_rewarded_unlock_required");
|
|
154
|
+
assert.equal(error.message, "Watch a rewarded ad before logging progress.");
|
|
155
|
+
assert.equal(error.details.rewardedGate, gateState);
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("requireGoogleRewardedUnlock rejects cooldown and daily-limit states", async () => {
|
|
162
|
+
const cooldownService = createGoogleRewardedService({
|
|
163
|
+
gateKey: "progress-logging",
|
|
164
|
+
workspaceSlug: "alpha",
|
|
165
|
+
surface: "app",
|
|
166
|
+
enabled: true,
|
|
167
|
+
available: false,
|
|
168
|
+
blocked: false,
|
|
169
|
+
reason: "cooldown-active",
|
|
170
|
+
unlock: null
|
|
171
|
+
});
|
|
172
|
+
const dailyLimitService = createGoogleRewardedService({
|
|
173
|
+
gateKey: "progress-logging",
|
|
174
|
+
workspaceSlug: "alpha",
|
|
175
|
+
surface: "app",
|
|
176
|
+
enabled: true,
|
|
177
|
+
available: false,
|
|
178
|
+
blocked: false,
|
|
179
|
+
reason: "daily-limit-reached",
|
|
180
|
+
unlock: null
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
await assert.rejects(
|
|
184
|
+
() => requireGoogleRewardedUnlock(
|
|
185
|
+
cooldownService,
|
|
186
|
+
{
|
|
187
|
+
gateKey: "progress-logging",
|
|
188
|
+
workspaceSlug: "alpha"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
context: REQUEST_CONTEXT
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
(error) => {
|
|
195
|
+
assert.equal(error.statusCode, 423);
|
|
196
|
+
assert.equal(error.code, "google_rewarded_cooldown_active");
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
await assert.rejects(
|
|
202
|
+
() => requireGoogleRewardedUnlock(
|
|
203
|
+
dailyLimitService,
|
|
204
|
+
{
|
|
205
|
+
gateKey: "progress-logging",
|
|
206
|
+
workspaceSlug: "alpha"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
context: REQUEST_CONTEXT
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
(error) => {
|
|
213
|
+
assert.equal(error.statusCode, 423);
|
|
214
|
+
assert.equal(error.code, "google_rewarded_daily_limit_reached");
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("requireGoogleRewardedUnlock fails closed when the rewarded service returns an invalid gate state", async () => {
|
|
221
|
+
const googleRewardedService = createGoogleRewardedService({
|
|
222
|
+
gateKey: "progress-logging",
|
|
223
|
+
workspaceSlug: "alpha"
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
await assert.rejects(
|
|
227
|
+
() => requireGoogleRewardedUnlock(
|
|
228
|
+
googleRewardedService,
|
|
229
|
+
{
|
|
230
|
+
gateKey: "progress-logging",
|
|
231
|
+
workspaceSlug: "alpha"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
context: REQUEST_CONTEXT
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
(error) => {
|
|
238
|
+
assert.equal(error.statusCode, 503);
|
|
239
|
+
assert.equal(error.code, "google_rewarded_gate_state_invalid");
|
|
240
|
+
assert.deepEqual(error.details.rewardedGate, {
|
|
241
|
+
gateKey: "progress-logging",
|
|
242
|
+
workspaceSlug: "alpha"
|
|
243
|
+
});
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("requireGoogleRewardedUnlock fails closed when a non-blocking gate state has no explicit reason", async () => {
|
|
250
|
+
const googleRewardedService = createGoogleRewardedService({
|
|
251
|
+
gateKey: "progress-logging",
|
|
252
|
+
workspaceSlug: "alpha",
|
|
253
|
+
enabled: false,
|
|
254
|
+
blocked: false
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
await assert.rejects(
|
|
258
|
+
() => requireGoogleRewardedUnlock(
|
|
259
|
+
googleRewardedService,
|
|
260
|
+
{
|
|
261
|
+
gateKey: "progress-logging",
|
|
262
|
+
workspaceSlug: "alpha"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
context: REQUEST_CONTEXT
|
|
266
|
+
}
|
|
267
|
+
),
|
|
268
|
+
(error) => {
|
|
269
|
+
assert.equal(error.statusCode, 503);
|
|
270
|
+
assert.equal(error.code, "google_rewarded_gate_state_invalid");
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
});
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { registerRoutes } from "../src/server/registerRoutes.js";
|
|
5
|
+
|
|
6
|
+
function createReplyDouble() {
|
|
7
|
+
return {
|
|
8
|
+
statusCode: 200,
|
|
9
|
+
payload: null,
|
|
10
|
+
code(value) {
|
|
11
|
+
this.statusCode = value;
|
|
12
|
+
return this;
|
|
13
|
+
},
|
|
14
|
+
send(value) {
|
|
15
|
+
this.payload = value;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function findRoute(routes, { method, path }) {
|
|
22
|
+
return routes.find((route) => route.method === method && route.path === path) || null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function mountRoutes() {
|
|
26
|
+
const registeredRoutes = [];
|
|
27
|
+
const router = {
|
|
28
|
+
register(method, path, route, handler) {
|
|
29
|
+
registeredRoutes.push({
|
|
30
|
+
...route,
|
|
31
|
+
method,
|
|
32
|
+
path,
|
|
33
|
+
handler
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const app = {
|
|
39
|
+
make(token) {
|
|
40
|
+
if (token !== "jskit.http.router") {
|
|
41
|
+
throw new Error(`Unexpected token: ${String(token)}`);
|
|
42
|
+
}
|
|
43
|
+
return router;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
registerRoutes(app);
|
|
48
|
+
return registeredRoutes;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function createActionRequest({ input = {}, executeAction }) {
|
|
52
|
+
return {
|
|
53
|
+
input,
|
|
54
|
+
executeAction
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
test("google rewarded workflow routes mount with explicit request and response contracts", () => {
|
|
59
|
+
const routes = mountRoutes();
|
|
60
|
+
const currentRoute = findRoute(routes, {
|
|
61
|
+
method: "GET",
|
|
62
|
+
path: "/api/w/:workspaceSlug/google-rewarded/current"
|
|
63
|
+
});
|
|
64
|
+
const startRoute = findRoute(routes, {
|
|
65
|
+
method: "POST",
|
|
66
|
+
path: "/api/w/:workspaceSlug/google-rewarded/start"
|
|
67
|
+
});
|
|
68
|
+
const grantRoute = findRoute(routes, {
|
|
69
|
+
method: "POST",
|
|
70
|
+
path: "/api/w/:workspaceSlug/google-rewarded/grant"
|
|
71
|
+
});
|
|
72
|
+
const closeRoute = findRoute(routes, {
|
|
73
|
+
method: "POST",
|
|
74
|
+
path: "/api/w/:workspaceSlug/google-rewarded/close"
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
assert.equal(currentRoute?.auth, "required");
|
|
78
|
+
assert.equal(currentRoute?.visibility, "workspace_user");
|
|
79
|
+
assert.equal(currentRoute?.surface, "app");
|
|
80
|
+
assert.equal(typeof currentRoute?.query?.schema, "object");
|
|
81
|
+
assert.equal(currentRoute?.responses?.[200]?.transportSchema?.properties?.blocked?.["x-json-rest-schema"]?.castType, "boolean");
|
|
82
|
+
|
|
83
|
+
assert.equal(startRoute?.auth, "required");
|
|
84
|
+
assert.equal(startRoute?.visibility, "workspace_user");
|
|
85
|
+
assert.equal(typeof startRoute?.body?.schema, "object");
|
|
86
|
+
assert.equal(startRoute?.responses?.[200]?.transportSchema?.properties?.session?.anyOf?.[1]?.type, "null");
|
|
87
|
+
|
|
88
|
+
assert.equal(grantRoute?.responses?.[200]?.transportSchema?.properties?.unlocked?.["x-json-rest-schema"]?.castType, "boolean");
|
|
89
|
+
assert.equal(closeRoute?.responses?.[200]?.transportSchema?.properties?.closed?.["x-json-rest-schema"]?.castType, "boolean");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("google rewarded workflow route handlers build action input from request.input", async () => {
|
|
93
|
+
const routes = mountRoutes();
|
|
94
|
+
const calls = [];
|
|
95
|
+
const executeAction = async (payload) => {
|
|
96
|
+
calls.push(payload);
|
|
97
|
+
if (payload.actionId === "google-rewarded.current.read") {
|
|
98
|
+
return {
|
|
99
|
+
gateKey: "progress-logging",
|
|
100
|
+
workspaceSlug: "alpha",
|
|
101
|
+
surface: "app",
|
|
102
|
+
enabled: true,
|
|
103
|
+
available: true,
|
|
104
|
+
blocked: true,
|
|
105
|
+
reason: "reward-required",
|
|
106
|
+
rule: null,
|
|
107
|
+
providerConfig: null,
|
|
108
|
+
unlock: null,
|
|
109
|
+
cooldownUntil: null,
|
|
110
|
+
dailyLimitRemaining: null
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (payload.actionId === "google-rewarded.start") {
|
|
114
|
+
return {
|
|
115
|
+
gateKey: "progress-logging",
|
|
116
|
+
workspaceSlug: "alpha",
|
|
117
|
+
surface: "app",
|
|
118
|
+
enabled: true,
|
|
119
|
+
available: true,
|
|
120
|
+
blocked: true,
|
|
121
|
+
reason: "reward-required",
|
|
122
|
+
rule: null,
|
|
123
|
+
providerConfig: null,
|
|
124
|
+
unlock: null,
|
|
125
|
+
cooldownUntil: null,
|
|
126
|
+
dailyLimitRemaining: null,
|
|
127
|
+
session: null
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (payload.actionId === "google-rewarded.grant") {
|
|
131
|
+
return {
|
|
132
|
+
unlocked: true,
|
|
133
|
+
workspaceSlug: "alpha",
|
|
134
|
+
gateKey: "progress-logging",
|
|
135
|
+
unlock: null,
|
|
136
|
+
session: null
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
closed: true,
|
|
141
|
+
workspaceSlug: "alpha",
|
|
142
|
+
gateKey: "progress-logging",
|
|
143
|
+
session: null,
|
|
144
|
+
reason: null
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
await findRoute(routes, {
|
|
149
|
+
method: "GET",
|
|
150
|
+
path: "/api/w/:workspaceSlug/google-rewarded/current"
|
|
151
|
+
}).handler(
|
|
152
|
+
createActionRequest({
|
|
153
|
+
input: {
|
|
154
|
+
params: {
|
|
155
|
+
workspaceSlug: "Alpha"
|
|
156
|
+
},
|
|
157
|
+
query: {
|
|
158
|
+
gateKey: "progress-logging"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
executeAction
|
|
162
|
+
}),
|
|
163
|
+
createReplyDouble()
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
await findRoute(routes, {
|
|
167
|
+
method: "POST",
|
|
168
|
+
path: "/api/w/:workspaceSlug/google-rewarded/start"
|
|
169
|
+
}).handler(
|
|
170
|
+
createActionRequest({
|
|
171
|
+
input: {
|
|
172
|
+
params: {
|
|
173
|
+
workspaceSlug: "Alpha"
|
|
174
|
+
},
|
|
175
|
+
body: {
|
|
176
|
+
gateKey: "progress-logging"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
executeAction
|
|
180
|
+
}),
|
|
181
|
+
createReplyDouble()
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
await findRoute(routes, {
|
|
185
|
+
method: "POST",
|
|
186
|
+
path: "/api/w/:workspaceSlug/google-rewarded/grant"
|
|
187
|
+
}).handler(
|
|
188
|
+
createActionRequest({
|
|
189
|
+
input: {
|
|
190
|
+
params: {
|
|
191
|
+
workspaceSlug: "Alpha"
|
|
192
|
+
},
|
|
193
|
+
body: {
|
|
194
|
+
sessionId: "41"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
executeAction
|
|
198
|
+
}),
|
|
199
|
+
createReplyDouble()
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
await findRoute(routes, {
|
|
203
|
+
method: "POST",
|
|
204
|
+
path: "/api/w/:workspaceSlug/google-rewarded/close"
|
|
205
|
+
}).handler(
|
|
206
|
+
createActionRequest({
|
|
207
|
+
input: {
|
|
208
|
+
params: {
|
|
209
|
+
workspaceSlug: "Alpha"
|
|
210
|
+
},
|
|
211
|
+
body: {
|
|
212
|
+
sessionId: "41"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
executeAction
|
|
216
|
+
}),
|
|
217
|
+
createReplyDouble()
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
assert.deepEqual(calls[0], {
|
|
221
|
+
actionId: "google-rewarded.current.read",
|
|
222
|
+
input: {
|
|
223
|
+
workspaceSlug: "alpha",
|
|
224
|
+
gateKey: "progress-logging"
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
assert.deepEqual(calls[1], {
|
|
228
|
+
actionId: "google-rewarded.start",
|
|
229
|
+
input: {
|
|
230
|
+
workspaceSlug: "alpha",
|
|
231
|
+
gateKey: "progress-logging"
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
assert.deepEqual(calls[2], {
|
|
235
|
+
actionId: "google-rewarded.grant",
|
|
236
|
+
input: {
|
|
237
|
+
workspaceSlug: "alpha",
|
|
238
|
+
sessionId: "41"
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
assert.deepEqual(calls[3], {
|
|
242
|
+
actionId: "google-rewarded.close",
|
|
243
|
+
input: {
|
|
244
|
+
workspaceSlug: "alpha",
|
|
245
|
+
sessionId: "41"
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|