Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Post text, images, videos, and long-form articles to X (Twitter) via real Chrome browser automation.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/x-utils.test.ts
1import assert from "node:assert/strict";2import test from "node:test";34import {5buildXSessionCookieMap,6hasChromeLockArtifacts,7hasRequiredXSessionCookies,8shouldRetryChromeLaunch,9} from "./x-utils.ts";1011test("hasChromeLockArtifacts detects Chrome singleton artifacts", () => {12assert.equal(hasChromeLockArtifacts(["SingletonSocket"]), true);13assert.equal(hasChromeLockArtifacts(["chrome.pid"]), true);14assert.equal(hasChromeLockArtifacts(["Cookies", "Preferences"]), false);15});1617test("shouldRetryChromeLaunch only retries when no live owner exists", () => {18assert.equal(19shouldRetryChromeLaunch({ lockArtifactsPresent: true, hasLiveOwner: false }),20true,21);22assert.equal(23shouldRetryChromeLaunch({ lockArtifactsPresent: true, hasLiveOwner: true }),24false,25);26assert.equal(27shouldRetryChromeLaunch({ lockArtifactsPresent: false, hasLiveOwner: false }),28false,29);30});3132test("buildXSessionCookieMap keeps only non-empty cookies", () => {33assert.deepEqual(34buildXSessionCookieMap([35{ name: "auth_token", value: "auth" },36{ name: "ct0", value: "csrf" },37{ name: "twid", value: "u=123" },38{ name: "ct0", value: "" },39{ name: "", value: "ignored" },40{ name: "gt", value: undefined },41]),42{43auth_token: "auth",44ct0: "csrf",45twid: "u=123",46},47);48});4950test("hasRequiredXSessionCookies requires auth_token and ct0", () => {51assert.equal(hasRequiredXSessionCookies({ auth_token: "auth" }), false);52assert.equal(hasRequiredXSessionCookies({ ct0: "csrf" }), false);53assert.equal(hasRequiredXSessionCookies({ auth_token: "auth", ct0: "csrf" }), true);54});55