Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import {
|
||||
buildVideoRegenerateRequest,
|
||||
canCancelVideoTask,
|
||||
canRegenerateVideoTask,
|
||||
getVideoURLFromDetail,
|
||||
normalizeExperienceVideoError,
|
||||
normalizeVideoTaskStatus,
|
||||
} from './videoTask.js';
|
||||
|
||||
test('normalizes provider task statuses', () => {
|
||||
for (const status of ['SUCCESS', 'completed', 'SUCCEEDED']) {
|
||||
assert.equal(normalizeVideoTaskStatus(status), 'success');
|
||||
}
|
||||
for (const status of ['FAILURE', 'failed', 'CANCELED']) {
|
||||
assert.equal(normalizeVideoTaskStatus(status), 'failure');
|
||||
}
|
||||
assert.equal(normalizeVideoTaskStatus('SUBMITTED'), 'queued');
|
||||
assert.equal(normalizeVideoTaskStatus('processing'), 'in_progress');
|
||||
});
|
||||
|
||||
test('reads only the unified detail video URL', () => {
|
||||
assert.equal(
|
||||
getVideoURLFromDetail({ data: { video_url: ' https://cdn/video.mp4 ' } }),
|
||||
'https://cdn/video.mp4',
|
||||
);
|
||||
assert.equal(
|
||||
getVideoURLFromDetail({ data: { url: 'https://legacy/video.mp4' } }),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('honors task capabilities', () => {
|
||||
assert.equal(
|
||||
canCancelVideoTask({ status: 'IN_PROGRESS', cancel_supported: true }),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
canCancelVideoTask({ status: 'SUCCESS', cancel_supported: true }),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
canCancelVideoTask({ status: 'IN_PROGRESS', cancel_supported: false }),
|
||||
false,
|
||||
);
|
||||
assert.equal(canRegenerateVideoTask({ regenerate_supported: true }), true);
|
||||
assert.equal(canRegenerateVideoTask({ regenerate_supported: false }), false);
|
||||
});
|
||||
|
||||
test('builds regeneration request with the final selected model', () => {
|
||||
const request = buildVideoRegenerateRequest(
|
||||
{ model: 'old-model', prompt: 'hello', seed: 0 },
|
||||
{ id: 9, model_name: 'new-model' },
|
||||
);
|
||||
assert.equal(request.model, 'new-model');
|
||||
assert.equal(request.prompt, 'hello');
|
||||
assert.equal(request.seed, 0);
|
||||
});
|
||||
|
||||
test('normalizes API errors with stable code', () => {
|
||||
assert.deepEqual(
|
||||
normalizeExperienceVideoError({
|
||||
response: { data: { message: 'disabled', code: 'channel_not_enabled' } },
|
||||
}),
|
||||
{ message: 'disabled', code: 'channel_not_enabled' },
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user