Remove test that can never run in our current setup (#6774)
Remove test that can never run with our current setup
This commit is contained in:
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
.PHONY: all
|
||||
all: install build check
|
||||
all: install check build
|
||||
|
||||
###############################################################################
|
||||
# INSTALL
|
||||
|
||||
@ -1,17 +1,8 @@
|
||||
import { spawn } from 'child_process'
|
||||
import path from 'path'
|
||||
import type { Models } from '@kittycad/lib'
|
||||
import { KCL_DEFAULT_LENGTH } from '@src/lib/constants'
|
||||
import fsp from 'fs/promises'
|
||||
import JSZip from 'jszip'
|
||||
|
||||
import type { CmdBarFixture } from '@e2e/playwright/fixtures/cmdBarFixture'
|
||||
import type { SceneFixture } from '@e2e/playwright/fixtures/sceneFixture'
|
||||
import { secrets } from '@e2e/playwright/secrets'
|
||||
import { TEST_SETTINGS, TEST_SETTINGS_KEY } from '@e2e/playwright/storageStates'
|
||||
import type { Paths } from '@e2e/playwright/test-utils'
|
||||
import {
|
||||
doExport,
|
||||
getUtils,
|
||||
headerMasks,
|
||||
networkingMasks,
|
||||
@ -40,275 +31,6 @@ test.afterEach(async ({ page }) => {
|
||||
|
||||
test.setTimeout(60_000)
|
||||
|
||||
// We test this end to end already - getting this to work on web just to take
|
||||
// a snapshot of it feels weird. I'd rather our regular tests fail.
|
||||
// The primary failure is doExport now relies on the filesystem. We can follow
|
||||
// up with another PR if we want this back.
|
||||
test(
|
||||
'exports of each format should work',
|
||||
{ tag: ['@snapshot'] },
|
||||
async ({ page, context, scene, cmdBar, tronApp }) => {
|
||||
if (!tronApp) {
|
||||
fail()
|
||||
}
|
||||
|
||||
// FYI this test doesn't work with only engine running locally
|
||||
// And you will need to have the KittyCAD CLI installed
|
||||
const u = await getUtils(page)
|
||||
await context.addInitScript(async () => {
|
||||
;(window as any).playwrightSkipFilePicker = true
|
||||
localStorage.setItem(
|
||||
'persistCode',
|
||||
`topAng = 25
|
||||
bottomAng = 35
|
||||
baseLen = 3.5
|
||||
baseHeight = 1
|
||||
totalHeightHalf = 2
|
||||
armThick = 0.5
|
||||
totalLen = 9.5
|
||||
part001 = startSketchOn(-XZ)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> yLine(length = baseHeight)
|
||||
|> xLine(length = baseLen)
|
||||
|> angledLine(
|
||||
angle = topAng,
|
||||
endAbsoluteY = totalHeightHalf,
|
||||
tag = $seg04,
|
||||
)
|
||||
|> xLine(endAbsolute = totalLen, tag = $seg03)
|
||||
|> yLine(length = -armThick, tag = $seg01)
|
||||
|> angledLineThatIntersects(angle = turns::HALF_TURN, offset = -armThick, intersectTag = seg04)
|
||||
|> angledLine(angle = segAng(seg04) + 180, endAbsoluteY = turns::ZERO)
|
||||
|> angledLine(
|
||||
angle = -bottomAng,
|
||||
endAbsoluteY = -totalHeightHalf - armThick,
|
||||
tag = $seg02,
|
||||
)
|
||||
|> xLine(length = endAbsolute = segEndX(seg03) + 0)
|
||||
|> yLine(length = -segLen(seg01))
|
||||
|> angledLineThatIntersects(angle = turns::HALF_TURN, offset = -armThick, intersectTag = seg02)
|
||||
|> angledLine(angle = segAng(seg02) + 180, endAbsoluteY = -baseHeight)
|
||||
|> xLine(endAbsolute = turns::ZERO)
|
||||
|> close()
|
||||
|> extrude(length = 4)`
|
||||
)
|
||||
})
|
||||
await page.setViewportSize({ width: 1200, height: 500 })
|
||||
|
||||
await u.waitForAuthSkipAppStart()
|
||||
|
||||
await scene.settled(cmdBar)
|
||||
|
||||
const axisDirectionPair: Models['AxisDirectionPair_type'] = {
|
||||
axis: 'z',
|
||||
direction: 'positive',
|
||||
}
|
||||
const sysType: Models['System_type'] = {
|
||||
forward: axisDirectionPair,
|
||||
up: axisDirectionPair,
|
||||
}
|
||||
|
||||
const exportLocations: Paths[] = []
|
||||
|
||||
// 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
|
||||
// the rest are only there to make typescript happy
|
||||
|
||||
// TODO - failing because of an exporter issue, ADD BACK IN WHEN ITS FIXED
|
||||
// exportLocations.push(
|
||||
// await doExport(
|
||||
// {
|
||||
// type: 'step',
|
||||
// coords: sysType,
|
||||
// },
|
||||
// page
|
||||
// )
|
||||
// )
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'ply',
|
||||
coords: sysType,
|
||||
selection: { type: 'default_scene' },
|
||||
storage: 'ascii',
|
||||
units: 'in',
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'ply',
|
||||
storage: 'binary_little_endian',
|
||||
coords: sysType,
|
||||
selection: { type: 'default_scene' },
|
||||
units: 'in',
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'ply',
|
||||
storage: 'binary_big_endian',
|
||||
coords: sysType,
|
||||
selection: { type: 'default_scene' },
|
||||
units: 'in',
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'stl',
|
||||
storage: 'ascii',
|
||||
coords: sysType,
|
||||
units: 'in',
|
||||
selection: { type: 'default_scene' },
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'stl',
|
||||
storage: 'binary',
|
||||
coords: sysType,
|
||||
units: 'in',
|
||||
selection: { type: 'default_scene' },
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
// obj seems to be a little flaky, times out tests sometimes
|
||||
type: 'obj',
|
||||
coords: sysType,
|
||||
units: 'in',
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'gltf',
|
||||
storage: 'embedded',
|
||||
presentation: 'pretty',
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'gltf',
|
||||
storage: 'binary',
|
||||
presentation: 'pretty',
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
exportLocations.push(
|
||||
await doExport(
|
||||
{
|
||||
type: 'gltf',
|
||||
storage: 'standard',
|
||||
presentation: 'pretty',
|
||||
},
|
||||
tronApp.projectDirName,
|
||||
page
|
||||
)
|
||||
)
|
||||
|
||||
// close page to disconnect websocket since we can only have one open atm
|
||||
await page.close()
|
||||
|
||||
// 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
|
||||
for (let { modelPath, imagePath, outputType } of exportLocations) {
|
||||
// May change depending on the file being dealt with
|
||||
let cliCommand = `export ZOO_TOKEN=${secrets.snapshottoken} && zoo file snapshot --output-format=png --src-format=${outputType} ${modelPath} ${imagePath}`
|
||||
const fileSize = (await fsp.stat(modelPath)).size
|
||||
console.log(`Size of the file at ${modelPath}: ${fileSize} bytes`)
|
||||
|
||||
const parentPath = path.dirname(modelPath)
|
||||
|
||||
// This is actually a zip file.
|
||||
if (modelPath.includes('gltf-standard.gltf')) {
|
||||
console.log('Extracting files from archive')
|
||||
const readZipFile = fsp.readFile(modelPath)
|
||||
const unzip = (archive: any) =>
|
||||
Object.values(archive.files).map((file: any) => ({
|
||||
name: file.name,
|
||||
promise: file.async('nodebuffer'),
|
||||
}))
|
||||
const writeFiles = (files: any) =>
|
||||
Promise.all(
|
||||
files.map((file: any) =>
|
||||
file.promise.then((data: any) => {
|
||||
console.log(`Writing ${file.name}`)
|
||||
return fsp
|
||||
.writeFile(`${parentPath}/${file.name}`, data)
|
||||
.then(() => file.name)
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
const filenames = await readZipFile
|
||||
.then(JSZip.loadAsync)
|
||||
.then(unzip)
|
||||
.then(writeFiles)
|
||||
const gltfFilename = filenames.filter((t: string) =>
|
||||
t.includes('.gltf')
|
||||
)[0]
|
||||
if (!gltfFilename) throw new Error('No gLTF in this archive')
|
||||
cliCommand = `export ZOO_TOKEN=${secrets.snapshottoken} && zoo file snapshot --output-format=png --src-format=${outputType} ${parentPath}/${gltfFilename} ${imagePath}`
|
||||
}
|
||||
|
||||
console.log(cliCommand)
|
||||
|
||||
const child = spawn(cliCommand, { shell: true })
|
||||
const result = await new Promise<string>((resolve, reject) => {
|
||||
child.on('error', (code: any, msg: any) => {
|
||||
console.log('error', code, msg)
|
||||
reject('error')
|
||||
})
|
||||
child.on('exit', (code, msg) => {
|
||||
console.log('exit', code, msg)
|
||||
if (code !== 0) {
|
||||
reject(`exit code ${code} for model ${modelPath}`)
|
||||
} else {
|
||||
resolve('success')
|
||||
}
|
||||
})
|
||||
child.stderr.on('data', (data) => console.log(`stderr: ${data}`))
|
||||
child.stdout.on('data', (data) => console.log(`stdout: ${data}`))
|
||||
})
|
||||
expect(result).toBe('success')
|
||||
if (result === 'success') {
|
||||
console.log(`snapshot taken for ${modelPath}`)
|
||||
} else {
|
||||
console.log(`snapshot failed for ${modelPath}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const extrudeDefaultPlane = async (
|
||||
context: any,
|
||||
page: any,
|
||||
|
||||
Reference in New Issue
Block a user