mirror of
https://github.com/penpot/penpot.git
synced 2026-10-03 09:16:15 +00:00
* ✨ Add renderer option on create-demo-profile command Allow create-demo-profile to take an optional renderer (svg or wasm) and store it on profile props. When omitted, no renderer is written so the Penpot default still applies. Closes #11893 AI-assisted-by: Muse Spark 1.3 Free * 📚 Fix renderer doc version on create-demo-profile Correct the ::doc/changes version for the new renderer param from 2.20 to 2.18.1. AI-assisted-by: Muse Spark 1.3 Free
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import { rpcPost, extractCookie } from "./client.mjs";
|
|
|
|
export async function createDemoProfile(params = {}) {
|
|
const res = await rpcPost("create-demo-profile", params);
|
|
if (res.body.type === "validation" || res.body.type === "restriction") {
|
|
throw new Error(
|
|
`Failed to create demo profile: ${res.body.code} - ${res.body.hint || ""}`
|
|
);
|
|
}
|
|
return { email: res.body.email, password: res.body.password };
|
|
}
|
|
|
|
export async function login(email, password) {
|
|
const res = await rpcPost("login-with-password", { email, password });
|
|
if (res.status !== 200 || res.body.type) {
|
|
throw new Error(
|
|
`Login failed: ${JSON.stringify(res.body)}`
|
|
);
|
|
}
|
|
const cookie = extractCookie(res.setCookie);
|
|
return { profile: res.body, cookie };
|
|
}
|
|
|
|
export async function createAccessToken(cookie, name = "e2e-test-token") {
|
|
const res = await rpcPost("create-access-token", { name }, { cookieToken: cookie });
|
|
if (res.status !== 200 || res.body.type) {
|
|
throw new Error(
|
|
`Create access token failed: ${JSON.stringify(res.body)}`
|
|
);
|
|
}
|
|
return res.body;
|
|
}
|
|
|
|
export async function setupTestProfile(params = {}) {
|
|
const { email, password } = await createDemoProfile(params);
|
|
const { profile, cookie } = await login(email, password);
|
|
return { profile, cookie, email, password };
|
|
}
|