@pipedream/testmo 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/append-to-automation-run/append-to-automation-run.mjs +99 -0
- package/actions/append-to-thread/append-to-thread.mjs +147 -0
- package/actions/create-automation-run/create-automation-run.mjs +113 -0
- package/actions/list-automation-runs/list-automation-runs.mjs +41 -0
- package/actions/list-project-sessions/list-project-sessions.mjs +41 -0
- package/common/constants.mjs +26 -0
- package/common/utils.mjs +16 -0
- package/package.json +5 -5
- package/testmo.app.mjs +236 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import testmo from "../../testmo.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "testmo-append-to-automation-run",
|
|
6
|
+
name: "Append to Automation Run",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Appends test artifacts, fields or links to an existing automation run. [See the documentation](https://docs.testmo.com/api/reference/automation-runs#post-automation-runs-automation_run_id-append)",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
testmo,
|
|
12
|
+
projectId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
testmo,
|
|
15
|
+
"projectId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
automationRunId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
testmo,
|
|
21
|
+
"automationRunId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
projectId: c.projectId,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
artifacts: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
testmo,
|
|
30
|
+
"artifacts",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
links: {
|
|
34
|
+
type: "string[]",
|
|
35
|
+
label: "Links",
|
|
36
|
+
description: "List of links to attach to the automation run (such as a link back to the build in the CI tool that triggered the tests).",
|
|
37
|
+
optional: true,
|
|
38
|
+
},
|
|
39
|
+
numFields: {
|
|
40
|
+
type: "integer",
|
|
41
|
+
label: "Number of Fields",
|
|
42
|
+
description: "Number of fields to enter name, type, and value for",
|
|
43
|
+
optional: true,
|
|
44
|
+
reloadProps: true,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
async additionalProps() {
|
|
48
|
+
const props = {};
|
|
49
|
+
for (let i = 1; i <= this.numFields; i++) {
|
|
50
|
+
props[`name_${i}`] = {
|
|
51
|
+
type: "string",
|
|
52
|
+
label: `Field ${i} - Name`,
|
|
53
|
+
};
|
|
54
|
+
props[`type_${i}`] = {
|
|
55
|
+
type: "integer",
|
|
56
|
+
label: `Field ${i} - Type`,
|
|
57
|
+
options: constants.FIELD_TYPES,
|
|
58
|
+
};
|
|
59
|
+
props[`value_${i}`] = {
|
|
60
|
+
type: "string",
|
|
61
|
+
label: `Field ${i} - Value`,
|
|
62
|
+
optional: true,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return props;
|
|
66
|
+
},
|
|
67
|
+
async run({ $ }) {
|
|
68
|
+
const artifacts = this.artifacts?.map((artifact) => ({
|
|
69
|
+
name: artifact,
|
|
70
|
+
url: artifact,
|
|
71
|
+
}));
|
|
72
|
+
const links = this.links?.map((link) => ({
|
|
73
|
+
name: link,
|
|
74
|
+
url: link,
|
|
75
|
+
}));
|
|
76
|
+
const fields = [];
|
|
77
|
+
for (let i = 1; i <= this.numFields; i++) {
|
|
78
|
+
fields.push({
|
|
79
|
+
name: this[`name_${i}`],
|
|
80
|
+
type: this[`type_${i}`],
|
|
81
|
+
value: this[`value_${i}`],
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const response = await this.testmo.appendToAutomationRun({
|
|
86
|
+
automationRunId: this.automationRunId,
|
|
87
|
+
data: {
|
|
88
|
+
artifacts,
|
|
89
|
+
links,
|
|
90
|
+
fields,
|
|
91
|
+
},
|
|
92
|
+
$,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
$.export("$summary", `Successfully appended data to automation run with ID ${this.automationRunId}.`);
|
|
96
|
+
|
|
97
|
+
return response;
|
|
98
|
+
},
|
|
99
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import testmo from "../../testmo.app.mjs";
|
|
2
|
+
import constants from "../../common/constants.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "testmo-append-to-thread",
|
|
6
|
+
name: "Append to Thread in Automation Run",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
description: "Appends test artifacts, fields or test results to an existing thread in an automation run. [See the documentation](https://docs.testmo.com/api/reference/automation-runs#post-automation-runs-threads-automation_run_thread_id-append)",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
testmo,
|
|
12
|
+
projectId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
testmo,
|
|
15
|
+
"projectId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
automationRunId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
testmo,
|
|
21
|
+
"automationRunId",
|
|
22
|
+
(c) => ({
|
|
23
|
+
projectId: c.projectId,
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
threadId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
testmo,
|
|
30
|
+
"threadId",
|
|
31
|
+
(c) => ({
|
|
32
|
+
automationRunId: c.automationRunId,
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
elapsedObserved: {
|
|
37
|
+
type: "integer",
|
|
38
|
+
label: "Elapsed Observed",
|
|
39
|
+
description: "Partial observed elapsed (execution time) in microseconds to add to the overall observed time of the thread.",
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
42
|
+
artifacts: {
|
|
43
|
+
propDefinition: [
|
|
44
|
+
testmo,
|
|
45
|
+
"artifacts",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
numFields: {
|
|
49
|
+
type: "integer",
|
|
50
|
+
label: "Number of Fields",
|
|
51
|
+
description: "Number of fields to append",
|
|
52
|
+
optional: true,
|
|
53
|
+
reloadProps: true,
|
|
54
|
+
},
|
|
55
|
+
numTests: {
|
|
56
|
+
type: "integer",
|
|
57
|
+
label: "Number of Tests",
|
|
58
|
+
description: "Number of tests to append",
|
|
59
|
+
optional: true,
|
|
60
|
+
reloadProps: true,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
async additionalProps() {
|
|
64
|
+
const props = {};
|
|
65
|
+
if (this.numFields) {
|
|
66
|
+
for (let i = 1; i <= this.numFields; i++) {
|
|
67
|
+
props[`fieldName_${i}`] = {
|
|
68
|
+
type: "string",
|
|
69
|
+
label: `Field ${i} - Name`,
|
|
70
|
+
};
|
|
71
|
+
props[`type_${i}`] = {
|
|
72
|
+
type: "integer",
|
|
73
|
+
label: `Field ${i} - Type`,
|
|
74
|
+
options: constants.FIELD_TYPES,
|
|
75
|
+
};
|
|
76
|
+
props[`value_${i}`] = {
|
|
77
|
+
type: "string",
|
|
78
|
+
label: `Field ${i} - Value`,
|
|
79
|
+
optional: true,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (this.numTests) {
|
|
84
|
+
for (let i = 1; i <= this.numTests; i++) {
|
|
85
|
+
props[`key_${i}`] = {
|
|
86
|
+
type: "string",
|
|
87
|
+
label: `Test ${i} - Key`,
|
|
88
|
+
description: "Key used to identify tests across multiple automation runs (in the context of the same source)",
|
|
89
|
+
};
|
|
90
|
+
props[`testName_${i}`] = {
|
|
91
|
+
type: "string",
|
|
92
|
+
label: `Test ${i} - Name`,
|
|
93
|
+
description: "Name of the test",
|
|
94
|
+
};
|
|
95
|
+
props[`status_${i}`] = {
|
|
96
|
+
type: "string",
|
|
97
|
+
label: `Test ${i} - Status`,
|
|
98
|
+
description: "Alias of the status for the result of the test (for example, `failed` or `passed`). The status aliases can be configured in Testmo's admin area.",
|
|
99
|
+
};
|
|
100
|
+
props[`folder_${i}`] = {
|
|
101
|
+
type: "string",
|
|
102
|
+
label: `Test ${i} - Folder`,
|
|
103
|
+
description: "Fully qualified name of the target folder of the test. Folders can be used to group related tests and usually map to class or type names as defined in the test automation suite",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return props;
|
|
108
|
+
},
|
|
109
|
+
async run({ $ }) {
|
|
110
|
+
const artifacts = this.artifacts?.map((artifact) => ({
|
|
111
|
+
name: artifact,
|
|
112
|
+
url: artifact,
|
|
113
|
+
}));
|
|
114
|
+
const fields = [];
|
|
115
|
+
for (let i = 1; i <= this.numFields; i++) {
|
|
116
|
+
fields.push({
|
|
117
|
+
name: this[`fieldName_${i}`],
|
|
118
|
+
type: this[`type_${i}`],
|
|
119
|
+
value: this[`value_${i}`],
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const tests = [];
|
|
123
|
+
for (let i = 1; i <= this.numTests; i++) {
|
|
124
|
+
tests.push({
|
|
125
|
+
key: this[`key_${i}`],
|
|
126
|
+
name: this[`testName_${i}`],
|
|
127
|
+
status: this[`status_${i}`],
|
|
128
|
+
folder: this[`folder_${i}`],
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const response = await this.testmo.appendToThread({
|
|
133
|
+
threadId: this.threadId,
|
|
134
|
+
data: {
|
|
135
|
+
elapsed_observed: this.elapsedObserved,
|
|
136
|
+
artifacts,
|
|
137
|
+
fields,
|
|
138
|
+
tests,
|
|
139
|
+
},
|
|
140
|
+
$,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
$.export("$summary", `Successfully appended data to automation run thread with ID ${this.threadId}.`);
|
|
144
|
+
|
|
145
|
+
return response;
|
|
146
|
+
},
|
|
147
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { parseArray } from "../../common/utils.mjs";
|
|
2
|
+
import testmo from "../../testmo.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "testmo-create-automation-run",
|
|
6
|
+
name: "Create Automation Run",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
description: "Creates a new automation run in a target project in preparation for adding threads and test results. [See the documentation](https://docs.testmo.com/api/reference/automation-runs#post-projects-project_id-automation-runs)",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
testmo,
|
|
12
|
+
projectId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
testmo,
|
|
15
|
+
"projectId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
name: {
|
|
19
|
+
type: "string",
|
|
20
|
+
label: "Name",
|
|
21
|
+
description: "Name of the new automation run.",
|
|
22
|
+
},
|
|
23
|
+
source: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
testmo,
|
|
26
|
+
"source",
|
|
27
|
+
({ projectId }) => ({
|
|
28
|
+
projectId,
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
config: {
|
|
33
|
+
type: "string",
|
|
34
|
+
label: "Config",
|
|
35
|
+
description: "Name of the configuration for the new automation run.",
|
|
36
|
+
optional: true,
|
|
37
|
+
},
|
|
38
|
+
configId: {
|
|
39
|
+
type: "string",
|
|
40
|
+
label: "Config Id",
|
|
41
|
+
description: "ID of the configuration for the new automation run. If both config and `configId` are specified, `configId` is given precedence.",
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
milestone: {
|
|
45
|
+
type: "string",
|
|
46
|
+
label: "Milestone",
|
|
47
|
+
description: "Name of the milestone for the new automation run.",
|
|
48
|
+
optional: true,
|
|
49
|
+
},
|
|
50
|
+
milestoneId: {
|
|
51
|
+
propDefinition: [
|
|
52
|
+
testmo,
|
|
53
|
+
"milestoneId",
|
|
54
|
+
({ projectId }) => ({
|
|
55
|
+
projectId,
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
optional: true,
|
|
59
|
+
},
|
|
60
|
+
tags: {
|
|
61
|
+
type: "string[]",
|
|
62
|
+
label: "Tags",
|
|
63
|
+
description: "List of tags for the new automation run. If a milestone in the same project has one or more matching automation tags, the new automation run is automatically linked to that milestone (unless `milestone` or `milestoneId` is also specified).",
|
|
64
|
+
optional: true,
|
|
65
|
+
},
|
|
66
|
+
artifacts: {
|
|
67
|
+
type: "string[]",
|
|
68
|
+
label: "Artifacts",
|
|
69
|
+
description: "List of externally stored test artifacts to link to the new automation run (such as log files, screenshots or test data). [See de documentation for details](https://docs.testmo.com/api/reference/automation-runs#post-projects-project_id-automation-runs)",
|
|
70
|
+
optional: true,
|
|
71
|
+
},
|
|
72
|
+
fields: {
|
|
73
|
+
type: "string[]",
|
|
74
|
+
label: "Fields",
|
|
75
|
+
description: "List of fields to attach to the new automation run (such as environment variables, errors or terminal output). [See de documentation for details](https://docs.testmo.com/api/reference/automation-runs#post-projects-project_id-automation-runs)",
|
|
76
|
+
optional: true,
|
|
77
|
+
},
|
|
78
|
+
links: {
|
|
79
|
+
type: "string[]",
|
|
80
|
+
label: "Links",
|
|
81
|
+
description: "List of links to attach to the new automation run (such as a link back to the build in the CI tool that triggered the tests). [See de documentation for details](https://docs.testmo.com/api/reference/automation-runs#post-projects-project_id-automation-runs)",
|
|
82
|
+
optional: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
async run({ $ }) {
|
|
86
|
+
const {
|
|
87
|
+
testmo,
|
|
88
|
+
projectId,
|
|
89
|
+
configId,
|
|
90
|
+
milestoneId,
|
|
91
|
+
artifacts,
|
|
92
|
+
fields,
|
|
93
|
+
links,
|
|
94
|
+
...data
|
|
95
|
+
} = this;
|
|
96
|
+
|
|
97
|
+
const response = await testmo.createAutomationRun({
|
|
98
|
+
$,
|
|
99
|
+
projectId,
|
|
100
|
+
data: {
|
|
101
|
+
config_id: configId,
|
|
102
|
+
milestone_id: milestoneId,
|
|
103
|
+
artifacts: parseArray(artifacts),
|
|
104
|
+
fields: parseArray(fields),
|
|
105
|
+
links: parseArray(links),
|
|
106
|
+
...data,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
$.export("$summary", `A new automation run with Id: ${response.id} was successfully created!`);
|
|
111
|
+
return response;
|
|
112
|
+
},
|
|
113
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import testmo from "../../testmo.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "testmo-list-automation-runs",
|
|
5
|
+
name: "List Automation Runs",
|
|
6
|
+
version: "0.0.2",
|
|
7
|
+
description: "List all automation runs for a project. [See the documentation](https://docs.testmo.com/api/reference/automation-runs#get-projects-project_id-automation-runs)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
testmo,
|
|
11
|
+
projectId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
testmo,
|
|
14
|
+
"projectId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const {
|
|
20
|
+
testmo,
|
|
21
|
+
projectId,
|
|
22
|
+
} = this;
|
|
23
|
+
|
|
24
|
+
const items = testmo.paginate({
|
|
25
|
+
fn: testmo.listAutomationRuns,
|
|
26
|
+
projectId,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const responseArray = [];
|
|
30
|
+
|
|
31
|
+
for await (const item of items) {
|
|
32
|
+
responseArray.push(item);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
$.export("$summary", `${responseArray.length} automation run${responseArray.length > 1
|
|
36
|
+
? "s were"
|
|
37
|
+
: " was"} successfully fetched!`);
|
|
38
|
+
|
|
39
|
+
return responseArray;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import testmo from "../../testmo.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "testmo-list-project-sessions",
|
|
5
|
+
name: "List Project Sessions",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
description: "List all sessions for a project. [See the documentation](https://docs.testmo.com/api/reference/sessions#get-projects-project_id-sessions)",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
testmo,
|
|
11
|
+
projectId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
testmo,
|
|
14
|
+
"projectId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
async run({ $ }) {
|
|
19
|
+
const {
|
|
20
|
+
testmo,
|
|
21
|
+
projectId,
|
|
22
|
+
} = this;
|
|
23
|
+
|
|
24
|
+
const items = testmo.paginate({
|
|
25
|
+
fn: testmo.listSessions,
|
|
26
|
+
projectId,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const responseArray = [];
|
|
30
|
+
|
|
31
|
+
for await (const item of items) {
|
|
32
|
+
responseArray.push(item);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
$.export("$summary", `${responseArray.length} session${responseArray.length === 1
|
|
36
|
+
? " was"
|
|
37
|
+
: "s were"} successfully retrieved!`);
|
|
38
|
+
|
|
39
|
+
return responseArray;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const FIELD_TYPES = [
|
|
2
|
+
{
|
|
3
|
+
value: 1,
|
|
4
|
+
label: "Regular string",
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
value: 2,
|
|
8
|
+
label: "Plain text",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
value: 3,
|
|
12
|
+
label: "HTML text",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
value: 4,
|
|
16
|
+
label: "Text to display in a terminal/console frame (with a monospaced font)",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: 5,
|
|
20
|
+
label: "URL",
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
FIELD_TYPES,
|
|
26
|
+
};
|
package/common/utils.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const parseArray = (array) => {
|
|
2
|
+
let parsedArray = array;
|
|
3
|
+
if (array) {
|
|
4
|
+
if (!Array.isArray(array)) {
|
|
5
|
+
parsedArray = JSON.parse(array);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
parsedArray = parsedArray.map((item) => {
|
|
9
|
+
if (typeof item != "object") {
|
|
10
|
+
return JSON.parse(item);
|
|
11
|
+
}
|
|
12
|
+
return item;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return parsedArray;
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/testmo",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pipedream Testmo Components",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "testmo.app.mjs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pipedream",
|
|
8
8
|
"testmo"
|
|
9
9
|
],
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
10
|
"homepage": "https://pipedream.com/apps/testmo",
|
|
14
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
15
12
|
"publishConfig": {
|
|
16
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^1.5.1"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/testmo.app.mjs
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
type: "app",
|
|
5
|
+
app: "testmo",
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
milestoneId: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Milestone Id",
|
|
10
|
+
description: "ID of the milestone for the new automation run. If both milestone and `milestoneId` are specified, `milestoneId` is given precedence.",
|
|
11
|
+
async options({
|
|
12
|
+
page, projectId,
|
|
13
|
+
}) {
|
|
14
|
+
const { result } = await this.listMilestones({
|
|
15
|
+
projectId,
|
|
16
|
+
params: {
|
|
17
|
+
page: page + 1,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return result.map(({
|
|
22
|
+
id: value, name: label,
|
|
23
|
+
}) => ({
|
|
24
|
+
label,
|
|
25
|
+
value,
|
|
26
|
+
}));
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
projectId: {
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Project Id",
|
|
32
|
+
description: "The Id of the target project.",
|
|
33
|
+
async options({ page }) {
|
|
34
|
+
const { result } = await this.listProjects({
|
|
35
|
+
params: {
|
|
36
|
+
page: page + 1,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return result.map(({
|
|
41
|
+
id: value, name: label,
|
|
42
|
+
}) => ({
|
|
43
|
+
label,
|
|
44
|
+
value,
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
source: {
|
|
49
|
+
type: "string",
|
|
50
|
+
label: "Source",
|
|
51
|
+
description: "Name of the source for the new automation run. If this source does not already exist in the target project, Testmo automatically creates a new one. It is recommended to keep source names short. Good examples are `backend`, `frontend` or `mobile-iphone`.",
|
|
52
|
+
async options({
|
|
53
|
+
page, projectId,
|
|
54
|
+
}) {
|
|
55
|
+
const { result } = await this.listSources({
|
|
56
|
+
projectId,
|
|
57
|
+
params: {
|
|
58
|
+
page: page + 1,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return result.map(({ name }) => name);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
automationRunId: {
|
|
66
|
+
type: "string",
|
|
67
|
+
label: "Automation Run Id",
|
|
68
|
+
description: "The Id of the automation run.",
|
|
69
|
+
async options({
|
|
70
|
+
projectId, page,
|
|
71
|
+
}) {
|
|
72
|
+
const { result } = await this.listAutomationRuns({
|
|
73
|
+
projectId,
|
|
74
|
+
params: {
|
|
75
|
+
page: page + 1,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return result.map(({
|
|
80
|
+
id: value, name: label,
|
|
81
|
+
}) => ({
|
|
82
|
+
label,
|
|
83
|
+
value,
|
|
84
|
+
}));
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
threadId: {
|
|
88
|
+
type: "string",
|
|
89
|
+
label: "Thread Id",
|
|
90
|
+
description: "The Id of the thread of the automation run.",
|
|
91
|
+
async options({ automationRunId }) {
|
|
92
|
+
const { result } = await this.getAutomationRun({
|
|
93
|
+
automationRunId,
|
|
94
|
+
});
|
|
95
|
+
if (!result || !result?.threads) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
return result.threads.map(({
|
|
99
|
+
id: value, name: label,
|
|
100
|
+
}) => ({
|
|
101
|
+
label,
|
|
102
|
+
value,
|
|
103
|
+
}));
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
artifacts: {
|
|
107
|
+
type: "string[]",
|
|
108
|
+
label: "Artifacts",
|
|
109
|
+
description: "List of URLs of externally stored test artifacts to link to the thread (such as log files, screenshots or test data)",
|
|
110
|
+
optional: true,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
methods: {
|
|
114
|
+
_apiUrl() {
|
|
115
|
+
return `https://${this.$auth.sitename}.testmo.net/api/v1`;
|
|
116
|
+
},
|
|
117
|
+
_getHeaders() {
|
|
118
|
+
return {
|
|
119
|
+
"Authorization": `Bearer ${this.$auth.api_key}`,
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
_makeRequest({
|
|
123
|
+
$ = this, path, ...opts
|
|
124
|
+
}) {
|
|
125
|
+
const config = {
|
|
126
|
+
url: `${this._apiUrl()}/${path}`,
|
|
127
|
+
headers: this._getHeaders(),
|
|
128
|
+
...opts,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return axios($, config);
|
|
132
|
+
},
|
|
133
|
+
createAutomationRun({
|
|
134
|
+
projectId, ...args
|
|
135
|
+
}) {
|
|
136
|
+
return this._makeRequest({
|
|
137
|
+
method: "POST",
|
|
138
|
+
path: `projects/${projectId}/automation/runs`,
|
|
139
|
+
...args,
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
listAutomationRuns({
|
|
143
|
+
projectId, ...args
|
|
144
|
+
}) {
|
|
145
|
+
return this._makeRequest({
|
|
146
|
+
path: `projects/${projectId}/automation/runs`,
|
|
147
|
+
...args,
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
listMilestones({
|
|
151
|
+
projectId, ...args
|
|
152
|
+
}) {
|
|
153
|
+
return this._makeRequest({
|
|
154
|
+
path: `projects/${projectId}/milestones`,
|
|
155
|
+
...args,
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
listProjects(args = {}) {
|
|
159
|
+
return this._makeRequest({
|
|
160
|
+
path: "projects",
|
|
161
|
+
...args,
|
|
162
|
+
});
|
|
163
|
+
},
|
|
164
|
+
listSources({
|
|
165
|
+
projectId, ...args
|
|
166
|
+
}) {
|
|
167
|
+
return this._makeRequest({
|
|
168
|
+
path: `projects/${projectId}/automation/sources`,
|
|
169
|
+
...args,
|
|
170
|
+
});
|
|
171
|
+
},
|
|
172
|
+
getAutomationRun({
|
|
173
|
+
automationRunId, ...args
|
|
174
|
+
}) {
|
|
175
|
+
return this._makeRequest({
|
|
176
|
+
path: `automation/runs/${automationRunId}`,
|
|
177
|
+
...args,
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
listSessions({
|
|
181
|
+
projectId, ...args
|
|
182
|
+
}) {
|
|
183
|
+
return this._makeRequest({
|
|
184
|
+
path: `projects/${projectId}/sessions`,
|
|
185
|
+
...args,
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
appendToAutomationRun({
|
|
189
|
+
automationRunId, ...args
|
|
190
|
+
}) {
|
|
191
|
+
return this._makeRequest({
|
|
192
|
+
method: "POST",
|
|
193
|
+
path: `automation/runs/${automationRunId}/append`,
|
|
194
|
+
...args,
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
appendToThread({
|
|
198
|
+
threadId, ...args
|
|
199
|
+
}) {
|
|
200
|
+
return this._makeRequest({
|
|
201
|
+
method: "POST",
|
|
202
|
+
path: `automation/runs/threads/${threadId}/append`,
|
|
203
|
+
...args,
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
async *paginate({
|
|
207
|
+
fn, params = {}, maxResults = null, ...args
|
|
208
|
+
}) {
|
|
209
|
+
let hasMore = false;
|
|
210
|
+
let count = 0;
|
|
211
|
+
let page = 0;
|
|
212
|
+
|
|
213
|
+
do {
|
|
214
|
+
params.page = ++page;
|
|
215
|
+
const {
|
|
216
|
+
result,
|
|
217
|
+
page: currentPage,
|
|
218
|
+
last_page: lastPage,
|
|
219
|
+
} = await fn({
|
|
220
|
+
params,
|
|
221
|
+
...args,
|
|
222
|
+
});
|
|
223
|
+
for (const d of result) {
|
|
224
|
+
yield d;
|
|
225
|
+
|
|
226
|
+
if (maxResults && ++count === maxResults) {
|
|
227
|
+
return count;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
hasMore = !(currentPage == lastPage);
|
|
232
|
+
|
|
233
|
+
} while (hasMore);
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
};
|