|
|
@@ -8,6 +8,10 @@ const { _electron: electron, expect } = req("@playwright/test")
|
|
|
|
|
|
;(async () => {
|
|
|
if (!process.argv[2]) throw new Error("Pass the packaged executable")
|
|
|
+ const upgradeIndex = process.argv.indexOf("--upgrade-from")
|
|
|
+ const previousExecutable = upgradeIndex < 0 ? undefined : process.argv[upgradeIndex + 1]
|
|
|
+ if (upgradeIndex >= 0 && !previousExecutable)
|
|
|
+ throw new Error("--upgrade-from requires the previous packaged executable")
|
|
|
const root = await fs.mkdtemp(path.join(require("node:os").tmpdir(), "lambda-release-"))
|
|
|
const profile = path.join(root, "profile")
|
|
|
const archive = path.join(root, "project.zip")
|
|
|
@@ -38,7 +42,9 @@ const { _electron: electron, expect } = req("@playwright/test")
|
|
|
})
|
|
|
await new Promise((resolve) => model.listen(0, "127.0.0.1", resolve))
|
|
|
const env = Object.fromEntries(
|
|
|
- Object.entries(process.env).filter(([key]) => !/^(AGENTPAAS_|AGENT_SERVICE_|PYTHONPATH$)|(_API_KEY|_TOKEN)$/.test(key)),
|
|
|
+ Object.entries(process.env).filter(
|
|
|
+ ([key]) => !/^(AGENTPAAS_|AGENT_SERVICE_|PYTHONPATH$)|(_API_KEY|_TOKEN)$/.test(key),
|
|
|
+ ),
|
|
|
)
|
|
|
Object.assign(env, {
|
|
|
OPENCODE_TEST_ONBOARDING: "1",
|
|
|
@@ -50,8 +56,8 @@ const { _electron: electron, expect } = req("@playwright/test")
|
|
|
let page
|
|
|
let connection
|
|
|
let userData
|
|
|
- const launch = async () => {
|
|
|
- app = await electron.launch({ executablePath: path.resolve(process.argv[2]), env, timeout: 60000 })
|
|
|
+ const launch = async (executable = process.argv[2]) => {
|
|
|
+ app = await electron.launch({ executablePath: path.resolve(executable), env, timeout: 60000 })
|
|
|
page = await app.firstWindow()
|
|
|
await page.waitForFunction(() => !!window.api?.paas)
|
|
|
userData = await app.evaluate(({ app }) => app.getPath("userData"))
|
|
|
@@ -73,7 +79,8 @@ const { _electron: electron, expect } = req("@playwright/test")
|
|
|
return data
|
|
|
}
|
|
|
try {
|
|
|
- const original = await launch()
|
|
|
+ const original = await launch(previousExecutable)
|
|
|
+ const previousVersion = await app.evaluate(({ app }) => app.getVersion())
|
|
|
const setup = await api("/desktop/setup")
|
|
|
for (const id of ["anthropic", "ollama"]) {
|
|
|
const provider = setup.providers.find((item) => item.id === id)
|
|
|
@@ -93,17 +100,20 @@ const { _electron: electron, expect } = req("@playwright/test")
|
|
|
const agentID = agent.agent_id || agent.id
|
|
|
const scope = await page.evaluate((agentID) => window.api.paas.request({ action: "task-scope", agentID }), agentID)
|
|
|
if (scope.agent_id !== agentID || scope.local_tools.length) throw new Error("Simple agent scope incorrect")
|
|
|
- await page.evaluate(({ id, folders }) => {
|
|
|
- window.nativeReleaseRun = window.api.paas.request({
|
|
|
- action: "execute",
|
|
|
- agentID: id,
|
|
|
- input: "验证后台运行",
|
|
|
- mode: "iterate",
|
|
|
- executionID: "native-release-owned",
|
|
|
- workDir: folders[0],
|
|
|
- workDirs: folders,
|
|
|
- })
|
|
|
- }, { id: agentID, folders })
|
|
|
+ await page.evaluate(
|
|
|
+ ({ id, folders }) => {
|
|
|
+ window.nativeReleaseRun = window.api.paas.request({
|
|
|
+ action: "execute",
|
|
|
+ agentID: id,
|
|
|
+ input: "验证后台运行",
|
|
|
+ mode: "iterate",
|
|
|
+ executionID: "native-release-owned",
|
|
|
+ workDir: folders[0],
|
|
|
+ workDirs: folders,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ { id: agentID, folders },
|
|
|
+ )
|
|
|
await expect.poll(() => calls, { timeout: 60000 }).toBeGreaterThan(0)
|
|
|
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].close())
|
|
|
await expect
|
|
|
@@ -163,6 +173,9 @@ const { _electron: electron, expect } = req("@playwright/test")
|
|
|
await app.close()
|
|
|
app = undefined
|
|
|
await launch()
|
|
|
+ const currentVersion = await app.evaluate(({ app }) => app.getVersion())
|
|
|
+ if (previousExecutable && currentVersion === previousVersion)
|
|
|
+ throw new Error("Upgrade acceptance requires different versions")
|
|
|
const saved = await api(`/agents/${agentID}/runs/${run.run_id}`)
|
|
|
if (saved.status !== "completed" || calls !== before) throw new Error("Relaunch lost or replayed task")
|
|
|
if (connection.scope !== original.scope) throw new Error("Managed workspace identity changed")
|
|
|
@@ -179,7 +192,8 @@ const { _electron: electron, expect } = req("@playwright/test")
|
|
|
backupRestored: true,
|
|
|
relaunchPreserved: true,
|
|
|
replayedCalls: calls - before,
|
|
|
- version: await app.evaluate(({ app }) => app.getVersion()),
|
|
|
+ version: currentVersion,
|
|
|
+ ...(previousExecutable ? { upgradedFrom: previousVersion } : {}),
|
|
|
},
|
|
|
null,
|
|
|
2,
|