Renzexi01 on X (一进来就这么复杂): a new user saw Get started and, under
it, every agent found on the computer at once. While the Get started card
shows and no agent is in use yet, the whole Agents list is folded under
it behind "Show all {n} agents" (en, zh, zh-TW, ja, de); the card's
second step already names the agents found, each connected in a click.
Once one is connected, or the card is put away, the list is as before:
the ones in use in view, the rest under "Show {n} more".
getting-started checks the list folded under the card, the button's
words and aria-expanded in every language, and the list back once an
agent is connected or the card put away. Tests whose fake state is a new
user with no agent in use, and which read the agents' rows, now set
guideHidden as a user past Get started has (account-arrange,
aside-native, agent-*, claude-picker-magpie-first, codex-accounts-via,
omp-profile-connect, picker-rail-current, picker-speeds, pop-phone-room,
reasonix-roles, snow-fields).
What was run, on mote through mote-run, at a9a82a1c3 (tree e91b8e625,
the same as this commit once its fixup was squashed in), on base
0872bc2a0:
- The whole GUI suite (node --test --test-concurrency=4
internal/gui/tests/*.test.cjs, both engines, every language), while
mote ran 14 other test processes: 18901 pass, 292 fail in 57 files.
- Those 57 files again at a9a82a1c3 (concurrency 2): 748 pass, 275 fail;
at 0872bc2a0: 756 pass, 267 fail. 43 files were red at both, most with
the same counts (model-chip-steady 40/40, usage-agents-hide 22/22,
segs-press-redraw 16/16, provider-fetch-again 14/14).
- Those 43 at origin/main e17b6cefc: 442 pass, 262 fail, the same files
with the same counts. Each has an open issue (among them #4388, #4566,
#3414, #5057, #5013, #4320, #4585, #4625).
- The 7 files red at a9a82a1c3 only, alone (concurrency 1): 79 of 82
pass at a9a82a1c3 (group-found-skip 1, name-suffix-remote 2), 76 of 82
at 0872bc2a0 (group-found-skip, images-codex-one 2, name-suffix-remote,
title-bar-tools 2): load, nothing red at the head alone that is not red
at the base alone. name-suffix-remote, red alone at both, is #5147;
group-found-skip is #4617.
- getting-started and group-switch-add-many at a9a82a1c3: 64 of 64 pass.
Broken by hand: app.js and plugins/routing/client.js put back to
0872bc2a0 (tests and i18n kept), the same two test files: 30 of 64 red.
getting-started went red in all 30 of its "Get started ticks from state"
cases ("no agent row in view under Get started").
Not tried: the real app with a fresh HOME (macOS, Linux WebKitGTK,
Windows), and the tray panel beyond the test's panel layout.
180 lines
12 KiB
JavaScript
180 lines
12 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs/promises');
|
|
const path = require('node:path');
|
|
const { test } = require('node:test');
|
|
const { chromium, webkit } = require('playwright');
|
|
const assets = path.resolve(__dirname, '../assets');
|
|
|
|
for (const engine of ['chromium', 'webkit']) {
|
|
for (const lang of ['en', 'zh']) {
|
|
test(`${engine} ${lang}: Aside provider connection is independent of model selection`, async (t) => {
|
|
const browser = await (engine === 'webkit' ? webkit.launch() : chromium.launch({ channel: 'chromium' }));
|
|
t.after(() => browser.close());
|
|
const page = await browser.newPage({ viewport: { width: 980, height: 760 }, reducedMotion: 'reduce' });
|
|
const posts = [], errors = [];
|
|
page.on('pageerror', (e) => errors.push(e.message));
|
|
const a = {
|
|
id: 'aside', name: 'Aside', icon: 'aside', path: '~/.aside/u/0/settings.json',
|
|
native: { provider: 'disconnected', runtime: 'applied', fields: { image: { value: 'magpie/art/gpt-image-1', status: 'unverified', detail: "Image generation is configured, but Aside's image provider support has not been verified" } } },
|
|
fields: [
|
|
{ key: 'model', label: 'model', value: 'minimax/native', options: [{ value: 'minimax/native', label: 'Native MiniMax' }, { value: 'magpie/relay/m1', ref: 'relay/m1', label: 'Magpie model' }] },
|
|
{ key: 'image', label: 'image', value: 'magpie/art/gpt-image-1', options: [{ value: 'magpie/art/gpt-image-1', ref: 'art/gpt-image-1', label: 'GPT image' }] },
|
|
],
|
|
};
|
|
const state = () => ({ agents: [a], profiles: [], settings: { lang, theme: 'light', guideHidden: true } });
|
|
await page.route('**/*', async (route) => {
|
|
const req = route.request(), url = new URL(req.url()), p = url.pathname;
|
|
if (req.method() === 'POST') posts.push(p);
|
|
if (p === '/boot.js') return route.fulfill({ contentType: 'text/javascript', body: `window.bootPrefs=${JSON.stringify({ lang, theme: 'light', web: true })}` });
|
|
if (p === '/api/state') return route.fulfill({ json: state() });
|
|
if (p === '/api/agents/connect/aside') { a.wired = true; a.native.provider = 'connected'; return route.fulfill({ json: { ...state(), connected: { how: 'joined' } } }); }
|
|
if (p === '/api/agents/preview/aside') return route.fulfill({ json: { revision: "provider-plan", changes: [{ path: '~/.aside/u/0/models.json', lines: [{ op: '-', text: 'providers.magpie' }] }] } });
|
|
if (p === '/api/agents/disconnect/aside') { a.wired = false; a.native.provider = 'disconnected'; return route.fulfill({ json: state() }); }
|
|
if (p === '/api/providers') return route.fulfill({ json: { providers: [], presets: [], gateway: { running: true } } });
|
|
if (p === '/api/groups') return route.fulfill({ json: { groups: [] } });
|
|
if (p === '/api/plugins') return route.fulfill({ json: { plugins: [] } });
|
|
if (p === '/api/usage/quotas') return route.fulfill({ json: [] });
|
|
if (p === '/api/agents/cli') return route.fulfill({ json: { agents: {}, pending: false } });
|
|
if (p.startsWith('/api/')) return route.fulfill({ json: {} });
|
|
const file = path.join(assets, p === '/' ? 'index.html' : p);
|
|
return route.fulfill({ body: await fs.readFile(file), contentType: { '.js': 'text/javascript', '.html': 'text/html', '.css': 'text/css', '.svg': 'image/svg+xml' }[path.extname(file)] });
|
|
});
|
|
await page.goto('http://magpie.test/?view=agents');
|
|
const row = page.locator('.row.agent[data-id="aside"]');
|
|
await row.locator('.ag-start').waitFor();
|
|
assert.match(await row.locator('.ag-start').textContent(), /Native MiniMax/);
|
|
await row.locator('.ag-conn').click();
|
|
await page.waitForFunction(() => document.querySelector('[data-id="aside"] .ag-conn')?.getAttribute('aria-checked') === 'true');
|
|
assert.match(await row.locator('.ag-start').textContent(), /Native MiniMax/);
|
|
assert.equal(await row.locator('.ag-fix').count(), 0, 'image warning does not offer a provider reconnect');
|
|
await row.locator('.ag-link').click();
|
|
await row.locator('.ag-exp').waitFor();
|
|
assert.match(await row.locator('.ag-exp').textContent(), lang === 'zh' ? /已配置图片生成/ : /Image generation is configured/);
|
|
assert.deepEqual(posts, ['/api/agents/connect/aside'], 'opening details sends no mutation');
|
|
await row.locator('.ag-conn').click();
|
|
const ask = page.locator('.disconnect-ask');
|
|
await ask.waitFor();
|
|
await ask.locator('.bar button').last().click();
|
|
await ask.waitFor({ state: 'detached' });
|
|
assert.match(await row.locator('.ag-start').textContent(), /Native MiniMax/);
|
|
assert.deepEqual(posts, ['/api/agents/connect/aside', '/api/agents/disconnect/aside']);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|
|
|
|
for (const engine of ['chromium', 'webkit']) {
|
|
for (const lang of ['en', 'zh']) {
|
|
test(`${engine} ${lang}: unavailable operation requires a separate offline confirmation`, async (t) => {
|
|
const browser = await (engine === 'webkit' ? webkit.launch() : chromium.launch({ channel: 'chromium' }));
|
|
t.after(() => browser.close());
|
|
const page = await browser.newPage({ viewport: { width: 980, height: 760 } });
|
|
page.setDefaultTimeout(5000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
const posts = [], errors = [];
|
|
page.on('pageerror', e => errors.push(e.message));
|
|
let failure = { error: 'Aside settings could not be read', code: 'runtime_unavailable', offline: 'stage' };
|
|
let revision = 'confirmed-plan';
|
|
let failPreview = false, releasePreview = null, blockPreview = false;
|
|
const a = {
|
|
id: 'aside', name: 'Aside', icon: 'aside', wired: true, path: '~/.aside/u/0/settings.json',
|
|
native: { provider: 'connected', runtime: 'applied', fields: {} },
|
|
fields: [{ key: 'model', label: 'model', value: 'native/current', options: [{ value: 'native/current', label: 'Current model' }, { value: 'magpie/relay/m1', ref: 'relay/m1', label: 'New model' }] }],
|
|
};
|
|
const current = () => ({ agents: [a], profiles: [], settings: { lang, theme: 'light', guideHidden: true } });
|
|
await page.route('**/*', async route => {
|
|
const req = route.request(), p = new URL(req.url()).pathname;
|
|
if (req.method() === 'POST') posts.push({ path: p, body: req.postDataJSON() });
|
|
if (p === '/boot.js') return route.fulfill({ contentType: 'text/javascript', body: `window.bootPrefs=${JSON.stringify({ lang, theme: 'light', web: true })}` });
|
|
if (p === '/api/state') return route.fulfill({ json: current() });
|
|
if (p === '/api/set') return route.fulfill({ status: 400, json: failure });
|
|
if (p === '/api/agents/stage/aside') { a.fields[0].value = req.postDataJSON().value; return route.fulfill({ json: current() }); }
|
|
if (p === '/api/agents/preview/aside') {
|
|
if (blockPreview) await new Promise(resolve => { releasePreview = resolve; });
|
|
return route.fulfill({ json: failPreview ? { error: 'No restore point' } : { revision, changes: [{ path: a.path, lines: [{ op: '~', text: 'native/current', was: 'magpie/relay/m1' }] }] } });
|
|
}
|
|
if (p === '/api/agents/disconnect/aside') return route.fulfill({ status: 400, json: { error: 'Aside unavailable', code: 'runtime_unavailable', offline: 'disconnect' } });
|
|
if (p === '/api/agents/disconnect-offline/aside') {
|
|
if (req.postDataJSON().revision !== revision) return route.fulfill({ status: 400, json: { error: 'Disconnect preview changed; preview it again' } });
|
|
a.wired = false; a.native.provider = 'disconnected'; return route.fulfill({ json: current() });
|
|
}
|
|
if (p === '/api/providers') return route.fulfill({ json: { providers: [], presets: [], gateway: { running: true } } });
|
|
if (p === '/api/groups') return route.fulfill({ json: { groups: [] } });
|
|
if (p === '/api/plugins') return route.fulfill({ json: { plugins: [] } });
|
|
if (p === '/api/usage/quotas') return route.fulfill({ json: [] });
|
|
if (p === '/api/agents/cli') return route.fulfill({ json: { agents: {}, pending: false } });
|
|
if (p.startsWith('/api/')) return route.fulfill({ json: {} });
|
|
const file = path.join(assets, p === '/' ? 'index.html' : p);
|
|
return route.fulfill({ body: await fs.readFile(file), contentType: { '.js': 'text/javascript', '.html': 'text/html', '.css': 'text/css', '.svg': 'image/svg+xml' }[path.extname(file)] });
|
|
});
|
|
await page.goto('http://magpie.test/?view=agents');
|
|
const row = page.locator('.row.agent[data-id="aside"]');
|
|
await row.locator('.ag-start').waitFor();
|
|
const pick = () => page.evaluate(() => setPick(state.agents[0], state.agents[0].fields[0], 'magpie/relay/m1'));
|
|
await pick();
|
|
const ask = page.locator('.disconnect-ask');
|
|
await ask.waitFor();
|
|
assert.equal(posts.filter(p => p.path.includes('/stage/')).length, 0);
|
|
await ask.locator('.bar button').first().click();
|
|
await ask.waitFor({ state: 'detached' });
|
|
assert.match(await row.locator('.ag-start').textContent(), /Current model/);
|
|
await pick();
|
|
await ask.waitFor();
|
|
await page.keyboard.press('Escape');
|
|
await ask.waitFor({ state: 'detached' });
|
|
assert.equal(posts.filter(p => p.path.includes('/stage/')).length, 0);
|
|
failure = { error: 'Generic refusal' };
|
|
await pick();
|
|
assert.equal(await ask.count(), 0, 'generic refusal offers no fallback');
|
|
failure = { error: 'Effort unavailable', code: 'runtime_unavailable', offline: '' };
|
|
await pick();
|
|
assert.equal(await ask.count(), 0, 'unsupported action offers no fallback');
|
|
failure = { error: 'Offline', code: 'runtime_unavailable', offline: 'stage' };
|
|
await pick();
|
|
await ask.waitFor();
|
|
await ask.locator('.bar button').last().click();
|
|
await ask.waitFor({ state: 'detached' });
|
|
assert.deepEqual(posts.filter(p => p.path.includes('/stage/')), [{ path: '/api/agents/stage/aside', body: { field: 'model', value: 'magpie/relay/m1' } }]);
|
|
const disconnect = async () => {
|
|
await page.evaluate(() => askDisconnect(state.agents[0]));
|
|
await ask.waitFor();
|
|
const go = ask.locator('.bar button').last();
|
|
await page.waitForFunction(() => !document.querySelector('.disconnect-ask .bar button:last-child').disabled);
|
|
await go.click();
|
|
await page.waitForFunction(() => document.querySelector('.disconnect-ask')?.textContent.includes('Close Aside') || document.querySelector('.disconnect-ask')?.textContent.includes('关闭 Aside'));
|
|
};
|
|
blockPreview = true;
|
|
await page.evaluate(() => askDisconnect(state.agents[0]));
|
|
await ask.waitFor();
|
|
assert.equal(await ask.locator('.bar button').last().isDisabled(), true, 'wait for successful preview');
|
|
while (!releasePreview) await new Promise(resolve => setTimeout(resolve, 10));
|
|
blockPreview = false; releasePreview();
|
|
await page.waitForFunction(() => !document.querySelector('.disconnect-ask .bar button:last-child').disabled);
|
|
await ask.locator('.bar button').first().click();
|
|
await ask.waitFor({ state: 'detached' });
|
|
await disconnect();
|
|
await ask.locator('.bar button').first().click();
|
|
await ask.waitFor({ state: 'detached' });
|
|
assert.equal(posts.filter(p => p.path.includes('/disconnect-offline/')).length, 0);
|
|
await disconnect();
|
|
revision = 'changed-plan';
|
|
await ask.locator('.bar button').last().click();
|
|
await page.waitForFunction(() => !document.querySelector('.disconnect-ask .bar button:last-child').disabled);
|
|
assert.equal(a.wired, true, 'stale preview retains provider');
|
|
await ask.locator('.bar button').first().click();
|
|
await ask.waitFor({ state: 'detached' });
|
|
failPreview = true;
|
|
await page.evaluate(() => askDisconnect(state.agents[0]));
|
|
await page.waitForFunction(() => document.querySelector('.disconnect-ask')?.textContent.includes('No restore point'));
|
|
assert.equal(await ask.locator('.bar button').last().isDisabled(), true);
|
|
await ask.locator('.bar button').first().click();
|
|
failPreview = false;
|
|
await disconnect();
|
|
await ask.locator('.bar button').last().click();
|
|
await ask.waitFor({ state: 'detached' });
|
|
assert.equal(a.wired, false, 'offline execution works with missing CLI');
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|