When a download fails because MakerWorld refused (or is missing) the auth token, the error carries reason makerworld_token. The import and "Download files from source" then open an "Update your MakerWorld token" prompt with steps to copy the token cookie; saving it retries the download straight away and says if MakerWorld still refuses it. A missing FlareSolverr URL is reported separately, since a token alone won't help. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
30 lines
1.6 KiB
JavaScript
30 lines
1.6 KiB
JavaScript
// MakerWorld importer helpers (lib/importers/makerworld.js).
|
||
const test = require('node:test');
|
||
const assert = require('node:assert/strict');
|
||
const makerworld = require('../lib/importers/makerworld');
|
||
|
||
const page = (design) =>
|
||
`<html><script id="__NEXT_DATA__" type="application/json">${JSON.stringify({ props: { pageProps: { design } } })}</script></html>`;
|
||
|
||
test('printable instances and the license are read from the page data', () => {
|
||
const html = page({
|
||
license: 'Standard Digital File License',
|
||
instances: [{ id: 650088, title: 'AMS - 0.4 Nozzle - 0.08 Layer' }, { id: 650089 }],
|
||
});
|
||
assert.deepEqual(makerworld.parseInstances(html), [
|
||
{ id: 650088, title: 'AMS - 0.4 Nozzle - 0.08 Layer' },
|
||
{ id: 650089, title: '' },
|
||
]);
|
||
assert.equal(makerworld.parseLicense(html), 'Standard Digital File License');
|
||
assert.deepEqual(makerworld.parseInstances('<html><title>Just a moment...</title></html>'), []);
|
||
});
|
||
|
||
test('a download answer without a link says why, and flags a refused token', () => {
|
||
assert.equal(makerworld.downloadProblem({ name: 'bookmarks.3mf', url: 'https://cdn.example/bookmarks.3mf' }), null);
|
||
const refused = makerworld.downloadProblem({ code: 1, error: 'Please log in to download models.' });
|
||
assert.equal(refused.tokenRejected, true);
|
||
assert.match(refused.message, /token \(it has probably expired\)/);
|
||
assert.deepEqual(makerworld.downloadProblem({ code: 7, error: 'Model not found' }),
|
||
{ message: 'MakerWorld didn’t give a download link: Model not found', tokenRejected: false });
|
||
assert.deepEqual(makerworld.downloadProblem(null), { message: 'MakerWorld didn’t give a download link', tokenRejected: false });
|
||
});
|