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:
Kurt Hutten
2023-11-30 17:20:52 +11:00
committed by GitHub
parent cef29013b8
commit f3083eb59d
4 changed files with 2490 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@ -210,11 +210,36 @@ const part001 = startSketchOn('-XZ')
const downloadPromise = page.waitForEvent('download')
await page.getByRole('button', { name: 'Export', exact: true }).click()
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/${
output.type
}-${'storage' in output ? output.storage : ''}.${output.type}`
if (output.type === 'gltf' && output.storage === 'standard') {
// wait for second download
const download2 = await page.waitForEvent('download')
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') {
// stable timestamps for step files
const fileContents = await fsp.readFile(downloadLocation, 'utf-8')

View File

@ -34,8 +34,8 @@ export const browserSaveFile = async (blob: Blob, suggestedName: string) => {
// Fail silently if the user has simply canceled the dialog.
if (err.name !== 'AbortError') {
console.error(err.name, err.message)
return
}
return
}
}
// Fallback if the File System Access API is not supported…

View File

@ -34,7 +34,7 @@ export async function exportSave(data: ArrayBuffer) {
// Create a new blob.
const blob = new Blob([new Uint8Array(file.contents)])
// Save the file.
browserSaveFile(blob, file.name)
await browserSaveFile(blob, file.name)
}
}
} catch (e) {