test(e2e): migrate to asset-libraries + /upload APIs #1986
@@ -55,9 +55,9 @@ test.describe("Douyin Script Extraction (#1972)", () => {
|
||||
data: { name: `Smoke Douyin ${suffix}` },
|
||||
})
|
||||
const projectId = (await proj.json()).id ?? (await proj.json()).project_id
|
||||
await request.post(`${apiBase}/video-libraries`, {
|
||||
await request.post(`${apiBase}/asset-libraries`, {
|
||||
headers: authHeader,
|
||||
data: { project_id: projectId, name: "Smoke" },
|
||||
data: { project_id: projectId, name: "Smoke", kind: "video" },
|
||||
})
|
||||
|
||||
await page.addInitScript((t: string) => {
|
||||
|
||||
@@ -61,35 +61,29 @@ async function setupFreshUser(
|
||||
expect(proj.ok(), `create project: ${await proj.text()}`).toBeTruthy()
|
||||
const projectId = (await proj.json()).id ?? (await proj.json()).project_id
|
||||
|
||||
const lib = await request.post(`${apiBase}/video-libraries`, {
|
||||
const lib = await request.post(`${apiBase}/asset-libraries`, {
|
||||
headers: auth,
|
||||
data: { project_id: projectId, name: "Smoke" },
|
||||
data: { project_id: projectId, name: "Smoke", kind: "video" },
|
||||
})
|
||||
expect(lib.ok(), `create library: ${await lib.text()}`).toBeTruthy()
|
||||
const libraryId = (await lib.json()).id
|
||||
|
||||
const sig = await request.post(`${apiBase}/assets/sign`, {
|
||||
headers: auth,
|
||||
data: {
|
||||
filename: "sample.mp4",
|
||||
content_type: "video/mp4",
|
||||
library_id: libraryId,
|
||||
source: "local",
|
||||
},
|
||||
})
|
||||
expect(sig.ok(), `sign upload: ${await sig.text()}`).toBeTruthy()
|
||||
const signData = await sig.json()
|
||||
const assetId = signData.asset_id
|
||||
const samplePath = path.join(__dirname, "fixtures", "sample.mp4")
|
||||
await request.put(signData.upload_url || signData.url, {
|
||||
const sampleBuf = fs.readFileSync(samplePath)
|
||||
const up = await request.post(`${apiBase}/upload`, {
|
||||
headers: auth,
|
||||
multipart: {
|
||||
project_id: projectId,
|
||||
library_id: libraryId,
|
||||
file: {
|
||||
name: "sample.mp4",
|
||||
mimeType: "video/mp4",
|
||||
buffer: fs.readFileSync(samplePath),
|
||||
buffer: sampleBuf,
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(up.ok(), `upload sample: ${await up.text()}`).toBeTruthy()
|
||||
const assetId = (await up.json()).asset_id
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
|
||||
@@ -48,9 +48,9 @@ test.describe("Core Navigation", () => {
|
||||
})
|
||||
if (proj.ok()) {
|
||||
const projectId = (await proj.json()).id ?? (await proj.json()).project_id
|
||||
await request.post(`${apiBase}/video-libraries`, {
|
||||
await request.post(`${apiBase}/asset-libraries`, {
|
||||
headers: authHeader,
|
||||
data: { project_id: projectId, name: "Nav Lib" },
|
||||
data: { project_id: projectId, name: "Nav Lib", kind: "video" },
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user