Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

TikTok draft closes Studio's onboarding tooltips before writing the caption

[._.]/ Adam Eivy66575f61502b
diff --git a/server/services/musicVideo/publish/tiktok.js b/server/services/musicVideo/publish/tiktok.js
index 60ddd35185..20c106698b 100644
--- a/server/services/musicVideo/publish/tiktok.js
+++ b/server/services/musicVideo/publish/tiktok.js
@@ -8,6 +8,23 @@ import { PUBLISH_STEP_TIMEOUT_MS as T, clickVisibleText, loginRequired, replaceE
const UPLOAD_URL = 'https://www.tiktok.com/tiktokstudio/upload';
const label = 'TikTok';
+const TOUR = '.react-joyride__overlay';
+
+/**
+ * Close TikTok Studio's onboarding tooltips ("Preview your video on your
+ * phone"…). Their overlay covers the whole form, so every click times out
+ * until it is gone. A tour can chain several steps, and once dismissed it does
+ * not come back for the account.
+ */
+async function dismissStudioTour(page, { attempts = 5 } = {}) {
+ for (let i = 0; i < attempts; i += 1) {
+ if (!(await page.locator(TOUR).count())) return true;
+ const closed = await clickVisibleText(page, 'Got it').then(() => true, () => clickVisibleText(page, 'Skip').then(() => true, () => false));
+ if (!closed) await page.keyboard.press('Escape');
+ await page.waitForTimeout(800);
+ }
+ return !(await page.locator(TOUR).count());
+}
export const tiktokAdapter = {
label,
@@ -17,6 +34,9 @@ export const tiktokAdapter = {
if (/\/login/.test(page.url())) throw loginRequired(label, UPLOAD_URL);
await step(label, 'upload the video', () => page.locator('input[type=file][accept*=video]').first().setInputFiles(payload.video.path, { timeout: T }));
await step(label, 'wait for the caption editor', () => page.locator('[contenteditable=true]').first().waitFor({ timeout: T }));
+ await step(label, 'close the Studio tour', async () => {
+ if (!(await dismissStudioTour(page))) throw new Error('an onboarding tooltip still covers the form');
+ });
if (payload.caption) {
await step(label, 'write the caption', () => replaceEditorText(page, '[contenteditable=true]', payload.caption));
await page.keyboard.press('Escape'); // closes the hashtag suggestion popup, nothing else
diff --git a/server/services/musicVideo/publish/tiktok.test.js b/server/services/musicVideo/publish/tiktok.test.js
new file mode 100644
index 0000000000..7b2ea2c759
--- /dev/null
+++ b/server/services/musicVideo/publish/tiktok.test.js
@@ -0,0 +1,58 @@
+import { describe, it, expect } from 'vitest';
+import { tiktokAdapter } from './tiktok.js';
+
+// TikTok Studio's upload page with `tourSteps` onboarding tooltips over the
+// form. Each "Got it" closes one; the overlay swallows clicks while it is up.
+const fakePage = ({ tourSteps = 0, closes = true } = {}) => {
+ let tour = tourSteps;
+ const calls = { editorClickedUnderTour: false, editorClicked: false, escapes: 0 };
+ const page = {
+ calls,
+ goto: async () => {},
+ url: () => 'https://www.tiktok.com/tiktokstudio/upload',
+ waitForTimeout: async () => {},
+ keyboard: { press: async (k) => { if (k === 'Escape') calls.escapes += 1; } },
+ evaluate: async (_fn, arg) => {
+ if (Array.isArray(arg) && arg[1] === 'Got it') { if (!tour) return false; if (closes) tour -= 1; return true; }
+ if (Array.isArray(arg) && arg[1] === 'Skip') return false;
+ return true;
+ },
+ locator: (sel) => {
+ const node = {
+ count: async () => (sel === '.react-joyride__overlay' ? (tour ? 1 : 0) : 1),
+ waitFor: async () => {},
+ setInputFiles: async () => {},
+ click: async () => {
+ if (sel === '[contenteditable=true]') { calls.editorClicked = true; if (tour) calls.editorClickedUnderTour = true; }
+ if (sel === 'text=Show more') throw new Error('stop here');
+ },
+ first: () => node,
+ };
+ return node;
+ },
+ };
+ return page;
+};
+
+const payload = { video: { path: '/tmp/v.mp4' }, caption: 'hello' };
+
+describe('TikTok Studio tour', () => {
+ it('closes every onboarding tooltip before writing the caption', async () => {
+ const page = fakePage({ tourSteps: 2 });
+ await expect(tiktokAdapter.prepare(page, payload)).rejects.toThrow(/stop here/);
+ expect(page.calls.editorClicked).toBe(true);
+ expect(page.calls.editorClickedUnderTour).toBe(false);
+ });
+
+ it('goes straight on when there is no tour', async () => {
+ const page = fakePage();
+ await expect(tiktokAdapter.prepare(page, payload)).rejects.toThrow(/stop here/);
+ expect(page.calls.escapes).toBeGreaterThanOrEqual(1); // only the hashtag-popup Escape after the caption
+ });
+
+ it('names the tooltip instead of timing out on the caption when it will not close', async () => {
+ const page = fakePage({ tourSteps: 1, closes: false });
+ await expect(tiktokAdapter.prepare(page, payload)).rejects.toThrow(/close the Studio tour.*onboarding tooltip/);
+ expect(page.calls.editorClicked).toBe(false);
+ });
+});