wip: snapshot das alterações não commitadas (2026-10-20)

Origem: D:/Documents/Github/PiAgentUI/PiAgentUi
Arquivos omitidos (segredos, bancos de dados, logs, >50 MB): 4
This commit is contained in:
Evandro committed 2026-10-20 00:48:28 -03:00
1 parent b3489e1ede
commit 98b5db029f
70 files changed
+9466 -9191

No files matched your search

+87
View File
@@ -0,0 +1,87 @@
import fs from 'node:fs'
import path from 'node:path'
import assert from 'node:assert/strict'
const markerPath = path.join(process.env.PIAGENTUI_E2E_MARKER_DIR ?? '', 'fake-pi-state.json')
async function readMarker() {
await browser.waitUntil(() => fs.existsSync(markerPath), {
timeout: 15000,
timeoutMsg: `Fake Pi marker was not created at ${markerPath}`,
})
return JSON.parse(fs.readFileSync(markerPath, 'utf8'))
}
async function textExists(text) {
const element = await $(`//*[contains(normalize-space(), ${JSON.stringify(text)})]`)
return element.isExisting()
}
describe('PiAgentUI first-run desktop onboarding', () => {
before(async () => {
await browser
.waitUntil(async () => (await browser.getUrl()) !== 'about:blank', { timeout: 10000 })
.catch(async () => {
await browser.url('http://tauri.localhost/')
})
})
it('starts an isolated Pi backend and opens the provider catalog', async () => {
await browser.waitUntil(() => textExists('Connect a model provider'), {
timeout: 45000,
timeoutMsg: 'Provider onboarding did not appear',
})
assert.equal(await textExists('First run setup'), true)
assert.equal(await textExists('OpenCode Zen'), true)
assert.equal(await textExists('DeepSeek V4 Flash'), true)
assert.equal(await textExists('Anthropic'), true)
assert.equal(await textExists('Google'), true)
assert.equal(await textExists('API key'), true)
assert.equal(await textExists('OAuth'), true)
const marker = await readMarker()
assert.match(marker.agentDir, /pi-runtime/)
assert.match(marker.agentDir, /agent/)
assert.equal(marker.sessionDir, path.join(marker.agentDir, 'sessions'))
assert.equal(marker.startupArgs.includes('--extension'), true)
assert.equal(
marker.startupArgs.some(arg => arg.endsWith('piagentui-server.ts')),
true,
)
assert.equal(
marker.requests.some(request => request.path === '/api/providers'),
true,
)
})
it('filters providers, saves an API key, and exits first-run onboarding', async () => {
const search = await $('input[placeholder*="Search providers"]')
await search.setValue('claude')
assert.equal(await textExists('Anthropic'), true)
assert.equal(await textExists('OpenCode Zen'), false)
await search.setValue('deepseek v4 flash')
assert.equal(await textExists('DeepSeek V4 Flash'), true)
assert.equal(await textExists('OpenCode Zen'), true)
const addKey = await $('//button[normalize-space()="Add key"]')
await addKey.click()
const keyInput = await $('input[placeholder="Paste API key"]')
await keyInput.setValue('test-key-from-e2e')
await $('//button[normalize-space()="Save key"]').click()
await browser.waitUntil(async () => !(await textExists('Connect a model provider')), {
timeout: 15000,
timeoutMsg: 'Onboarding did not close after saving provider auth',
})
const marker = await readMarker()
assert.equal(marker.apiKeyConfigured, true)
assert.equal(marker.lastApiKeyLength, 'test-key-from-e2e'.length)
assert.equal(
marker.requests.some(request => request.path === '/api/providers/opencode/api-key'),
true,
)
})
})