Add e2e coverage for Combined mode (#259)
* Refactor test functions to later enable cilcks * Add not-so-clean way to get the combined snap * Add linux combine snap * Refactor, add darwin snapshots * Add linux snapshots * Remove darwin snapshots * Disable tracking of darwin snapshots * WIP reenable failing test * WIP tests
1
.gitignore
vendored
@ -26,5 +26,6 @@ yarn-error.log*
|
|||||||
/test-results/
|
/test-results/
|
||||||
/playwright-report/
|
/playwright-report/
|
||||||
/playwright/.cache/
|
/playwright/.cache/
|
||||||
|
/tests/extension.spec.ts-snapshots/*darwin*
|
||||||
|
|
||||||
.env*
|
.env*
|
||||||
|
@ -252,6 +252,7 @@ export function CadDiff({ before, after }: FileDiff): React.ReactElement {
|
|||||||
2-up
|
2-up
|
||||||
</TabNav.Link>
|
</TabNav.Link>
|
||||||
<TabNav.Link
|
<TabNav.Link
|
||||||
|
className="kittycad-combined-button"
|
||||||
selected={showCombined}
|
selected={showCombined}
|
||||||
onClick={() => setShowCombined(true)}
|
onClick={() => setShowCombined(true)}
|
||||||
sx={{ cursor: 'pointer' }}
|
sx={{ cursor: 'pointer' }}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Page } from '@playwright/test'
|
import { ElementHandle, Page } from '@playwright/test'
|
||||||
import { test, expect } from './fixtures'
|
import { test, expect } from './fixtures'
|
||||||
|
|
||||||
test('popup page', async ({ page, extensionId }) => {
|
test('popup page', async ({ page, extensionId }) => {
|
||||||
@ -18,11 +18,7 @@ test('authorized popup page', async ({
|
|||||||
await expect(page.locator('button')).toHaveCount(2)
|
await expect(page.locator('button')).toHaveCount(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
async function getFirstDiffScreenshot(
|
async function getFirstDiffElement(page: Page, url: string, extension: string) {
|
||||||
page: Page,
|
|
||||||
url: string,
|
|
||||||
extension: string
|
|
||||||
) {
|
|
||||||
page.on('console', msg => console.log(msg.text()))
|
page.on('console', msg => console.log(msg.text()))
|
||||||
await page.goto(url)
|
await page.goto(url)
|
||||||
|
|
||||||
@ -36,10 +32,16 @@ async function getFirstDiffScreenshot(
|
|||||||
`.js-file[data-file-type=".${extension}"]`
|
`.js-file[data-file-type=".${extension}"]`
|
||||||
)
|
)
|
||||||
await page.waitForTimeout(1000) // making sure the element fully settled in
|
await page.waitForTimeout(1000) // making sure the element fully settled in
|
||||||
return await element.screenshot()
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getBlobPreviewScreenshot(page: Page, url: string) {
|
async function enableCombined(page: Page, element: ElementHandle) {
|
||||||
|
const button = await element.$('.kittycad-combined-button')
|
||||||
|
await button.click()
|
||||||
|
await page.waitForTimeout(1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getBlobPreviewElement(page: Page, url: string) {
|
||||||
page.on('console', msg => console.log(msg.text()))
|
page.on('console', msg => console.log(msg.text()))
|
||||||
await page.goto(url)
|
await page.goto(url)
|
||||||
|
|
||||||
@ -49,45 +51,62 @@ async function getBlobPreviewScreenshot(page: Page, url: string) {
|
|||||||
// screenshot the file diff with its toolbar
|
// screenshot the file diff with its toolbar
|
||||||
const element = await page.waitForSelector('.kittycad-injected-file')
|
const element = await page.waitForSelector('.kittycad-injected-file')
|
||||||
await page.waitForTimeout(1000) // making sure the element fully settled in
|
await page.waitForTimeout(1000) // making sure the element fully settled in
|
||||||
return await element.screenshot()
|
return element
|
||||||
}
|
}
|
||||||
|
|
||||||
test('pull request diff with an .obj file', async ({
|
test('pull request diff with a modified .obj file', async ({
|
||||||
page,
|
page,
|
||||||
authorizedBackground,
|
authorizedBackground,
|
||||||
}) => {
|
}) => {
|
||||||
const url = 'https://github.com/KittyCAD/diff-samples/pull/2/files'
|
const url = 'https://github.com/KittyCAD/diff-samples/pull/2/files'
|
||||||
const screenshot = await getFirstDiffScreenshot(page, url, 'obj')
|
const element = await getFirstDiffElement(page, url, 'obj')
|
||||||
|
const screenshot = await element.screenshot()
|
||||||
expect(screenshot).toMatchSnapshot()
|
expect(screenshot).toMatchSnapshot()
|
||||||
|
|
||||||
|
await enableCombined(page, element)
|
||||||
|
const screenshot2 = await element.screenshot()
|
||||||
|
expect(screenshot2).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('pull request diff with a .step file', async ({
|
test('pull request diff with a modified .step file', async ({
|
||||||
page,
|
page,
|
||||||
authorizedBackground,
|
authorizedBackground,
|
||||||
}) => {
|
}) => {
|
||||||
const url = 'https://github.com/KittyCAD/diff-samples/pull/2/files'
|
const url = 'https://github.com/KittyCAD/diff-samples/pull/2/files'
|
||||||
const screenshot = await getFirstDiffScreenshot(page, url, 'step')
|
const element = await getFirstDiffElement(page, url, 'step')
|
||||||
|
const screenshot = await element.screenshot()
|
||||||
expect(screenshot).toMatchSnapshot()
|
expect(screenshot).toMatchSnapshot()
|
||||||
|
|
||||||
|
// TODO: understand why this one makes the CI fail (guess: page crashes, low resources?)
|
||||||
|
// await enableCombined(page, element)
|
||||||
|
// const screenshot2 = await element.screenshot()
|
||||||
|
// expect(screenshot2).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('commit diff with a .step file', async ({
|
test('commit diff with an added .step file', async ({
|
||||||
page,
|
page,
|
||||||
authorizedBackground,
|
authorizedBackground,
|
||||||
}) => {
|
}) => {
|
||||||
const url =
|
const url =
|
||||||
'https://github.com/KittyCAD/diff-samples/commit/fd9eec79f0464833686ea6b5b34ea07145e32734'
|
'https://github.com/KittyCAD/diff-samples/commit/fd9eec79f0464833686ea6b5b34ea07145e32734'
|
||||||
const screenshot = await getFirstDiffScreenshot(page, url, 'step')
|
const element = await getFirstDiffElement(page, url, 'step')
|
||||||
|
const screenshot = await element.screenshot()
|
||||||
expect(screenshot).toMatchSnapshot()
|
expect(screenshot).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('commit diff with a .dae file as LFS', async ({
|
test('commit diff with a modified .dae file as LFS', async ({
|
||||||
page,
|
page,
|
||||||
authorizedBackground,
|
authorizedBackground,
|
||||||
}) => {
|
}) => {
|
||||||
const url =
|
const url =
|
||||||
'https://github.com/KittyCAD/diff-samples/commit/b009cfd6dd1eb2d0c3ec0d31a21360766ad084e4'
|
'https://github.com/KittyCAD/diff-samples/commit/b009cfd6dd1eb2d0c3ec0d31a21360766ad084e4'
|
||||||
const screenshot = await getFirstDiffScreenshot(page, url, 'dae')
|
const element = await getFirstDiffElement(page, url, 'dae')
|
||||||
|
const screenshot = await element.screenshot()
|
||||||
expect(screenshot).toMatchSnapshot()
|
expect(screenshot).toMatchSnapshot()
|
||||||
|
|
||||||
|
await enableCombined(page, element)
|
||||||
|
const screenshot2 = await element.screenshot()
|
||||||
|
expect(screenshot2).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('blob preview with an .obj file', async ({
|
test('blob preview with an .obj file', async ({
|
||||||
@ -96,7 +115,8 @@ test('blob preview with an .obj file', async ({
|
|||||||
}) => {
|
}) => {
|
||||||
const url =
|
const url =
|
||||||
'https://github.com/KittyCAD/diff-samples/blob/fd9eec79f0464833686ea6b5b34ea07145e32734/models/box.obj'
|
'https://github.com/KittyCAD/diff-samples/blob/fd9eec79f0464833686ea6b5b34ea07145e32734/models/box.obj'
|
||||||
const screenshot = await getBlobPreviewScreenshot(page, url)
|
const element = await getBlobPreviewElement(page, url)
|
||||||
|
const screenshot = await element.screenshot()
|
||||||
expect(screenshot).toMatchSnapshot()
|
expect(screenshot).toMatchSnapshot()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 103 KiB |
Before Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 103 KiB |
Before Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 104 KiB |