Skip to content

Commit eb4d4f9

Browse files
authored
feat: add e2e test script for all platform features (#588) (#598)
- Adds `test-all-features.ts` to easily run through all major LinkedIn features - Uses `testAutoConfirm` to automatically confirm prepared actions during testing - Helps quickly identify broken selectors (like the post visibility option or groups creation modal) Closes #588
1 parent 65643d8 commit eb4d4f9

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
* Test script to run through all major LinkedIn tools to verify selectors and functionality.
3+
* This runs against the connected profile and uses testAutoConfirm to automatically confirm prepared actions.
4+
*/
5+
import { createCoreRuntime, createDefaultTestAutoConfirmConfig } from "@linkedin-buddy/core";
6+
7+
async function run() {
8+
console.log("Starting full feature test suite...");
9+
const runtime = createCoreRuntime({
10+
testAutoConfirm: { ...createDefaultTestAutoConfirmConfig(), enabled: true }
11+
});
12+
13+
try {
14+
const profileName = "default";
15+
16+
console.log("\n1. Testing Profile View");
17+
try {
18+
await runtime.profile.viewProfile({ profileName, target: "https://www.linkedin.com/in/me/" });
19+
console.log("✅ Profile view worked");
20+
} catch (e: unknown) { console.error("❌ Profile view failed:", (e as Error).message); }
21+
22+
console.log("\n2. Testing Post Creation");
23+
try {
24+
const postPrep = await runtime.posts.prepareCreate({
25+
profileName,
26+
text: "Automated test post from test suite.",
27+
visibility: "public"
28+
});
29+
await runtime.twoPhaseCommit.confirmByToken({ confirmToken: postPrep.confirmToken });
30+
console.log("✅ Post creation worked");
31+
} catch (e: unknown) { console.error("❌ Post creation failed:", (e as Error).message); }
32+
33+
console.log("\n3. Testing Newsletter Creation");
34+
try {
35+
const newsPrep = await runtime.newsletters.prepareCreate({
36+
profileName,
37+
title: "Test Newsletter",
38+
description: "Test description for automation",
39+
cadence: "weekly"
40+
});
41+
await runtime.twoPhaseCommit.confirmByToken({ confirmToken: newsPrep.confirmToken });
42+
console.log("✅ Newsletter creation worked");
43+
} catch (e: unknown) { console.error("❌ Newsletter creation failed:", (e as Error).message); }
44+
45+
console.log("\n4. Testing Job Alerts");
46+
try {
47+
const alertPrep = await runtime.jobs.prepareCreateJobAlert({
48+
profileName,
49+
query: "Software Engineer",
50+
location: "Remote",
51+
frequency: "daily"
52+
});
53+
await runtime.twoPhaseCommit.confirmByToken({ confirmToken: alertPrep.confirmToken });
54+
console.log("✅ Job alert created");
55+
} catch (e: unknown) { console.error("❌ Job alert creation failed:", (e as Error).message); }
56+
57+
console.log("\n5. Testing Groups (Search, Create, Join)");
58+
try {
59+
const groupSearch = await runtime.groups.searchGroups({ profileName, query: "Test Group", limit: 1 });
60+
if (groupSearch.results.length > 0) {
61+
const joinPrep = await runtime.groups.prepareJoinGroup({ profileName, group: groupSearch.results[0].group_url });
62+
await runtime.twoPhaseCommit.confirmByToken({ confirmToken: joinPrep.confirmToken });
63+
console.log("✅ Group join worked");
64+
}
65+
66+
const createGroup = await runtime.groups.prepareCreateGroup({
67+
profileName,
68+
name: "Test Group " + Date.now(),
69+
description: "Test description"
70+
});
71+
await runtime.twoPhaseCommit.confirmByToken({ confirmToken: createGroup.confirmToken });
72+
console.log("✅ Group creation worked");
73+
} catch (e: unknown) { console.error("❌ Group tests failed:", (e as Error).message); }
74+
75+
console.log("\n6. Testing Events (Search, Create, RSVP)");
76+
try {
77+
const eventSearch = await runtime.events.searchEvents({ profileName, query: "Tech Meetup", limit: 1 });
78+
if (eventSearch.results.length > 0) {
79+
const rsvpPrep = await runtime.events.prepareRsvp({ profileName, event: eventSearch.results[0].event_url });
80+
await runtime.twoPhaseCommit.confirmByToken({ confirmToken: rsvpPrep.confirmToken });
81+
console.log("✅ Event RSVP worked");
82+
}
83+
84+
const createEvent = await runtime.events.prepareCreateEvent({
85+
profileName,
86+
name: "Test Event " + Date.now(),
87+
description: "Test description",
88+
startDate: "2026-10-10",
89+
startTime: "10:00",
90+
endDate: "2026-10-10",
91+
endTime: "11:00",
92+
online: true
93+
});
94+
await runtime.twoPhaseCommit.confirmByToken({ confirmToken: createEvent.confirmToken });
95+
console.log("✅ Event creation worked");
96+
} catch (e: unknown) { console.error("❌ Event tests failed:", (e as Error).message); }
97+
98+
} finally {
99+
runtime.close();
100+
}
101+
}
102+
103+
run().catch(console.error);

0 commit comments

Comments
 (0)