more e2e export fixes (#1150)
* more e2e export fixes * fixes * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
2459
e2e/playwright/export-snapshots/gltf-standard-2.gltf
Normal file
2459
e2e/playwright/export-snapshots/gltf-standard-2.gltf
Normal file
File diff suppressed because it is too large
Load Diff
@ -210,11 +210,36 @@ const part001 = startSketchOn('-XZ')
|
|||||||
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 = '') =>
|
||||||
|
`./e2e/playwright/export-snapshots/${output.type}-${
|
||||||
|
'storage' in output ? output.storage : ''
|
||||||
|
}${extra}.${output.type}`
|
||||||
|
const downloadLocation = downloadLocationer()
|
||||||
|
const downloadLocation2 = downloadLocationer('-2')
|
||||||
|
|
||||||
const downloadLocation = `./e2e/playwright/export-snapshots/${
|
if (output.type === 'gltf' && output.storage === 'standard') {
|
||||||
output.type
|
// wait for second download
|
||||||
}-${'storage' in output ? output.storage : ''}.${output.type}`
|
const download2 = await page.waitForEvent('download')
|
||||||
await download.saveAs(downloadLocation)
|
await download.saveAs(downloadLocation)
|
||||||
|
await download2.saveAs(downloadLocation2)
|
||||||
|
|
||||||
|
// rewrite uri to reference our file name
|
||||||
|
const fileContents = await fsp.readFile(downloadLocation, 'utf-8')
|
||||||
|
const isJson = fileContents.includes('buffers')
|
||||||
|
let contents = fileContents
|
||||||
|
let reWriteLocation = downloadLocation
|
||||||
|
let uri = downloadLocation2.split('/').pop()
|
||||||
|
if (!isJson) {
|
||||||
|
contents = await fsp.readFile(downloadLocation2, 'utf-8')
|
||||||
|
reWriteLocation = downloadLocation2
|
||||||
|
uri = downloadLocation.split('/').pop()
|
||||||
|
}
|
||||||
|
contents = contents.replace(/"uri": ".*"/g, `"uri": "${uri}"`)
|
||||||
|
await fsp.writeFile(reWriteLocation, contents)
|
||||||
|
} else {
|
||||||
|
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')
|
||||||
|
@ -34,8 +34,8 @@ export const browserSaveFile = async (blob: Blob, suggestedName: string) => {
|
|||||||
// Fail silently if the user has simply canceled the dialog.
|
// Fail silently if the user has simply canceled the dialog.
|
||||||
if (err.name !== 'AbortError') {
|
if (err.name !== 'AbortError') {
|
||||||
console.error(err.name, err.message)
|
console.error(err.name, err.message)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Fallback if the File System Access API is not supported…
|
// Fallback if the File System Access API is not supported…
|
||||||
|
@ -34,7 +34,7 @@ export async function exportSave(data: ArrayBuffer) {
|
|||||||
// Create a new blob.
|
// Create a new blob.
|
||||||
const blob = new Blob([new Uint8Array(file.contents)])
|
const blob = new Blob([new Uint8Array(file.contents)])
|
||||||
// Save the file.
|
// Save the file.
|
||||||
browserSaveFile(blob, file.name)
|
await browserSaveFile(blob, file.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Reference in New Issue
Block a user