Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Post articles and image-text content to WeChat Official Account via API or Chrome CDP, with markdown-to-WeChat HTML conversion.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/wechat-article-focus.test.ts
1import assert from "node:assert/strict";2import fs from "node:fs";3import path from "node:path";4import test from "node:test";5import { fileURLToPath } from "node:url";67const __filename = fileURLToPath(import.meta.url);8const __dirname = path.dirname(__filename);9const articleScript = fs.readFileSync(path.join(__dirname, "wechat-article.ts"), "utf8");1011test("browser article paste uses CDP-targeted paste instead of global macOS keystrokes", () => {12assert.equal(13articleScript.includes('tell application "System Events" to keystroke "v" using command down'),14false,15);16});1718test("browser article publishing verifies the title before saving drafts", () => {19assert.match(articleScript, /verifyTitleUnchangedBeforeSave/);20assert.match(articleScript, /Title was modified during paste/);21});2223test("browser article body insertion does not paste HTML through the active form field", () => {24assert.match(articleScript, /insertHtmlIntoEditorFromFile/);25assert.doesNotMatch(articleScript, /await copyHtmlFromBrowser\(cdp, effectiveHtmlFile, contentImages\)/);26});2728test("browser article body operations target the body ProseMirror, not the title ProseMirror", () => {29assert.match(articleScript, /BODY_EDITOR_SELECTOR = '\.rich_media_content \.ProseMirror'/);30assert.doesNotMatch(articleScript, /clickElement\(session, '\\.ProseMirror'\)/);31});3233test("browser article reuses the selected account Chrome profile before launching", () => {34assert.match(articleScript, /await findExistingChromeDebugPort\(profileDir\)/);35});3637test("browser article inserts inline images through WeChat local upload instead of clipboard paste", () => {38assert.match(articleScript, /uploadImageThroughFileInput/);39assert.match(articleScript, /DOM\.setFileInputFiles/);40assert.doesNotMatch(articleScript, /await copyImageToClipboard\(img\.localPath\)/);41});4243test("browser article uploads original images before fallback processing", () => {44const rawUploadIndex = articleScript.indexOf("await uploadImagePathThroughFileInput(session, absolutePath, beforeCount)");45const fallbackIndex = articleScript.indexOf("const fallback = await prepareFallbackWechatBodyImageUpload(absolutePath)");4647assert.notEqual(rawUploadIndex, -1);48assert.notEqual(fallbackIndex, -1);49assert.ok(rawUploadIndex < fallbackIndex);50assert.match(articleScript, /prepareWechatBodyImageUpload/);51assert.match(articleScript, /Raw image upload failed, retrying with fallback processing/);52});5354test("browser article waits for a saved draft appmsgid before reporting success", () => {55assert.match(articleScript, /waitForDraftSaved/);56assert.match(articleScript, /appmsgid/);57assert.doesNotMatch(articleScript, /Waiting for save confirmation/);58});59