import { expect, Page, test } from '@playwright/test'; import path from 'node:path'; declare global { interface Window { __seedIpOperatorScenario?: (scenario: 'ready') => unknown; } } const scenarioSeedPath = path.resolve(__dirname, '../scripts/validation/ip-operator-scenario-seed.js'); const planKey = 'tiktok.ipOperator.plan.ip_plan_e2e_ready.local-guest'; async function seedP2Scenario(page: Page) { await page.addInitScript({ path: scenarioSeedPath }); await page.addInitScript(() => { window.__seedIpOperatorScenario?.('ready'); localStorage.setItem('tiktok.currentTab', 'ip-operator'); }); } test('P2 core keeps account evidence connected to direction topics and production actions', async ({ page }) => { await seedP2Scenario(page); await page.goto('/'); await expect(page.locator('.ip-operator-page')).toBeVisible(); await expect(page.locator('.account-monitor-panel')).toContainText('账号内容与数据'); await page.getByRole('button', { name: /方向选题/ }).click(); const firstTopicCard = page.locator('.direction-topic-card').first(); await expect(firstTopicCard).toBeVisible(); await expect(firstTopicCard).toContainText('来源证据'); await firstTopicCard.getByRole('button', { name: /生成分镜脚本|分镜脚本已生成/ }).click(); await expect(page.locator('.shot-script-modal')).toBeVisible(); await expect(page.locator('.shot-script-modal')).toContainText('核心观点'); await page.locator('.shot-script-modal__close').click(); await firstTopicCard.getByRole('button', { name: '生成发布包' }).click(); await expect(page.locator('.workspace-tabs button.is-active')).toContainText('发布复盘'); await expect.poll(async () => page.evaluate((nextPlanKey) => { const plan = JSON.parse(localStorage.getItem(nextPlanKey) || '{}'); return (plan.publishPackages || []).length; }, planKey)).toBeGreaterThan(0); });