Canvix — Free & open-source graphic design tool. A community-built Canva alternative with a drag-and-drop editor, templates, shapes, text, images & one-click export. Works on desktop, tablet & mobile.
TypeScript canva-alternativecanvasdesigndesign-tooldrag-and-dropeditorgraphic-designkonvanextjsopen-sourcereactself-hostedtemplatestypescript
fix(e2e): keep the suite inside the 5/h/IP register budget (#26)
Ashiq Hussain Mir8a08916f147b
diff --git a/tests/e2e/clipboard.spec.ts b/tests/e2e/clipboard.spec.tsindex 87dbaf0..57e8a6a 100644--- a/tests/e2e/clipboard.spec.ts+++ b/tests/e2e/clipboard.spec.ts@@ -48,9 +48,15 @@ async function register(page: Page, tag: string): Promise<string> {data: { username, password: `D2-E2e-${username}-17!q` },})expect(res.status()).toBeLessThan(300)+ if (!SHARED_ACCOUNT) SHARED_ACCOUNT = { username, password: `D2-E2e-${username}-17!q` }return username}+// one account per FILE (tests run sequentially, workers: 1) — the+// suite-wide register budget is 5/h/IP, so the read-only test's+// design owner logs in here instead of registering a 3rd user+let SHARED_ACCOUNT: { username: string; password: string } | null = null+async function createDesign(page: Page, name: string, elements: unknown[]): Promise<string> {const res = await page.request.post('/api/designs', {data: { name, width: 1080, height: 720, pages: [{ id: 'p1', background: { type: 'solid', color: '#FFFFFF' }, elements }] },@@ -73,6 +79,8 @@ async function elementCount(page: Page, designId: string, pred: (e: Record<strin}test.describe('System clipboard (v0.14 D2)', () => {+ // two full editor opens per test — slow self-host boxes need room+ test.setTimeout(120_000)test('copy in tab A pastes in tab B with a fresh element id', async ({ browser }) => {const ctx = await browser.newContext({ permissions: ['clipboard-read', 'clipboard-write'] })const pageA = await ctx.newPage()@@ -143,11 +151,17 @@ test.describe('System clipboard (v0.14 D2)', () => {})test('read-only designs never paste', async ({ browser }) => {- // owner creates a design with content…+ // a REGISTERED owner makes the design private (ownerless designs+ // are the anonymous commons — editable, not read-only). The owner+ // logs into the account test 1 created: one registration per file.+ expect(SHARED_ACCOUNT, 'a prior test registered the shared account').not.toBeNull()const ownerCtx = await browser.newContext()const ownerPage = await ownerCtx.newPage()- const username = await register(ownerPage, 'owner')- const design = await createDesign(ownerPage, `cvx_d2_ro_${username}`, [TEXT_ELEMENT])+ const login = await ownerPage.request.post('/api/auth/login', {+ data: { username: SHARED_ACCOUNT!.username, password: SHARED_ACCOUNT!.password },+ })+ expect(login.status()).toBe(200)+ const design = await createDesign(ownerPage, 'cvx_d2_ro_owned', [TEXT_ELEMENT])await ownerCtx.close()// …an anonymous viewer opens it (read-only)diff --git a/tests/e2e/uploads-library.spec.ts b/tests/e2e/uploads-library.spec.tsindex 24d51a5..1d6dc4f 100644--- a/tests/e2e/uploads-library.spec.ts+++ b/tests/e2e/uploads-library.spec.ts@@ -32,9 +32,16 @@ async function register(page: Page, tag: string): Promise<string> {data: { username, password: `D1-E2e-${username}-17!q` },})expect(res.status(), `register ${username}`).toBeLessThan(300)+ // stash the first account — the claim test logs into it instead of+ // registering a 4th user (the suite-wide register budget is 5/h/IP)+ if (!SHARED_ACCOUNT) SHARED_ACCOUNT = { username, password: `D1-E2e-${username}-17!q` }return username}+// tests in this file run sequentially (workers: 1, no parallel) —+// the first test to register publishes its credentials here+let SHARED_ACCOUNT: { username: string; password: string } | null = null+async function createBlankDesign(page: Page, name: string): Promise<string> {const res = await page.request.post('/api/designs', {data: { name, width: 1080, height: 720, pages: [{ id: 'p1', background: { type: 'solid', color: '#FFFFFF' }, elements: [] }] },@@ -169,8 +176,15 @@ test.describe('Uploads library (v0.14 D1)', () => {// the anonymous library lists it…await expect(page.getByRole('heading', { name: 'Your library' })).toBeVisible({ timeout: 15_000 })- // …then registering claims the rows into the account- const username = await register(page, 'claim')+ // …then LOGGING IN claims the rows into the account (the same+ // claimAnonMedia path register uses — the suite's register budget+ // is 5/h/IP, so this test borrows the account test 1 created)+ expect(SHARED_ACCOUNT, 'a prior test registered the shared account').not.toBeNull()+ const username = SHARED_ACCOUNT!.username+ const login = await page.request.post('/api/auth/login', {+ data: { username, password: SHARED_ACCOUNT!.password },+ })+ expect(login.status(), 'login as the shared account').toBeLessThan(300)// the API now attributes the library to the accountconst lib = await page.request.get('/api/media/library')expect(lib.status()).toBe(200)@@ -181,10 +195,10 @@ test.describe('Uploads library (v0.14 D1)', () => {const ctx = await page.context().browser()!.newContext()const pageB = await ctx.newPage()await pageB.goto('/')- const login = await pageB.request.post('/api/auth/login', {- data: { username, password: `D1-E2e-${username}-17!q` },+ const loginB = await pageB.request.post('/api/auth/login', {+ data: { username, password: SHARED_ACCOUNT!.password },})- expect(login.status()).toBe(200)+ expect(loginB.status()).toBe(200)const libB = await pageB.request.get('/api/media/library')const bodyB = (await libB.json()) as { items: { id: string }[] }expect(bodyB.items.map((i) => i.id).sort()).toEqual(body.items.map((i) => i.id).sort())