fix: support authenticated video citation playback
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import test from 'node:test';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { createServer } from 'vite';
|
||||
|
||||
const source = (path) => readFile(new URL(path, import.meta.url), 'utf8');
|
||||
|
||||
@@ -28,3 +30,30 @@ test('引用详情页释放媒体临时 URL', async () => {
|
||||
assert.match(detail, /onUnmounted\(releaseMedia\)/);
|
||||
assert.match(detail, /releaseAuthenticatedFileUrl/);
|
||||
});
|
||||
|
||||
test('H5 video media URLs stay rooted at the dev API instead of the /h5 app base', async () => {
|
||||
globalThis.window = { location: { origin: 'https://wygj-mobile-uni.localhost' } };
|
||||
globalThis.uni = {
|
||||
getStorageSync: () => '',
|
||||
removeStorageSync: () => {}
|
||||
};
|
||||
const vite = await createServer({
|
||||
root: fileURLToPath(new URL('..', import.meta.url)),
|
||||
configFile: false,
|
||||
optimizeDeps: { noDiscovery: true },
|
||||
server: { middlewareMode: true, hmr: false },
|
||||
appType: 'custom'
|
||||
});
|
||||
|
||||
try {
|
||||
const { apiMediaUrl } = await vite.ssrLoadModule('/src/services/api.ts');
|
||||
assert.equal(
|
||||
apiMediaUrl('/api/knowledge/resources/2069/download?ticket=opaque'),
|
||||
'https://wygj-mobile-uni.localhost/dev-api/api/knowledge/resources/2069/download?ticket=opaque'
|
||||
);
|
||||
} finally {
|
||||
await vite.close();
|
||||
delete globalThis.window;
|
||||
delete globalThis.uni;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user