@pipedream/testmo 0.0.1 → 0.1.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.
|
@@ -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.1",
|
|
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.1",
|
|
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
|
+
};
|
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.1.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,155 @@
|
|
|
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
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
_apiUrl() {
|
|
68
|
+
return `https://${this.$auth.sitename}.testmo.net/api/v1`;
|
|
69
|
+
},
|
|
70
|
+
_getHeaders() {
|
|
71
|
+
return {
|
|
72
|
+
"Authorization": `Bearer ${this.$auth.api_key}`,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
_makeRequest({
|
|
76
|
+
$ = this, path, ...opts
|
|
77
|
+
}) {
|
|
78
|
+
const config = {
|
|
79
|
+
url: `${this._apiUrl()}/${path}`,
|
|
80
|
+
headers: this._getHeaders(),
|
|
81
|
+
...opts,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return axios($, config);
|
|
85
|
+
},
|
|
86
|
+
createAutomationRun({
|
|
87
|
+
projectId, ...args
|
|
88
|
+
}) {
|
|
89
|
+
return this._makeRequest({
|
|
90
|
+
method: "POST",
|
|
91
|
+
path: `projects/${projectId}/automation/runs`,
|
|
92
|
+
...args,
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
listAutomationRuns({
|
|
96
|
+
projectId, ...args
|
|
97
|
+
}) {
|
|
98
|
+
return this._makeRequest({
|
|
99
|
+
path: `projects/${projectId}/automation/runs`,
|
|
100
|
+
...args,
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
listMilestones({
|
|
104
|
+
projectId, ...args
|
|
105
|
+
}) {
|
|
106
|
+
return this._makeRequest({
|
|
107
|
+
path: `projects/${projectId}/milestones`,
|
|
108
|
+
...args,
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
listProjects(args = {}) {
|
|
112
|
+
return this._makeRequest({
|
|
113
|
+
path: "projects",
|
|
114
|
+
...args,
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
listSources({
|
|
118
|
+
projectId, ...args
|
|
119
|
+
}) {
|
|
120
|
+
return this._makeRequest({
|
|
121
|
+
path: `projects/${projectId}/automation/sources`,
|
|
122
|
+
...args,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
async *paginate({
|
|
126
|
+
fn, params = {}, maxResults = null, ...args
|
|
127
|
+
}) {
|
|
128
|
+
let hasMore = false;
|
|
129
|
+
let count = 0;
|
|
130
|
+
let page = 0;
|
|
131
|
+
|
|
132
|
+
do {
|
|
133
|
+
params.page = ++page;
|
|
134
|
+
const {
|
|
135
|
+
result,
|
|
136
|
+
page: currentPage,
|
|
137
|
+
last_page: lastPage,
|
|
138
|
+
} = await fn({
|
|
139
|
+
params,
|
|
140
|
+
...args,
|
|
141
|
+
});
|
|
142
|
+
for (const d of result) {
|
|
143
|
+
yield d;
|
|
144
|
+
|
|
145
|
+
if (maxResults && ++count === maxResults) {
|
|
146
|
+
return count;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
hasMore = !(currentPage == lastPage);
|
|
151
|
+
|
|
152
|
+
} while (hasMore);
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
};
|