|
6 | 6 | import { createReadStream, readFileSync } from "fs"; |
7 | 7 | import { OFSCredentials, OFSBulkUpdateRequest } from "../../src/model"; |
8 | 8 | import { OFS } from "../../src/OFS"; |
9 | | -import myCredentials from "../credentials_test.json"; |
| 9 | +import { getTestCredentials } from "../test_credentials"; |
10 | 10 | import { faker } from "@faker-js/faker"; |
11 | 11 |
|
12 | 12 | var myProxy: OFS; |
13 | 13 |
|
14 | 14 | // Setup info |
15 | 15 | beforeAll(() => { |
16 | | - myProxy = new OFS(myCredentials); |
17 | | - if ("instance" in myCredentials) { |
18 | | - expect(myProxy.instance).toBe(myCredentials.instance); |
| 16 | + const credentials = getTestCredentials(); |
| 17 | + myProxy = new OFS(credentials); |
| 18 | + if ("instance" in credentials) { |
| 19 | + expect(myProxy.instance).toBe(credentials.instance); |
19 | 20 | } else { |
20 | 21 | expect(myProxy.baseURL).toBe(myProxy.baseURL); |
21 | 22 | } |
@@ -525,3 +526,30 @@ test("Get Submitted Forms with Real Data - Activity 3954799", async () => { |
525 | 526 | console.log('⚠ No submitted forms found for this activity'); |
526 | 527 | } |
527 | 528 | }); |
| 529 | + |
| 530 | +test("Get Linked Activities for Activity", async () => { |
| 531 | + var aid = 4225599; // sample activity id |
| 532 | + var result = await myProxy.getLinkedActivities(aid); |
| 533 | + // API may return 200 with an items array or 200 with empty result |
| 534 | + expect(result.status).toBeGreaterThanOrEqual(200); |
| 535 | + expect(result.status).toBeLessThan(400); |
| 536 | + // If data contains items, ensure it's an array |
| 537 | + if (result.data && result.data.items) { |
| 538 | + expect(Array.isArray(result.data.items)).toBe(true); |
| 539 | + } |
| 540 | +}); |
| 541 | + |
| 542 | +test("Get Activity Link Type", async () => { |
| 543 | + var aid = 4225599; // sample activity id |
| 544 | + var linkedActivityId = 4225600; // sample linked activity id |
| 545 | + var linkType = "requires"; // example link type |
| 546 | + var result = await myProxy.getActivityLinkType(aid, linkedActivityId, linkType); |
| 547 | + // API may return 200 with link type info |
| 548 | + expect(result.status).toBeGreaterThanOrEqual(200); |
| 549 | + expect(result.status).toBeLessThan(400); |
| 550 | + // If successful response, check link type is returned |
| 551 | + if (result.status === 200) { |
| 552 | + expect(result.data).toHaveProperty('linkType'); |
| 553 | + expect(typeof result.data.linkType).toBe('string'); |
| 554 | + } |
| 555 | +}); |
0 commit comments