import { mkdtemp, rm } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import path from 'node:path'; import { closeElectronApp, expect, getStableWindow, test } from './fixtures/electron'; test.describe('Project-level Superpowers setting', () => { test('starts publishable projects with Superpowers disabled and only the one-click release entry', async ({ launchElectronApp }) => { const parentPath = await mkdtemp(path.join(tmpdir(), 'niancode-superpowers-e2e-')); const app = await launchElectronApp({ skipSetup: true }); try { await app.evaluate(({ ipcMain }, selectedPath) => { ipcMain.removeHandler('dialog:open'); ipcMain.handle('dialog:open', async () => ({ canceled: false, filePaths: [selectedPath] })); }, parentPath); const page = await getStableWindow(app); await page.getByTestId('sidebar-create-project').click(); await expect(page.getByRole('radio', { name: '小游戏' })).toBeChecked(); await expect(page.getByRole('radio', { name: '小程序' })).not.toBeChecked(); await expect(page.getByRole('radio', { name: '自定义项目' })).not.toBeChecked(); await page.getByRole('radio', { name: '小程序' }).click(); await expect(page.getByRole('radio', { name: '小程序' })).toBeChecked(); await page.getByRole('radio', { name: '小游戏' }).click(); await expect(page.getByRole('radio', { name: '直接使用所选文件夹(默认)' })).toBeChecked(); await page.getByRole('button', { name: '选择路径' }).click(); await expect(page.getByLabel('项目路径')).toHaveValue(parentPath); await page.getByRole('button', { name: '确认创建' }).click(); await expect(page.getByTestId('project-configuration-page')).toBeVisible(); await expect(page.getByTestId('sidebar-nav-publish')).toHaveCount(0); await expect(page.getByText(/新项目还没有联系人/)).toBeVisible(); await expect(page.getByRole('button', { name: '新增伙伴' })).toBeVisible(); await page.getByTestId('resource-card-skills').click(); await expect(page.getByRole('switch', { name: '启用 Superpowers' })).toHaveAttribute('aria-checked', 'false'); await expect(page.getByText('已关闭')).toBeVisible(); await page.getByRole('button', { name: '关闭' }).click(); await expect(page.getByTestId('resource-card-publish')).toHaveCount(0); await expect(page.getByRole('button', { name: '一键提交审核' })).toHaveCount(1); await expect(page.getByText('自动部署', { exact: false })).toHaveCount(0); await expect(page.getByText('部署发布检查', { exact: false })).toHaveCount(0); } finally { await closeElectronApp(app); await rm(parentPath, { recursive: true, force: true }); } }); });