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'); async function seedReadyScenario(page: Page, assistantAction?: Record) { await page.addInitScript({ path: scenarioSeedPath }); await page.addInitScript((action) => { window.__seedIpOperatorScenario?.('ready'); localStorage.setItem('tiktok.currentTab', 'ip-operator'); if (action) { sessionStorage.setItem('videoWorkflow.ipOperator.assistantAction', JSON.stringify(action)); } }, assistantAction || null); } test('assistant medium-risk action enters confirmation queue', async ({ page }) => { await seedReadyScenario(page, { action: 'approve_publish_package', label: '批准发布包', reason: '会影响发布决策,需要人工确认。', }); await page.goto('/'); await expect(page.locator('.assistant-confirm-panel')).toBeVisible(); await expect(page.locator('.assistant-confirm-panel')).toContainText('批准发布包'); await expect(page.locator('.assistant-confirm-panel')).toContainText('确认执行'); }); test('assistant blocked automation action is rejected', async ({ page }) => { await seedReadyScenario(page, { action: 'auto_comment', label: '自动评论', reason: '涉及平台互动自动化。', }); await page.goto('/'); await expect(page.locator('.assistant-confirm-panel__blocked')).toBeVisible(); await expect(page.locator('.assistant-confirm-panel__blocked')).toContainText('禁止执行'); }); test('matrix governance remains available while scheduled monitor placeholder is removed', async ({ page }) => { await seedReadyScenario(page); await page.goto('/'); await expect(page.locator('.monitor-schedule-panel')).toHaveCount(0); await expect(page.locator('.legacy-plan-archive')).toHaveCount(0); await expect(page.locator('.account-manager-panel')).toContainText('运营账号生命周期'); await expect(page.locator('.account-workbench')).toContainText('发布复盘'); });