test: complete WP4-07 visual and performance budgets
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 2m34s
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 2m34s
This commit is contained in:
@@ -53,6 +53,10 @@ export const WP4_07_DYNAMIC_VALUES = Object.freeze({
|
||||
|
||||
const timestamp = "2026-07-27T04:00:00.000Z";
|
||||
const redResourceVersion = "wp4-07-red-contract-v1";
|
||||
export const WP4_07_REAL_RESOURCE_VERSIONS = Object.freeze({
|
||||
complex: "p0a-complex-v1",
|
||||
static: "p0a-static-v1",
|
||||
});
|
||||
const palette = ["#111111", "#F2F400", "#1769AA", "#C92A24", "#FFFFFF"];
|
||||
const textTemplateIds = [
|
||||
"FLOWER001", "FLOWER003", "FLOWER005", "FLOWER008", "H003", "H004",
|
||||
@@ -100,9 +104,14 @@ function common(index, type, templateOrAssetId, resourceVersion) {
|
||||
};
|
||||
}
|
||||
|
||||
export function createWp407CanvasFixture(resourceVersion = redResourceVersion) {
|
||||
function releaseVersions(input = redResourceVersion) {
|
||||
return typeof input === "string" ? { complex: input, static: input } : input;
|
||||
}
|
||||
|
||||
export function createWp407CanvasFixture(resourceVersions = redResourceVersion) {
|
||||
const versions = releaseVersions(resourceVersions);
|
||||
const text = textTemplateIds.map((templateId, offset) => ({
|
||||
...common(offset + 1, "text_template", templateId, resourceVersion),
|
||||
...common(offset + 1, "text_template", templateId, versions.complex),
|
||||
content: offset === 0 ? "DADA\n视觉预算" : `固定文字 ${String(offset + 1).padStart(2, "0")}`,
|
||||
font_size: 48,
|
||||
position: offset === 0 ? { x: 0.5, y: 0.5 } : position(offset, 4, 0.09),
|
||||
@@ -123,7 +132,7 @@ export function createWp407CanvasFixture(resourceVersion = redResourceVersion) {
|
||||
},
|
||||
}));
|
||||
const stickers = Array.from({ length: 24 }, (_, offset) => ({
|
||||
...common(offset + 13, "static_sticker", `STK${String(offset + 1).padStart(3, "0")}`, resourceVersion),
|
||||
...common(offset + 13, "static_sticker", `STK${String(offset + 1).padStart(3, "0")}`, versions.static),
|
||||
opacity: 0.84 + (offset % 4) * 0.04,
|
||||
position: position(offset, 6, 0.39),
|
||||
rotation: (offset % 5 - 2) * 6,
|
||||
@@ -131,7 +140,7 @@ export function createWp407CanvasFixture(resourceVersion = redResourceVersion) {
|
||||
style_parameters: { flip_horizontal: offset % 7 === 0 },
|
||||
}));
|
||||
const colors = colorCards.map(([cardId, styleId], offset) => ({
|
||||
...common(offset + 37, "color_card", cardId, resourceVersion),
|
||||
...common(offset + 37, "color_card", cardId, versions.complex),
|
||||
colors: [...palette],
|
||||
position: { x: 0.16 + offset * 0.22, y: 0.83 },
|
||||
scale: { x: 1.25, y: 1.25 },
|
||||
@@ -139,7 +148,7 @@ export function createWp407CanvasFixture(resourceVersion = redResourceVersion) {
|
||||
style_parameters: { palette_algorithm_version: "mmcq-v1" },
|
||||
}));
|
||||
const dynamics = dynamicIds.map((dynamicId, offset) => ({
|
||||
...common(offset + 41, "dynamic_sticker", dynamicId, resourceVersion),
|
||||
...common(offset + 41, "dynamic_sticker", dynamicId, versions.complex),
|
||||
dynamic_fields: { ...WP4_07_DYNAMIC_VALUES },
|
||||
formatted_value: dynamicId === "DYN012" ? "12:00 PM" : "@dada_fixture",
|
||||
position: { x: 0.09 + (offset % 5) * 0.205, y: 0.9 + Math.floor(offset / 5) * 0.06 },
|
||||
@@ -162,8 +171,8 @@ export function createWp407CanvasFixture(resourceVersion = redResourceVersion) {
|
||||
};
|
||||
}
|
||||
|
||||
export function wp407FixtureContract() {
|
||||
const canvas = createWp407CanvasFixture();
|
||||
export function wp407FixtureContract(resourceVersions = redResourceVersion) {
|
||||
const canvas = createWp407CanvasFixture(resourceVersions);
|
||||
return {
|
||||
canvas,
|
||||
dynamic_values: WP4_07_DYNAMIC_VALUES,
|
||||
@@ -174,12 +183,12 @@ export function wp407FixtureContract() {
|
||||
};
|
||||
}
|
||||
|
||||
export function wp407FixtureSha256() {
|
||||
return createHash("sha256").update(JSON.stringify(wp407FixtureContract())).digest("hex").toUpperCase();
|
||||
export function wp407FixtureSha256(resourceVersions = redResourceVersion) {
|
||||
return createHash("sha256").update(JSON.stringify(wp407FixtureContract(resourceVersions))).digest("hex").toUpperCase();
|
||||
}
|
||||
|
||||
export function assertWp407Fixture() {
|
||||
const fixture = wp407FixtureContract();
|
||||
export function assertWp407Fixture(resourceVersions = redResourceVersion) {
|
||||
const fixture = wp407FixtureContract(resourceVersions);
|
||||
const counts = Object.fromEntries(["text_template", "static_sticker", "color_card", "dynamic_sticker"].map((type) => [
|
||||
type,
|
||||
fixture.canvas.elements.filter((element) => element.type === type).length,
|
||||
@@ -195,12 +204,12 @@ export function assertWp407Fixture() {
|
||||
if (fixture.environment.viewport.width !== 1920 || fixture.environment.viewport.height !== 1080 || fixture.environment.device_scale_factor !== 1) {
|
||||
throw new Error("candidate viewport or DPR changed");
|
||||
}
|
||||
return { counts, fixture_sha256: wp407FixtureSha256() };
|
||||
return { counts, fixture_sha256: wp407FixtureSha256(resourceVersions) };
|
||||
}
|
||||
|
||||
export const WP4_07_RED_RESOURCE_VERSION = redResourceVersion;
|
||||
export const WP4_07_REQUIRED_FONT_IDS = Object.freeze([
|
||||
"FONT005", "FONT008", "FONT011", "FONT022", "FONT027", "FONT039", "FONT043", "FONT046", "FONT052", "FONT081",
|
||||
"FONT005", "FONT008", "FONT011", "FONT021", "FONT022", "FONT027", "FONT039", "FONT043", "FONT046", "FONT052", "FONT081",
|
||||
"15974853bc3294ef68e7e6d58fe74fd7", "46f8336813e4c48d06a1aef294fdccf6",
|
||||
"53ca6b704728520da50c145eabb2e635", "cca5efc0e02fb1bf62349bd68ef30fc1",
|
||||
"dd25b35dcb7ba4476cbaa9a9592e39e2", "e4210c9872f0c279b35273f230809821",
|
||||
|
||||
Reference in New Issue
Block a user