| 1 | // Comment bodies are visible on the comments page (B6: they rendered inside a |
| 2 | // rastrillo toggle-block, whose body is display:none without a checked switch). |
| 3 | // Real server-rendered page and stylesheets, mocked transport; no live data. |
| 4 | // SHEETS_COMMENTS_FIXTURE=/tmp/comments.json go test ./internal/sheets -run TestBrowserCommentsFixture -count=1 |
| 5 | // PLAYWRIGHT=/path/to/playwright/index.mjs SHEETS_COMMENTS_FIXTURE=/tmp/comments.json node tools/drive/comments.mjs |
| 6 | import assert from 'node:assert/strict'; |
| 7 | import fs from 'node:fs'; |
| 8 | const pw = await import(process.env.PLAYWRIGHT || 'playwright'); |
| 9 | const fixture = JSON.parse(fs.readFileSync(process.env.SHEETS_COMMENTS_FIXTURE)); |
| 10 | const origin = 'https://sheets.test'; |
| 11 | for (const name of ['chromium', 'webkit']) { |
| 12 | const options = name === 'webkit' && process.env.WEBKIT_EXECUTABLE_PATH ? {executablePath:process.env.WEBKIT_EXECUTABLE_PATH} : {}; |
| 13 | const browser = await pw[name].launch(options); |
| 14 | try { |
| 15 | for (const viewport of [{width:1440,height:900},{width:390,height:844}]) { |
| 16 | const page = await browser.newPage({viewport}); |
| 17 | await page.route(origin+'/**', async route => { |
| 18 | const path = new URL(route.request().url()).pathname; |
| 19 | if (path in fixture.assets) return route.fulfill({body:fixture.assets[path],contentType: |
| 20 | path.endsWith('.js')?'application/javascript':path.endsWith('.css')?'text/css':'image/svg+xml'}); |
| 21 | return route.fulfill({body:fixture.html,contentType:'text/html'}); |
| 22 | }); |
| 23 | await page.goto(origin+'/sheets/1/comments'); |
| 24 | for (const text of fixture.bodies) { |
| 25 | const body = page.getByText(text, {exact:true}); |
| 26 | assert.equal(await body.count(), 1, `${name}: "${text}" rendered once`); |
| 27 | assert.ok(await body.isVisible(), `${name} ${viewport.width}px: "${text}" is visible`); |
| 28 | const box = await body.boundingBox(); |
| 29 | assert.ok(box && box.width > 0 && box.height > 0, `${name}: "${text}" has a painted box`); |
| 30 | } |
| 31 | await page.close(); |
| 32 | } |
| 33 | console.log(`${name}: comment bodies visible`); |
| 34 | } finally { |
| 35 | await browser.close(); |
| 36 | } |
| 37 | } |
| 38 | |