aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/create-generate-storyboard-job.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-31 14:34:36 +0200
committerChocobozzz <me@florianbigard.com>2023-08-11 15:02:33 +0200
commit3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch)
treee4510b39bdac9c318fdb4b47018d08f15368b8f0 /server/tests/cli/create-generate-storyboard-job.ts
parent04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff)
downloadPeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'server/tests/cli/create-generate-storyboard-job.ts')
-rw-r--r--server/tests/cli/create-generate-storyboard-job.ts120
1 files changed, 0 insertions, 120 deletions
diff --git a/server/tests/cli/create-generate-storyboard-job.ts b/server/tests/cli/create-generate-storyboard-job.ts
deleted file mode 100644
index 02a4be8ae..000000000
--- a/server/tests/cli/create-generate-storyboard-job.ts
+++ /dev/null
@@ -1,120 +0,0 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { expect } from 'chai'
4import { readdir, remove } from 'fs-extra'
5import { join } from 'path'
6import { HttpStatusCode } from '@shared/models'
7import {
8 cleanupTests,
9 createMultipleServers,
10 doubleFollow,
11 makeGetRequest,
12 PeerTubeServer,
13 setAccessTokensToServers,
14 waitJobs
15} from '@shared/server-commands'
16import { SQLCommand } from '../shared'
17
18function listStoryboardFiles (server: PeerTubeServer) {
19 const storage = server.getDirectoryPath('storyboards')
20
21 return readdir(storage)
22}
23
24describe('Test create generate storyboard job', function () {
25 let servers: PeerTubeServer[] = []
26 const uuids: string[] = []
27 let sql: SQLCommand
28 let existingStoryboardName: string
29
30 before(async function () {
31 this.timeout(120000)
32
33 // Run server 2 to have transcoding enabled
34 servers = await createMultipleServers(2)
35 await setAccessTokensToServers(servers)
36
37 await doubleFollow(servers[0], servers[1])
38
39 for (let i = 0; i < 3; i++) {
40 const { uuid } = await servers[0].videos.quickUpload({ name: 'video ' + i })
41 uuids.push(uuid)
42 }
43
44 await waitJobs(servers)
45
46 const storage = servers[0].getDirectoryPath('storyboards')
47 for (const storyboard of await listStoryboardFiles(servers[0])) {
48 await remove(join(storage, storyboard))
49 }
50
51 sql = new SQLCommand(servers[0])
52 await sql.deleteAll('storyboard')
53
54 const { uuid } = await servers[0].videos.quickUpload({ name: 'video 4' })
55 uuids.push(uuid)
56
57 await waitJobs(servers)
58
59 const storyboards = await listStoryboardFiles(servers[0])
60 existingStoryboardName = storyboards[0]
61 })
62
63 it('Should create a storyboard of a video', async function () {
64 this.timeout(120000)
65
66 for (const uuid of [ uuids[0], uuids[3] ]) {
67 const command = `npm run create-generate-storyboard-job -- -v ${uuid}`
68 await servers[0].cli.execWithEnv(command)
69 }
70
71 await waitJobs(servers)
72
73 {
74 const storyboards = await listStoryboardFiles(servers[0])
75 expect(storyboards).to.have.lengthOf(2)
76 expect(storyboards).to.not.include(existingStoryboardName)
77
78 existingStoryboardName = storyboards[0]
79 }
80
81 for (const server of servers) {
82 for (const uuid of [ uuids[0], uuids[3] ]) {
83 const { storyboards } = await server.storyboard.list({ id: uuid })
84 expect(storyboards).to.have.lengthOf(1)
85
86 await makeGetRequest({ url: server.url, path: storyboards[0].storyboardPath, expectedStatus: HttpStatusCode.OK_200 })
87 }
88 }
89 })
90
91 it('Should create missing storyboards', async function () {
92 this.timeout(120000)
93
94 const command = `npm run create-generate-storyboard-job -- -a`
95 await servers[0].cli.execWithEnv(command)
96
97 await waitJobs(servers)
98
99 {
100 const storyboards = await listStoryboardFiles(servers[0])
101 expect(storyboards).to.have.lengthOf(4)
102 expect(storyboards).to.include(existingStoryboardName)
103 }
104
105 for (const server of servers) {
106 for (const uuid of uuids) {
107 const { storyboards } = await server.storyboard.list({ id: uuid })
108 expect(storyboards).to.have.lengthOf(1)
109
110 await makeGetRequest({ url: server.url, path: storyboards[0].storyboardPath, expectedStatus: HttpStatusCode.OK_200 })
111 }
112 }
113 })
114
115 after(async function () {
116 await sql.cleanup()
117
118 await cleanupTests(servers)
119 })
120})