Skip to content

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.

fix(e2e): count the Charts tab + spend zero registrations for the charts spec (D7 CI follow-up)

Ashiq Hussain Mir2eecfe1b4d36
diff --git a/tests/e2e/charts.spec.ts b/tests/e2e/charts.spec.ts
index 8938e04..66d7b3d 100644
--- a/tests/e2e/charts.spec.ts
+++ b/tests/e2e/charts.spec.ts
@@ -17,21 +17,11 @@ import { readFileSync } from 'node:fs'
* HOSTILE clipboard envelope pastes as a sanitized chart (junk
* kind → bar fallback, caps applied, id remapped)
*
- * Register budget: ONE registration per run (the second test logs in
- * with the shared account — the PR #26 discipline).
+ * Register budget: ZERO — the whole spec runs anonymously (each test
+ * gets its own browser context/attribution). The suite-wide budget is
+ * 5/h/IP and this spec must not spend any of it (the PR #26/#30 lesson).
*/
-let SHARED_ACCOUNT: { username: string; password: string } | null = null
-
-async function register(page: Page, tag: string): Promise<string> {
- const username = `d7_${tag}_${Date.now().toString(36)}`
- const password = `D7-E2e-${username}-17!q`
- const res = await page.request.post('/api/auth/register', { data: { username, password } })
- expect(res.status(), `register ${username}`).toBeLessThan(300)
- if (!SHARED_ACCOUNT) SHARED_ACCOUNT = { username, password }
- return username
-}
-
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 }] },
@@ -81,8 +71,9 @@ test.describe('Charts (v0.14 D7)', () => {
test.setTimeout(180_000)
test('add bar → edit data → convert to donut → persist → SVG exports', async ({ page }) => {
- const username = await register(page, 'main')
- const design = await createDesign(page, `cvx_d7_${username}`, [])
+ // fully anonymous — designs work in the anon commons and this spec
+ // must not spend a registration (the suite-wide 5/h/IP budget)
+ const design = await createDesign(page, `cvx_d7_${Date.now().toString(36)}`, [])
await openEditor(page, design)
// ── add a bar chart from the Elements panel ──
@@ -171,15 +162,10 @@ test.describe('Charts (v0.14 D7)', () => {
})
test('line + scatter shapes land, hostile envelope pastes sanitized', async ({ browser }) => {
- expect(SHARED_ACCOUNT, 'a prior test registered the shared account').not.toBeNull()
const ctx = await browser.newContext({ permissions: ['clipboard-read', 'clipboard-write'] })
const page = await ctx.newPage()
- const login = await page.request.post('/api/auth/login', {
- data: { username: SHARED_ACCOUNT!.username, password: SHARED_ACCOUNT!.password },
- })
- expect(login.status(), 'login as the shared account').toBeLessThan(300)
- const design = await createDesign(page, `cvx_d7_b_${SHARED_ACCOUNT!.username}`, [])
+ const design = await createDesign(page, `cvx_d7_b_${Date.now().toString(36)}`, [])
await openEditor(page, design)
// ── line chart ──
diff --git a/tests/e2e/panels-responsive.spec.ts b/tests/e2e/panels-responsive.spec.ts
index 91f1902..f520678 100644
--- a/tests/e2e/panels-responsive.spec.ts
+++ b/tests/e2e/panels-responsive.spec.ts
@@ -18,7 +18,7 @@ import { test, expect, type Page } from '@playwright/test'
*/
const MOBILE_WIDTHS = [320, 360, 390, 430] as const
-const CATEGORIES = ['Shapes', 'Lines', 'Graphics', 'Stickers', 'Tables', 'Frames', 'Embeds'] as const
+const CATEGORIES = ['Shapes', 'Lines', 'Graphics', 'Stickers', 'Charts', 'Tables', 'Frames', 'Embeds'] as const
async function openEditorPanel(page: Page, panel: string) {
await page.goto('/')
@@ -145,7 +145,7 @@ test('Elements strip stays a single row on desktop (320px sidebar)', async ({ pa
...new Set(els.map((el) => Math.round(el.getBoundingClientRect().y))),
])
expect(ys).toHaveLength(1)
- // desktop panel is 320px wide — the 7 tabs still overflow into a scroll row
+ // desktop panel is 320px wide — the 8 tabs still overflow into a scroll row
const strip = page.getByRole('tablist', { name: 'Element categories' })
const geom = await strip.evaluate((el) => ({ sw: el.scrollWidth, cw: el.clientWidth }))
expect(geom.sw).toBeGreaterThan(geom.cw)