update cli to reestablish export test (#1523)

* update cli to reestablish export test

* update cli v

* tweak
This commit is contained in:
Kurt Hutten
2024-02-27 09:41:09 +11:00
committed by GitHub
parent 65ebde0b34
commit c0e6947170
2 changed files with 236 additions and 236 deletions

View File

@ -14,7 +14,7 @@ jobs:
with: with:
node-version-file: '.nvmrc' node-version-file: '.nvmrc'
cache: 'yarn' cache: 'yarn'
- uses: KittyCAD/action-install-cli@v0.2.16 - uses: KittyCAD/action-install-cli@v0.2.21
- name: Install dependencies - name: Install dependencies
run: yarn run: yarn
- name: Install Playwright Browsers - name: Install Playwright Browsers

View File

@ -120,254 +120,254 @@ test('change camera, show planes', async ({ page, context }) => {
}) })
}) })
// test('exports of each format should work', async ({ page, context }) => { test('exports of each format should work', async ({ page, context }) => {
// // FYI this test doesn't work with only engine running locally // FYI this test doesn't work with only engine running locally
// // And you will need to have the KittyCAD CLI installed // And you will need to have the KittyCAD CLI installed
// const u = getUtils(page) const u = getUtils(page)
// await context.addInitScript(async () => { await context.addInitScript(async () => {
// ;(window as any).playwrightSkipFilePicker = true ;(window as any).playwrightSkipFilePicker = true
// localStorage.setItem( localStorage.setItem(
// 'persistCode', 'persistCode',
// `const topAng = 25 `const topAng = 25
// const bottomAng = 35 const bottomAng = 35
// const baseLen = 3.5 const baseLen = 3.5
// const baseHeight = 1 const baseHeight = 1
// const totalHeightHalf = 2 const totalHeightHalf = 2
// const armThick = 0.5 const armThick = 0.5
// const totalLen = 9.5 const totalLen = 9.5
// const part001 = startSketchOn('-XZ') const part001 = startSketchOn('-XZ')
// |> startProfileAt([0, 0], %) |> startProfileAt([0, 0], %)
// |> yLine(baseHeight, %) |> yLine(baseHeight, %)
// |> xLine(baseLen, %) |> xLine(baseLen, %)
// |> angledLineToY({ |> angledLineToY({
// angle: topAng, angle: topAng,
// to: totalHeightHalf, to: totalHeightHalf,
// tag: 'seg04' tag: 'seg04'
// }, %) }, %)
// |> xLineTo({ to: totalLen, tag: 'seg03' }, %) |> xLineTo({ to: totalLen, tag: 'seg03' }, %)
// |> yLine({ length: -armThick, tag: 'seg01' }, %) |> yLine({ length: -armThick, tag: 'seg01' }, %)
// |> angledLineThatIntersects({ |> angledLineThatIntersects({
// angle: HALF_TURN, angle: HALF_TURN,
// offset: -armThick, offset: -armThick,
// intersectTag: 'seg04' intersectTag: 'seg04'
// }, %) }, %)
// |> angledLineToY([segAng('seg04', %) + 180, ZERO], %) |> angledLineToY([segAng('seg04', %) + 180, ZERO], %)
// |> angledLineToY({ |> angledLineToY({
// angle: -bottomAng, angle: -bottomAng,
// to: -totalHeightHalf - armThick, to: -totalHeightHalf - armThick,
// tag: 'seg02' tag: 'seg02'
// }, %) }, %)
// |> xLineTo(segEndX('seg03', %) + 0, %) |> xLineTo(segEndX('seg03', %) + 0, %)
// |> yLine(-segLen('seg01', %), %) |> yLine(-segLen('seg01', %), %)
// |> angledLineThatIntersects({ |> angledLineThatIntersects({
// angle: HALF_TURN, angle: HALF_TURN,
// offset: -armThick, offset: -armThick,
// intersectTag: 'seg02' intersectTag: 'seg02'
// }, %) }, %)
// |> angledLineToY([segAng('seg02', %) + 180, -baseHeight], %) |> angledLineToY([segAng('seg02', %) + 180, -baseHeight], %)
// |> xLineTo(ZERO, %) |> xLineTo(ZERO, %)
// |> close(%) |> close(%)
// |> extrude(4, %)` |> extrude(4, %)`
// ) )
// }) })
// await page.setViewportSize({ width: 1200, height: 500 }) await page.setViewportSize({ width: 1200, height: 500 })
// await page.goto('/') await page.goto('/')
// await u.waitForAuthSkipAppStart() await u.waitForAuthSkipAppStart()
// await u.openDebugPanel() await u.openDebugPanel()
// await u.expectCmdLog('[data-message-type="execution-done"]') await u.expectCmdLog('[data-message-type="execution-done"]')
// await u.waitForCmdReceive('extrude') await u.waitForCmdReceive('extrude')
// await page.waitForTimeout(1000) await page.waitForTimeout(1000)
// await u.clearAndCloseDebugPanel() await u.clearAndCloseDebugPanel()
// await page.getByRole('button', { name: APP_NAME }).click() await page.getByRole('button', { name: APP_NAME }).click()
// interface Paths { interface Paths {
// modelPath: string modelPath: string
// imagePath: string imagePath: string
// outputType: string outputType: string
// } }
// const doExport = async ( const doExport = async (
// output: Models['OutputFormat_type'] output: Models['OutputFormat_type']
// ): Promise<Paths> => { ): Promise<Paths> => {
// await page.getByRole('button', { name: 'Export Model' }).click() await page.getByRole('button', { name: 'Export Model' }).click()
// const exportSelect = page.getByTestId('export-type') const exportSelect = page.getByTestId('export-type')
// await exportSelect.selectOption({ label: output.type }) await exportSelect.selectOption({ label: output.type })
// if ('storage' in output) { if ('storage' in output) {
// const storageSelect = page.getByTestId('export-storage') const storageSelect = page.getByTestId('export-storage')
// await storageSelect.selectOption({ label: output.storage }) await storageSelect.selectOption({ label: output.storage })
// } }
// const downloadPromise = page.waitForEvent('download') const downloadPromise = page.waitForEvent('download')
// await page.getByRole('button', { name: 'Export', exact: true }).click() await page.getByRole('button', { name: 'Export', exact: true }).click()
// const download = await downloadPromise const download = await downloadPromise
// const downloadLocationer = (extra = '', isImage = false) => const downloadLocationer = (extra = '', isImage = false) =>
// `./e2e/playwright/export-snapshots/${output.type}-${ `./e2e/playwright/export-snapshots/${output.type}-${
// 'storage' in output ? output.storage : '' 'storage' in output ? output.storage : ''
// }${extra}.${isImage ? 'png' : output.type}` }${extra}.${isImage ? 'png' : output.type}`
// const downloadLocation = downloadLocationer() const downloadLocation = downloadLocationer()
// const downloadLocation2 = downloadLocationer('-2') const downloadLocation2 = downloadLocationer('-2')
// if (output.type === 'gltf' && output.storage === 'standard') { if (output.type === 'gltf' && output.storage === 'standard') {
// // wait for second download // wait for second download
// const download2 = await page.waitForEvent('download') const download2 = await page.waitForEvent('download')
// await download.saveAs(downloadLocation) await download.saveAs(downloadLocation)
// await download2.saveAs(downloadLocation2) await download2.saveAs(downloadLocation2)
// // rewrite uri to reference our file name // rewrite uri to reference our file name
// const fileContents = await fsp.readFile(downloadLocation, 'utf-8') const fileContents = await fsp.readFile(downloadLocation, 'utf-8')
// const isJson = fileContents.includes('buffers') const isJson = fileContents.includes('buffers')
// let contents = fileContents let contents = fileContents
// let reWriteLocation = downloadLocation let reWriteLocation = downloadLocation
// let uri = downloadLocation2.split('/').pop() let uri = downloadLocation2.split('/').pop()
// if (!isJson) { if (!isJson) {
// contents = await fsp.readFile(downloadLocation2, 'utf-8') contents = await fsp.readFile(downloadLocation2, 'utf-8')
// reWriteLocation = downloadLocation2 reWriteLocation = downloadLocation2
// uri = downloadLocation.split('/').pop() uri = downloadLocation.split('/').pop()
// } }
// contents = contents.replace(/"uri": ".*"/g, `"uri": "${uri}"`) contents = contents.replace(/"uri": ".*"/g, `"uri": "${uri}"`)
// await fsp.writeFile(reWriteLocation, contents) await fsp.writeFile(reWriteLocation, contents)
// } else { } else {
// await download.saveAs(downloadLocation) await download.saveAs(downloadLocation)
// } }
// if (output.type === 'step') { if (output.type === 'step') {
// // stable timestamps for step files // stable timestamps for step files
// const fileContents = await fsp.readFile(downloadLocation, 'utf-8') const fileContents = await fsp.readFile(downloadLocation, 'utf-8')
// const newFileContents = fileContents.replace( const newFileContents = fileContents.replace(
// /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+[0-9]+[0-9]\+[0-9]{2}:[0-9]{2}/g, /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+[0-9]+[0-9]\+[0-9]{2}:[0-9]{2}/g,
// '1970-01-01T00:00:00.0+00:00' '1970-01-01T00:00:00.0+00:00'
// ) )
// await fsp.writeFile(downloadLocation, newFileContents) await fsp.writeFile(downloadLocation, newFileContents)
// } }
// return { return {
// modelPath: downloadLocation, modelPath: downloadLocation,
// imagePath: downloadLocationer('', true), imagePath: downloadLocationer('', true),
// outputType: output.type, outputType: output.type,
// } }
// } }
// const axisDirectionPair: Models['AxisDirectionPair_type'] = { const axisDirectionPair: Models['AxisDirectionPair_type'] = {
// axis: 'z', axis: 'z',
// direction: 'positive', direction: 'positive',
// } }
// const sysType: Models['System_type'] = { const sysType: Models['System_type'] = {
// forward: axisDirectionPair, forward: axisDirectionPair,
// up: axisDirectionPair, up: axisDirectionPair,
// } }
// const exportLocations: Paths[] = [] const exportLocations: Paths[] = []
// // NOTE it was easiest to leverage existing types and have doExport take Models['OutputFormat_type'] as in input // NOTE it was easiest to leverage existing types and have doExport take Models['OutputFormat_type'] as in input
// // just note that only `type` and `storage` are used for selecting the drop downs is the app // just note that only `type` and `storage` are used for selecting the drop downs is the app
// // the rest are only there to make typescript happy // the rest are only there to make typescript happy
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'step', type: 'step',
// coords: sysType, coords: sysType,
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'ply', type: 'ply',
// coords: sysType, coords: sysType,
// selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
// storage: 'ascii', storage: 'ascii',
// units: 'in', units: 'in',
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'ply', type: 'ply',
// storage: 'binary_little_endian', storage: 'binary_little_endian',
// coords: sysType, coords: sysType,
// selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
// units: 'in', units: 'in',
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'ply', type: 'ply',
// storage: 'binary_big_endian', storage: 'binary_big_endian',
// coords: sysType, coords: sysType,
// selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
// units: 'in', units: 'in',
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'stl', type: 'stl',
// storage: 'ascii', storage: 'ascii',
// coords: sysType, coords: sysType,
// units: 'in', units: 'in',
// selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'stl', type: 'stl',
// storage: 'binary', storage: 'binary',
// coords: sysType, coords: sysType,
// units: 'in', units: 'in',
// selection: { type: 'default_scene' }, selection: { type: 'default_scene' },
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// // obj seems to be a little flaky, times out tests sometimes // obj seems to be a little flaky, times out tests sometimes
// type: 'obj', type: 'obj',
// coords: sysType, coords: sysType,
// units: 'in', units: 'in',
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'gltf', type: 'gltf',
// storage: 'embedded', storage: 'embedded',
// presentation: 'pretty', presentation: 'pretty',
// }) })
// ) )
// exportLocations.push( exportLocations.push(
// await doExport({ await doExport({
// type: 'gltf', type: 'gltf',
// storage: 'binary', storage: 'binary',
// presentation: 'pretty', presentation: 'pretty',
// }) })
// ) )
// // TODO: gltfs don't seem to work with snap shots. push onto exportLocations once it's figured out // TODO: gltfs don't seem to work with snap shots. push onto exportLocations once it's figured out
// await doExport({ await doExport({
// type: 'gltf', type: 'gltf',
// storage: 'standard', storage: 'standard',
// presentation: 'pretty', presentation: 'pretty',
// }) })
// // close page to disconnect websocket since we can only have one open atm // close page to disconnect websocket since we can only have one open atm
// await page.close() await page.close()
// // snapshot exports, good compromise to capture that exports are healthy without getting bogged down in "did the formatting change" changes // snapshot exports, good compromise to capture that exports are healthy without getting bogged down in "did the formatting change" changes
// // context: https://github.com/KittyCAD/modeling-app/issues/1222 // context: https://github.com/KittyCAD/modeling-app/issues/1222
// for (const { modelPath, imagePath, outputType } of exportLocations) { for (const { modelPath, imagePath, outputType } of exportLocations) {
// const cliCommand = `export KITTYCAD_TOKEN=${secrets.snapshottoken} && kittycad file snapshot --output-format=png --src-format=${outputType} ${modelPath} ${imagePath}` const cliCommand = `export ZOO_TOKEN=${secrets.snapshottoken} && zoo file snapshot --output-format=png --src-format=${outputType} ${modelPath} ${imagePath}`
// const child = spawn(cliCommand, { shell: true }) const child = spawn(cliCommand, { shell: true })
// await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
// child.on('error', (code: any, msg: any) => { child.on('error', (code: any, msg: any) => {
// console.log('error', code, msg) console.log('error', code, msg)
// reject() reject()
// }) })
// child.on('exit', (code, msg) => { child.on('exit', (code, msg) => {
// console.log('exit', code, msg) console.log('exit', code, msg)
// if (code !== 0) { if (code !== 0) {
// reject(`exit code ${code} for model ${modelPath}`) reject(`exit code ${code} for model ${modelPath}`)
// } else { } else {
// resolve(true) resolve(true)
// } }
// }) })
// child.stderr.on('data', (data) => console.log(`stderr: ${data}`)) child.stderr.on('data', (data) => console.log(`stderr: ${data}`))
// child.stdout.on('data', (data) => console.log(`stdout: ${data}`)) child.stdout.on('data', (data) => console.log(`stdout: ${data}`))
// }) })
// } }
// }) })
test('extrude on each default plane should be stable', async ({ test('extrude on each default plane should be stable', async ({
page, page,