Files
genoffice/e2e/sheets-new-blank.spec.ts
T
merrick-2002andGenOffice 8f523289d6 Sync snapshot (2026-08-04) (#19)
- Docs: paragraph writing direction (LTR/RTL) toggle with auto-detection
- Docs: hardened file lifecycle, docx fidelity, and editor performance
- PDF: Export as Word via cloud conversion, non-destructive Save As, and an in-progress export dialog
- Slides: treat full-page background shapes as the page background
- Sheets: faster recalculation with a session-resident engine; better xlsx compatibility (builtin number formats, auto-fit row heights, sheet-name resolution)
- AI: surface stream and gateway errors instead of finishing empty turns; parse non-SSE JSON gateway replies; stall watchdogs
- Fixes from alpha feedback batches 3 and 4 (TOC levels, Windows menus, honest AI applies, login flow diagnostics, credits-exhausted notice)
- CI: sheets save round-trip E2E and xlsx compatibility corpus gate
- Start the 0.5 release train (v0.5.0/v0.5.1)

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-08-04 21:26:02 +08:00

66 lines
2.8 KiB
TypeScript

import { test, expect } from '@playwright/test'
import { execSync } from 'node:child_process'
import { mkdtemp, readdir } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { launchShell, closeAndSaveVideo, waitForPageWithUrl, screenshotPath } from './helpers'
/**
* Regression for "new spreadsheet cannot be saved" (feedback 2368785): the
* quick-create card must create a real backing .xlsx up front so the save
* pipeline works from the first edit.
*/
test.describe('sheets: new blank workbook', () => {
test('quick-create writes a backing file and saves the first edit', async () => {
const scratch = await mkdtemp(join(tmpdir(), 'genoffice-sheets-blank-'))
const launched = await launchShell({ onboardingSeen: true, videoDir: 'sheets-new-blank' })
try {
const { app, page } = launched
// keep the auto-created workbook out of the real ~/Documents/GenOffice
await app.evaluate(({ app: electronApp }, dir) => {
electronApp.setPath('documents', dir)
}, scratch)
await expect(page.locator('.quick-card').nth(1)).toContainText('AI Sheets')
await page.locator('.quick-card').nth(1).click()
const sheets = await waitForPageWithUrl(app, 'sheets/out')
await sheets.waitForFunction(() => document.body.textContent?.includes('Sheet1'), null, {
timeout: 30_000,
})
await sheets.waitForTimeout(1_500)
// the backing file exists before any edit
const saveDir = join(scratch, 'GenOffice')
const created = (await readdir(saveDir)).filter((f) => f.endsWith('.xlsx'))
expect(created).toHaveLength(1)
const workbook = join(saveDir, created[0])
const grid = await sheets.evaluate(() => {
for (const canvas of document.querySelectorAll('canvas')) {
const rect = canvas.getBoundingClientRect()
if (rect.width > 500 && rect.height > 300) return { x: rect.x, y: rect.y }
}
return null
})
if (!grid) throw new Error('worksheet canvas not found')
await sheets.mouse.click(grid.x + 46 + 43, grid.y + 24 + 12)
await expect(sheets.locator('.name-box')).toHaveValue('A1')
await sheets.keyboard.type('42', { delay: 50 })
await sheets.keyboard.press('Enter')
await sheets.screenshot({ path: screenshotPath('sheets-new-blank-edited') })
await app.evaluate(({ webContents }) => {
const wc = webContents.getAllWebContents().find((w) => w.getURL().includes('sheets/out'))
wc?.send('menu:action', 'save')
})
await expect(() => {
const xml = execSync(`unzip -p "${workbook}" xl/worksheets/sheet1.xml`).toString()
expect(xml).toContain('<v>42</v>')
}).toPass({ timeout: 15_000 })
} finally {
await closeAndSaveVideo(launched, 'sheets-new-blank')
}
})
})