axelburks on Discord: "供应商里方舟的配置页,有图像模型选项能勾选模型,但是没 有视频模型选项不能勾选视频模型". A Volcengine Ark key's editor listed its Seedream models under Image models, to tick, and had its Seedance models among the chat models or nowhere. Cause, two parts: - The editor had no video section at all: video models had no list and no hidden set (gateway-routing.md said "Video models aren't listed in the editor, so there is nothing to hide there"). - catalog's live parse read only "kind" and modalities.input/output. Ark's /api/v3/models marks no kind: it says domain "VideoGeneration" / "ImageGeneration" and modalities.input_modalities/output_modalities. So Seedance came back as a chat model, and 3D models (output 3d, no text) as chat models too. Change: - catalog: a live row with no kind is a video model when its domain is VideoGeneration or it outputs video without text, an image model for ImageGeneration or image without text; Ark's input_modalities / output_modalities are read when input/output aren't there, so a model that gives no text (Ark's 3D) is left out of the chat list. TestFetchArkMarksVideoModels runs on a captured Ark list (testdata/volcengine-ark-models-2026-11-03.json, fetched read-only with GET /api/v3/models, no key in it). - provider: HiddenVideomakers beside HiddenDrawers, VideomakerHidden. - gateway: VideomakersOf (Videomakers on a given list, for the editor), OfferedVideomakers = Videomakers less the unticked ones, read by AutoVideomaker, videomakerObjects (another magpie's list) and mediaModels(true) (generate_video). A hidden one still makes its video when named: bareVideomaker, videosCreate and arkFilms read Videomakers. - gui: the editor's Video models section (renderVideomakers), filmIds and hiddenVideomakers on /api/providers, kept on save as hiddenDrawers is; i18n for every language. app.js comments cut to stay under TestCoreScriptBudget, which this change reached; no raise. - docs: gateway-routing.md's Hidden image models section. Old data: an Ark list fetched before keeps Seedance among its chat models until its list is fetched again; customVideomakers already counts any Seedance id an Ark key lists or picks as a video model, so it makes videos and shows under Video models now. Run on mote, this change and the next (/v1/models ?kind=, gateway and docs only) rebased on f4c664a09; this commit's own tree, on17f2387e1, gave the same Go results with Linux and Windows vet of ./internal/... clean: - go test -count=1 -timeout 45m ./internal/catalog ./internal/provider ./internal/gateway ./internal/gui: catalog, provider and gateway ok; gui red only in TestMainWindowCorners/macOS_26_SDK (#3949, red on main). - GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean. gofmt -l: nothing. - GUI (at the next commit's tree, which adds no GUI file or script): the 51 provider-*, drawers, image-models, i18n and video-models-hide files, both engines, every language, wide and narrow: 1161 of 1188 ok. The 27 reds are 5 files that are red the same 27 at origin/maind1cdce130run alone: provider-fetch-again (#3292/#5057), provider-models-rest (#4396), provider-picks-stay (#4397), provider-levels-scroll (#4395), provider-typed (#4673). video-models-hide: 22 of 22 ok. - The whole GUI suite (all files) ran earlier at this change on8af751987, 347 of 19153 red at load 100 to 200; the 66 files with a red, run again alone, are red in the same tests at origin/main17f2387e1(all filed: #4388, #4391, #4398, #4320, #4541/#5013, #2564, #4244, #4304 and the above). Rebased again ontod1cdce130(sessions, Cursor mover, library and routing plugins, group-unlists; nothing this change touches but gateway.go, which merged clean) and run there: TestCoreScriptBudget and internal/gui's new tests, the gateway's ?kind= and video tests, internal/provider and internal/catalog, video-models-hide 22 of 22: ok. Broken by hand, each red, then put back: - the domain/output check in catalog's live parse: TestFetchArkMarksVideoModels red - OfferedVideomakers returning Videomakers whole: TestHiddenVideomakerLeavesListsButStillFilms red - the editor's filmIds left empty: TestVideoModelsHidden red - a save without hiddenVideomakers dropping the old ones: TestVideoModelsHidden red - renderVideomakers' call in the editor left out: video-models-hide 22 of 22 red - a chip's click not changing the draft: video-models-hide 22 of 22 red Not tried: no real Ark video was made (no money spent); the list parse was checked on a real Ark list fetched read-only. The editor was not opened in the real app, only in the GUI tests' fake API. Credit: axelburks on Discord.
125 lines
8.7 KiB
JavaScript
125 lines
8.7 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// axelburks on Discord: "供应商里方舟的配置页,有图像模型选项能勾选模型,但是没
|
|
// 有视频模型选项不能勾选视频模型". A Volcengine Ark key's editor had its
|
|
// Seedream models under Image models, to tick, and its Seedance models
|
|
// nowhere. Now they are under Video models, each ticked, a click unticks it
|
|
// (and ticks it back), and Save writes the unticked ones as
|
|
// hiddenVideomakers, beside hiddenDrawers, neither one touching the other.
|
|
// Every language, wide and at a phone's width; the API is faked here.
|
|
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");
|
|
const fetched = new Date(Date.now() - 3600e3).toISOString();
|
|
const drawIds = ["doubao-seedream-5-0-pro-260628", "doubao-seedream-5-0-flash-260915"];
|
|
const filmIds = ["doubao-seedance-2-0-260128", "doubao-seedance-2-0-fast-260128", "doubao-seedance-1-0-pro-fast-251015"];
|
|
|
|
function providerFor(hidden, hiddenDraw) {
|
|
return {
|
|
id: "volcengine-2", name: "Volcengine Ark", icon: "volcengine", preset: "volcengine", host: "", chat: "https://ark.cn-beijing.volces.com/api/v3", responses: "", anthropic: "", catalog: "",
|
|
models: [{ id: "doubao-seed-2-1-pro-260915", name: "Doubao Seed 2.1 Pro", on: true }], chosen: [], fetched, agents: [], fallback: [], headers: {},
|
|
key: { set: true, masked: "ark-…one", optional: false }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "", ready: true,
|
|
draws: drawIds.length, drawIds, hiddenDrawers: hiddenDraw, filmIds, hiddenVideomakers: hidden,
|
|
};
|
|
}
|
|
|
|
function serve(lang, saves) {
|
|
let hidden = ["doubao-seedance-1-0-pro-fast-251015"], hiddenDraw = ["doubao-seedream-5-0-flash-260915"];
|
|
const providers = () => ({ providers: [providerFor(hidden, hiddenDraw)], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
|
|
return async (route) => {
|
|
const req = route.request(), url = new URL(req.url());
|
|
const json = (data) => route.fulfill({ json: data });
|
|
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true,textSize:100};` });
|
|
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
|
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", textSize: 100 } });
|
|
if (url.pathname === "/api/settings") return json({ lang, theme: "light", textSize: 100, fx: { rate: 7.2, at: new Date().toISOString(), stale: false } });
|
|
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
|
if (url.pathname === "/api/providers") return json(providers());
|
|
if (url.pathname === "/api/provider/save") {
|
|
const body = req.postDataJSON();
|
|
saves.push({ videos: body.hiddenVideomakers, images: body.hiddenDrawers });
|
|
if (body.hiddenVideomakers) hidden = body.hiddenVideomakers;
|
|
if (body.hiddenDrawers) hiddenDraw = body.hiddenDrawers;
|
|
return json(providers());
|
|
}
|
|
if (url.pathname === "/api/usage/quotas") return json([]);
|
|
if (url.pathname === "/api/groups") return json({ groups: [], pools: [], models: [] });
|
|
if (url.pathname === "/api/gateway/trace") return json({ routes: [] });
|
|
if (url.pathname === "/api/window/fit") return route.fulfill({ status: 204 });
|
|
if (url.pathname.startsWith("/api/")) return json({});
|
|
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
|
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
|
const body = await fs.readFile(file).catch(() => null);
|
|
await (body ? route.fulfill({ body, contentType }) : route.fulfill({ status: 404, body: "" }));
|
|
};
|
|
}
|
|
|
|
const words = {
|
|
en: { save: "Save", field: "Video models", hint: /Only the ticked ones are offered when making a video/ },
|
|
zh: { save: "保存", field: "视频模型", hint: /生成视频时只提供已勾选的/ },
|
|
"zh-TW": { save: "儲存", field: "影片模型", hint: /生成影片時只提供已勾選的/ },
|
|
ja: { save: "保存", field: "動画モデル", hint: /動画を作るときは、チェックしたものだけが候補になります/ },
|
|
de: { save: "Speichern", field: "Videomodelle", hint: /Beim Erstellen eines Videos werden nur die angehakten angeboten/ },
|
|
};
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
test(engine + ": a provider's video models can be unticked, apart from its image models", async (t) => {
|
|
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
for (const lang of Object.keys(words)) {
|
|
const w = words[lang];
|
|
for (const width of [1000, 360]) {
|
|
await t.test(`${lang} at ${width}px: the editor unticks and ticks back a video model`, async () => {
|
|
const saves = [];
|
|
const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(5000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
const errors = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", serve(lang, saves));
|
|
await page.goto("http://magpie.test/?view=providers");
|
|
const editor = page.locator("#modal:not([hidden]) .editor");
|
|
const openEditor = async () => {
|
|
await page.locator(".row.provider", { hasText: "Volcengine Ark" }).first().click();
|
|
await editor.locator(".mchips.videomakers .mchip").first().waitFor();
|
|
};
|
|
const ticked = (cls) => editor.locator(`.mchips.${cls} .mchip.on`).evaluateAll((cs) => cs.map((c) => c.textContent));
|
|
const chip = (id) => editor.locator(".mchips.videomakers .mchip", { has: page.locator(`span:text-is("${id}")`) });
|
|
await openEditor();
|
|
await editor.getByText(w.field, { exact: true }).first().waitFor();
|
|
await editor.getByText(w.hint).waitFor();
|
|
assert.equal(await editor.locator(".mchips.videomakers .mchip").count(), 3);
|
|
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128", "doubao-seedance-2-0-fast-260128"], "the saved hidden one opens unticked");
|
|
assert.deepEqual(await ticked("drawers"), ["doubao-seedream-5-0-pro-260628"], "image models are their own");
|
|
assert.equal(await editor.locator(".mchips.drawers .mchip", { hasText: "seedance" }).count(), 0);
|
|
assert.equal(await chip("doubao-seedance-1-0-pro-fast-251015").getAttribute("aria-pressed"), "false");
|
|
await chip("doubao-seedance-2-0-fast-260128").click();
|
|
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128"]);
|
|
await chip("doubao-seedance-1-0-pro-fast-251015").click();
|
|
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128", "doubao-seedance-1-0-pro-fast-251015"]);
|
|
assert.deepEqual(await ticked("drawers"), ["doubao-seedream-5-0-pro-260628"], "a video tick leaves the image models be");
|
|
// the section and its chips fit the editor at a phone's width
|
|
const fit = await editor.locator(".mchips.videomakers").evaluate((box) => {
|
|
const ed = box.closest(".editor").getBoundingClientRect();
|
|
return [...box.querySelectorAll(".mchip")].every((c) => { const r = c.getBoundingClientRect(); return r.left >= ed.left - 1 && r.right <= ed.right + 1; });
|
|
});
|
|
assert.equal(fit, true, "a chip runs out of the editor");
|
|
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth), 0);
|
|
await editor.getByRole("button", { name: w.save, exact: true }).click();
|
|
await editor.waitFor({ state: "detached" });
|
|
assert.deepEqual(saves.at(-1), { videos: ["doubao-seedance-2-0-fast-260128"], images: ["doubao-seedream-5-0-flash-260915"] });
|
|
await openEditor();
|
|
assert.deepEqual(await ticked("videomakers"), ["doubao-seedance-2-0-260128", "doubao-seedance-1-0-pro-fast-251015"], "reopened as saved");
|
|
assert.equal(await page.locator("select").count(), 0);
|
|
assert.deepEqual(errors, []);
|
|
await page.context().close();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|