Skip to content

Commit 8926fe3

Browse files
committed
chore(integration-tests): fix any typings
1 parent 8651482 commit 8926fe3

File tree

9 files changed

+64
-53
lines changed

9 files changed

+64
-53
lines changed
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
{
2+
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
23
"rules": {
3-
"dbTests": {
4-
"$testId": {
5-
"adminOnly": {
6-
".validate": false
7-
}
8-
}
9-
},
10-
".read": "auth != null",
11-
".write": true
4+
".read": false,
5+
".write": false
126
}
13-
}
7+
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import * as functions from "firebase-functions";
1+
import * as functions from "firebase-functions/v1";
22
import { REGION } from "../region";
33

4-
export const analyticsEventTests: any = functions
4+
export const analyticsEventTests = functions
55
.region(REGION)
66
.analytics.event("in_app_purchase")
7-
.onLog(async () => {});
7+
.onLog(async () => {
8+
// Test function - intentionally empty
9+
});

integration_test/functions/src/v1/database-tests.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as admin from "firebase-admin";
2-
import * as functions from "firebase-functions";
2+
import * as functions from "firebase-functions/v1";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
export const databaseRefOnCreateTests: any = functions
6+
export const databaseRefOnCreateTests = functions
77
.region(REGION)
88
.database.ref("dbTests/{testId}/start")
99
.onCreate(async (snapshot, context) => {
@@ -21,7 +21,7 @@ export const databaseRefOnCreateTests: any = functions
2121
);
2222
});
2323

24-
export const databaseRefOnDeleteTests: any = functions
24+
export const databaseRefOnDeleteTests = functions
2525
.region(REGION)
2626
.database.ref("dbTests/{testId}/start")
2727
.onDelete(async (snapshot, context) => {
@@ -39,12 +39,12 @@ export const databaseRefOnDeleteTests: any = functions
3939
);
4040
});
4141

42-
export const databaseRefOnUpdateTests: any = functions
42+
export const databaseRefOnUpdateTests = functions
4343
.region(REGION)
4444
.database.ref("dbTests/{testId}/start")
4545
.onUpdate(async (change, context) => {
4646
const testId = context.params.testId;
47-
const data = change.after.val();
47+
const data = change.after.val() as unknown;
4848

4949
await admin
5050
.firestore()
@@ -59,7 +59,7 @@ export const databaseRefOnUpdateTests: any = functions
5959
);
6060
});
6161

62-
export const databaseRefOnWriteTests: any = functions
62+
export const databaseRefOnWriteTests = functions
6363
.region(REGION)
6464
.database.ref("dbTests/{testId}/start")
6565
.onWrite(async (change, context) => {

integration_test/functions/src/v1/firestore-tests.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import * as admin from "firebase-admin";
2-
import * as functions from "firebase-functions";
2+
import * as functions from "firebase-functions/v1";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
export const firestoreDocumentOnCreateTests: any = functions
6+
export const firestoreDocumentOnCreateTests = functions
77
.runWith({
88
timeoutSeconds: 540,
99
})
1010
.region(REGION)
1111
.firestore.document("tests/{testId}")
12-
.onCreate(async (snapshot, context) => {
12+
.onCreate(async (_snapshot, context) => {
1313
const testId = context.params.testId;
1414
await admin
1515
.firestore()
@@ -18,13 +18,13 @@ export const firestoreDocumentOnCreateTests: any = functions
1818
.set(sanitizeData(context));
1919
});
2020

21-
export const firestoreDocumentOnDeleteTests: any = functions
21+
export const firestoreDocumentOnDeleteTests = functions
2222
.runWith({
2323
timeoutSeconds: 540,
2424
})
2525
.region(REGION)
2626
.firestore.document("tests/{testId}")
27-
.onDelete(async (snapshot, context) => {
27+
.onDelete(async (_snapshot, context) => {
2828
const testId = context.params.testId;
2929
await admin
3030
.firestore()
@@ -33,13 +33,13 @@ export const firestoreDocumentOnDeleteTests: any = functions
3333
.set(sanitizeData(context));
3434
});
3535

36-
export const firestoreDocumentOnUpdateTests: any = functions
36+
export const firestoreDocumentOnUpdateTests = functions
3737
.runWith({
3838
timeoutSeconds: 540,
3939
})
4040
.region(REGION)
4141
.firestore.document("tests/{testId}")
42-
.onUpdate(async (change, context) => {
42+
.onUpdate(async (_change, context) => {
4343
const testId = context.params.testId;
4444
await admin
4545
.firestore()
@@ -48,13 +48,13 @@ export const firestoreDocumentOnUpdateTests: any = functions
4848
.set(sanitizeData(context));
4949
});
5050

51-
export const firestoreDocumentOnWriteTests: any = functions
51+
export const firestoreDocumentOnWriteTests = functions
5252
.runWith({
5353
timeoutSeconds: 540,
5454
})
5555
.region(REGION)
5656
.firestore.document("tests/{testId}")
57-
.onWrite(async (change, context) => {
57+
.onWrite(async (_change, context) => {
5858
const testId = context.params.testId;
5959
await admin
6060
.firestore()

integration_test/functions/src/v1/pubsub-tests.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as admin from "firebase-admin";
2-
import * as functions from "firebase-functions";
2+
import * as functions from "firebase-functions/v1";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
export const pubsubOnPublishTests: any = functions
6+
export const pubsubOnPublishTests = functions
77
.region(REGION)
88
.pubsub.topic("pubsubTests")
99
.onPublish(async (message, context) => {
10-
let testId = message.json?.testId;
10+
const testId = (message.json as { testId?: string })?.testId;
1111
await admin
1212
.firestore()
1313
.collection("pubsubOnPublishTests")
@@ -20,7 +20,7 @@ export const pubsubOnPublishTests: any = functions
2020
);
2121
});
2222

23-
export const pubsubScheduleTests: any = functions
23+
export const pubsubScheduleTests = functions
2424
.region(REGION)
2525
.pubsub.schedule("every 10 hours") // This is a dummy schedule, since we need to put a valid one in.
2626
// For the test, the job is triggered by the jobs:run api

integration_test/functions/src/v1/remoteConfig-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import * as functions from "firebase-functions";
1+
import * as functions from "firebase-functions/v1";
22
import * as admin from "firebase-admin";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
export const remoteConfigOnUpdateTests: any = functions
6+
export const remoteConfigOnUpdateTests = functions
77
.region(REGION)
88
.remoteConfig.onUpdate(async (version, context) => {
99
const testId = version.description;

integration_test/functions/src/v1/storage-tests.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as admin from "firebase-admin";
2-
import * as functions from "firebase-functions";
2+
import * as functions from "firebase-functions/v1";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

@@ -25,19 +25,24 @@ import { sanitizeData } from "../utils";
2525
// .set(sanitizeData(context));
2626
// });
2727

28-
export const storageOnFinalizeTests: any = functions
28+
export const storageOnFinalizeTests = functions
2929
.runWith({
3030
timeoutSeconds: 540,
3131
})
3232
.region(REGION)
3333
.storage.bucket()
3434
.object()
35-
.onFinalize(async (object, context) => {
36-
const testId = object.name?.split(".")[0];
37-
if (!testId) {
38-
functions.logger.error("TestId not found for storage object finalize");
35+
.onFinalize(async (object: unknown, context) => {
36+
if (!object || typeof object !== "object" || !("name" in object)) {
37+
functions.logger.error("Invalid object structure for storage object finalize");
38+
return;
39+
}
40+
const name = (object as { name: string }).name;
41+
if (!name || typeof name !== "string") {
42+
functions.logger.error("Invalid name property for storage object finalize");
3943
return;
4044
}
45+
const testId = name.split(".")[0];
4146

4247
await admin
4348
.firestore()
@@ -46,7 +51,7 @@ export const storageOnFinalizeTests: any = functions
4651
.set(sanitizeData(context));
4752
});
4853

49-
export const storageOnMetadataUpdateTests: any = functions
54+
export const storageOnMetadataUpdateTests = functions
5055
.runWith({
5156
timeoutSeconds: 540,
5257
})

integration_test/functions/src/v1/tasks-tests.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import * as admin from "firebase-admin";
2-
import * as functions from "firebase-functions";
2+
import * as functions from "firebase-functions/v1";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
export const tasksOnDispatchTests: any = functions
6+
export const tasksOnDispatchTests = functions
77
.runWith({
88
timeoutSeconds: 540,
99
})
1010
.region(REGION)
1111
.tasks.taskQueue()
12-
.onDispatch(async (data, context) => {
13-
const testId = data.testId;
14-
if (!testId) {
15-
functions.logger.error("TestId not found for tasks onDispatch");
12+
.onDispatch(async (data: unknown, context) => {
13+
if (!data || typeof data !== "object" || !("testId" in data)) {
14+
functions.logger.error("Invalid data structure for tasks onDispatch");
1615
return;
1716
}
17+
const testId = (data as { testId: string }).testId;
1818

1919
await admin
2020
.firestore()

integration_test/functions/src/v1/testLab-tests.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
import * as admin from "firebase-admin";
2-
import * as functions from "firebase-functions";
2+
import * as functions from "firebase-functions/v1";
33
import { REGION } from "../region";
44
import { sanitizeData } from "../utils";
55

6-
export const testLabOnCompleteTests: any = functions
6+
export const testLabOnCompleteTests = functions
77
.runWith({
88
timeoutSeconds: 540,
99
})
1010
.region(REGION)
1111
.testLab.testMatrix()
12-
.onComplete(async (matrix, context) => {
13-
const testId = matrix?.clientInfo?.details?.testId;
14-
if (!testId) {
15-
functions.logger.error("TestId not found for test matrix completion");
12+
.onComplete(async (matrix: unknown, context) => {
13+
if (!matrix || typeof matrix !== "object" || !("clientInfo" in matrix)) {
14+
functions.logger.error("Invalid matrix structure for test matrix completion");
1615
return;
1716
}
17+
const clientInfo = (matrix as { clientInfo: unknown }).clientInfo;
18+
if (!clientInfo || typeof clientInfo !== "object" || !("details" in clientInfo)) {
19+
functions.logger.error("Invalid clientInfo structure for test matrix completion");
20+
return;
21+
}
22+
const details = clientInfo.details;
23+
if (!details || typeof details !== "object" || !("testId" in details)) {
24+
functions.logger.error("Invalid details structure for test matrix completion");
25+
return;
26+
}
27+
const testId = details.testId as string;
1828

1929
await admin
2030
.firestore()

0 commit comments

Comments
 (0)