Files
diff-viewer-extension/tests/extension.spec.ts
Pierre Jacquier 3df22f1116 Add toggle between source and rich diff for CAD (#36)
* Remove await on GetFileDiff
Progress towards #28

* n roots instead of 2n

* Lint

* Trying something with portals

* Portal component, one root

* Fix element clean up, prep for later tasks

* Draft: toolbar element injection

* Working click to select rich or source

* Actually working now

* Fixes

* Clean up

* Polishing here and there

* Add SourceRichToggle component

* e2e test with toolbar

* Update linux snapshots

* Remove failing test (WIP)

* Clean up
2023-03-27 16:37:21 -04:00

56 lines
1.8 KiB
TypeScript

import { Page } from '@playwright/test'
import { test, expect } from './fixtures'
test('popup page', async ({ page, extensionId }) => {
await page.goto(`chrome-extension://${extensionId}/index.html`)
await expect(page.locator('body')).toContainText('Enter a GitHub token')
await expect(page.locator('body')).toContainText('Enter a KittyCAD token')
})
test('authorized popup page', async ({
page,
extensionId,
authorizedBackground,
}) => {
await page.goto(`chrome-extension://${extensionId}/index.html`)
await page.waitForSelector('button')
await expect(page.locator('body')).toContainText('Sign out')
await expect(page.locator('button')).toHaveCount(2)
})
async function getFirstDiffScreenshot(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(
'.js-file[data-file-type=".obj"] .js-file-content canvas'
)
// screenshot the file diff with its toolbar
const element = await page.waitForSelector(
'.js-file[data-file-type=".obj"]'
)
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,
}) => {
const url = 'https://github.com/KittyCAD/kittycad.ts/pull/3/files'
const screenshot = await getFirstDiffScreenshot(page, url)
expect(screenshot).toMatchSnapshot()
})
test('commit diff with an .obj file', async ({
page,
authorizedBackground,
}) => {
const url =
'https://github.com/KittyCAD/kittycad.ts/commit/08b50ee5a23b3ae7dd7b19383f14bbd520079cc1'
const screenshot = await getFirstDiffScreenshot(page, url)
expect(screenshot).toMatchSnapshot()
})