Add rich viewer for files (non-diff) (#246)

* Add rich viewer for files (non-diff)
Fixes #74

* Fix test typo

* WIP toolbar and proper blob element injection

* Add working Preview/Code/Blame toggle

* Add missing aria-label

* Add e2e test and classic/reactUI support

* Re-enable headless e2e

* Update e2e snap for linux

* Lint

* Improve style a bit

* Reorg and cleanup
This commit is contained in:
Pierre Jacquier
2023-06-23 16:37:02 -04:00
committed by GitHub
parent e544a7aadc
commit ebafdecae7
26 changed files with 458 additions and 31 deletions

View File

@ -39,6 +39,19 @@ async function getFirstDiffScreenshot(
return await element.screenshot()
}
async function getBlobPreviewScreenshot(page: Page, url: string) {
page.on('console', msg => console.log(msg.text()))
await page.goto(url)
// waiting for the canvas (that holds the diff) to show up
await page.waitForSelector('#repo-content-pjax-container canvas')
// screenshot the file diff with its toolbar
const element = await page.waitForSelector('.kittycad-injected-file')
await page.waitForTimeout(1000) // making sure the element fully settled in
return await element.screenshot()
}
test('pull request diff with an .obj file', async ({
page,
authorizedBackground,
@ -76,3 +89,13 @@ test('commit diff with a .dae file as LFS', async ({
const screenshot = await getFirstDiffScreenshot(page, url, 'dae')
expect(screenshot).toMatchSnapshot()
})
test('blob preview with an .obj file', async ({
page,
authorizedBackground,
}) => {
const url =
'https://github.com/KittyCAD/diff-samples/blob/fd9eec79f0464833686ea6b5b34ea07145e32734/models/box.obj'
const screenshot = await getBlobPreviewScreenshot(page, url)
expect(screenshot).toMatchSnapshot()
})