Skip to content

Commit 6423e06

Browse files
authored
Update kittycad lib (#363)
* Update kittycad lib * Change output for output["output.obj"] * Update vitest * Update e2e snaps * Disable two tests * Investigation
1 parent 3ca2f97 commit 6423e06

8 files changed

Lines changed: 145 additions & 102 deletions

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dependencies": {
66
"@dicebear/avatars": "^4.10.8",
77
"@dicebear/avatars-bottts-sprites": "^4.10.8",
8-
"@kittycad/lib": "^0.0.20",
8+
"@kittycad/lib": "^0.0.34",
99
"@octokit/openapi-types": "^18.0.0",
1010
"@octokit/rest": "^20.0.1",
1111
"@octokit/types": "^11.1.0",
@@ -17,7 +17,7 @@
1717
"@testing-library/jest-dom": "^5.17.0",
1818
"@testing-library/react": "^14.0.0",
1919
"@testing-library/user-event": "^14.4.3",
20-
"@types/chrome": "^0.0.241",
20+
"@types/chrome": "^0.0.244",
2121
"@types/jest": "^29.5.3",
2222
"@types/node": "^20.4.2",
2323
"@types/react": "^18.2.15",
@@ -80,7 +80,7 @@
8080
"prettier": "^3.0.0",
8181
"vite": "^4.4.4",
8282
"vite-plugin-node-polyfills": "^0.9.0",
83-
"vitest": "^0.33.0"
83+
"vitest": "^0.34.3"
8484
},
8585
"packageManager": "yarn@3.6.0",
8686
"engines": {

src/chrome/diff.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@ import {
88
import { Buffer } from 'buffer'
99

1010
export const extensionToSrcFormat: {
11-
[extension: string]: FileImportFormat_type
11+
[extension: string]: FileImportFormat_type | 'fbx' | 'sldprt'
1212
} = {
13-
dae: 'dae',
14-
dxf: 'dxf',
13+
// expected one of `fbx`, `gltf`, `obj`, `ply`, `sldprt`, `step`, `stl`
1514
fbx: 'fbx',
15+
gltf: 'gltf',
1616
obj: 'obj',
17-
stl: 'stl',
17+
ply: 'ply',
18+
sldprt: 'sldprt',
1819
stp: 'step',
1920
step: 'step',
20-
svg: 'svg',
21+
stl: 'stl',
22+
23+
// Disabled in new format api
24+
// dae: 'dae',
2125
}
2226

2327
export function isFilenameSupported(filename: string): boolean {
@@ -71,11 +75,11 @@ async function convert(
7175
src_format: extensionToSrcFormat[extension],
7276
output_format: outputFormat as FileExportFormat_type,
7377
})
74-
if ('error_code' in response) throw response
75-
const { status, id, output } = response
76-
console.log(`File conversion id: ${id}`)
77-
console.log(`File conversion status: ${status}`)
78-
return output
78+
const key = `source.${outputFormat}`
79+
if ('error_code' in response || !response.outputs[key]) throw response
80+
const { status, id, outputs } = response
81+
console.log(`File conversion: ${id}, ${status}`)
82+
return outputs[key]
7983
}
8084

8185
export async function getFileDiff(

tests/extension.spec.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,33 @@ test('commit diff with an added .step file', async ({
108108
expect(screenshot).toMatchSnapshot()
109109
})
110110

111-
test('commit diff with a modified .dae file as LFS', async ({
112-
page,
113-
authorizedBackground,
114-
}) => {
115-
const url =
116-
'https://github.com/KittyCAD/diff-samples/commit/b009cfd6dd1eb2d0c3ec0d31a21360766ad084e4'
117-
const element = await getFirstDiffElement(page, url, 'dae')
118-
const screenshot = await element.screenshot()
119-
expect(screenshot).toMatchSnapshot()
120-
121-
await enableCombined(page, element)
122-
const screenshot2 = await element.screenshot()
123-
expect(screenshot2).toMatchSnapshot()
124-
})
125-
126-
test('blob preview with an .obj file', async ({
127-
page,
128-
authorizedBackground,
129-
}) => {
130-
const url =
131-
'https://github.com/KittyCAD/diff-samples/blob/fd9eec79f0464833686ea6b5b34ea07145e32734/models/box.obj'
132-
const element = await getBlobPreviewElement(page, url)
133-
const screenshot = await element.screenshot()
134-
expect(screenshot).toMatchSnapshot()
135-
})
111+
// TODO: re-enable when .dae are supported
112+
// test('commit diff with a modified .dae file as LFS', async ({
113+
// page,
114+
// authorizedBackground,
115+
// }) => {
116+
// const url =
117+
// 'https://github.com/KittyCAD/diff-samples/commit/b009cfd6dd1eb2d0c3ec0d31a21360766ad084e4'
118+
// const element = await getFirstDiffElement(page, url, 'dae')
119+
// const screenshot = await element.screenshot()
120+
// expect(screenshot).toMatchSnapshot()
121+
122+
// await enableCombined(page, element)
123+
// const screenshot2 = await element.screenshot()
124+
// expect(screenshot2).toMatchSnapshot()
125+
// })
126+
127+
// TODO: re-enable when new blob page is fixed
128+
// test('blob preview with an .obj file', async ({
129+
// page,
130+
// authorizedBackground,
131+
// }) => {
132+
// const url =
133+
// 'https://github.com/KittyCAD/diff-samples/blob/fd9eec79f0464833686ea6b5b34ea07145e32734/models/box.obj'
134+
// const element = await getBlobPreviewElement(page, url)
135+
// const screenshot = await element.screenshot()
136+
// expect(screenshot).toMatchSnapshot()
137+
// })
136138

137139
test('blob preview with an .stl file', async ({
138140
page,
-117 KB
Loading
-48.1 KB
Loading
-72.7 KB
Loading
-79.4 KB
Loading

0 commit comments

Comments
 (0)