-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtest-sessions.ts
More file actions
62 lines (53 loc) · 1.79 KB
/
test-sessions.ts
File metadata and controls
62 lines (53 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import type { AxiosInstance } from 'axios'
import { GitInformation } from '../services/util'
import { RetryStrategy, SharedFile } from '../constructs'
import { compressJSONPayload } from './util'
type RunTestSessionRequest = {
name: string,
checkRunJobs: any[],
project: { logicalId: string },
sharedFiles?: SharedFile[]
runLocation: string|{ type: 'PUBLIC', region: string }|{ type: 'PRIVATE', slugName: string, id: string },
repoInfo?: GitInformation | null,
environment?: string | null,
shouldRecord: boolean,
streamLogs?: boolean,
}
type TriggerTestSessionRequest = {
name: string,
runLocation: string|{ type: 'PUBLIC', region: string }|{ type: 'PRIVATE', slugName: string, id: string },
shouldRecord: boolean,
targetTags: string[][],
checkRunSuiteId: string,
environmentVariables: Array<{ key: string, value: string }>,
repoInfo: GitInformation | null,
environment: string | null,
testRetryStrategy: RetryStrategy | null,
}
export type TestResultsShortLinks = {
testResultLink: string
testTraceLinks: string[]
videoLinks: string[]
screenshotLinks: string[]
}
class TestSessions {
api: AxiosInstance
constructor (api: AxiosInstance) {
this.api = api
}
run (payload: RunTestSessionRequest) {
return this.api.post('/next/test-sessions/run', payload, {
transformRequest: compressJSONPayload,
})
}
trigger (payload: TriggerTestSessionRequest) {
return this.api.post('/next/test-sessions/trigger', payload)
}
getShortLink (id: string) {
return this.api.get<{ link: string }>(`/next/test-sessions/${id}/link`)
}
getResultShortLinks (testSessionId: string, testResultId: string) {
return this.api.get<TestResultsShortLinks>(`/next/test-sessions/${testSessionId}/results/${testResultId}/links`)
}
}
export default TestSessions