Skip to content

Commit 16336b3

Browse files
committed
[Action] TestMonitor - Create a new Test Result #13990
Actions - Create New Test Result
1 parent 28a5961 commit 16336b3

File tree

8 files changed

+136
-7
lines changed

8 files changed

+136
-7
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import testmonitor from "../../testmonitor.app.mjs";
3+
4+
export default {
5+
key: "testmonitor-create-test-result",
6+
name: "Create Test Result",
7+
description: "Create a new test result. [See the docs here](https://docs.testmonitor.com/#tag/Test-Results/operation/PostTestResult)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
testmonitor,
12+
projectId: {
13+
propDefinition: [
14+
testmonitor,
15+
"projectId",
16+
],
17+
},
18+
testCaseId: {
19+
propDefinition: [
20+
testmonitor,
21+
"testCaseId",
22+
({ projectId }) => ({
23+
projectId,
24+
}),
25+
],
26+
},
27+
testRunId: {
28+
propDefinition: [
29+
testmonitor,
30+
"testRunId",
31+
({ projectId }) => ({
32+
projectId,
33+
}),
34+
],
35+
},
36+
draft: {
37+
type: "boolean",
38+
label: "Draft",
39+
description: "Denotes if this test result is marked as draft.",
40+
},
41+
description: {
42+
type: "string",
43+
label: "Description",
44+
description: "The description of the test result.",
45+
optional: true,
46+
},
47+
},
48+
async run({ $ }) {
49+
try {
50+
const response = await this.testmonitor.createTestResult({
51+
$,
52+
data: {
53+
test_case_id: this.testCaseId,
54+
test_run_id: this.testRunId,
55+
draft: this.draft,
56+
description: this.description,
57+
},
58+
});
59+
60+
$.export("$summary", `Successfully created test result with Id: ${response.data.id}`);
61+
return response;
62+
} catch (e) {
63+
throw new ConfigurationError((e.response.status === 400)
64+
? "It seems that there is already a test with this configuration!"
65+
: e.response.data.message);
66+
}
67+
},
68+
};

components/testmonitor/actions/find-issue/find-issue.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "testmonitor-find-issue",
77
name: "Find an Issue",
88
description: "Retrieve a list of issues. [See the docs here](https://docs.testmonitor.com/#tag/Issues/operation/GetIssueCollection)",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "action",
1111
props: {
1212
...common.props,

components/testmonitor/actions/find-project/find-project.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "testmonitor-find-project",
77
name: "Find a Project",
88
description: "Retrieve a list of projects. [See the docs here](https://docs.testmonitor.com/#tag/Projects/operation/GetProjectCollection)",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "action",
1111
props: {
1212
...common.props,

components/testmonitor/actions/find-test-result/find-test-result.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "testmonitor-find-test-result",
77
name: "Find a Test Result",
88
description: "Retrieve a list of test results. [See the docs here](https://docs.testmonitor.com/#tag/Test-Results/operation/GetTestResultCollection)",
9-
version: "0.0.2",
9+
version: "0.0.3",
1010
type: "action",
1111
props: {
1212
...common.props,

components/testmonitor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/testmonitor",
3-
"version": "0.0.3",
3+
"version": "0.1.0",
44
"description": "Pipedream Testmonitor Components",
55
"main": "testmonitor.app.mjs",
66
"keywords": [
@@ -10,7 +10,7 @@
1010
"homepage": "https://pipedream.com/apps/testmonitor",
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"dependencies": {
13-
"@pipedream/platform": "^1.2.1",
13+
"@pipedream/platform": "^3.0.3",
1414
"moment": "^2.29.4"
1515
},
1616
"publishConfig": {

components/testmonitor/sources/new-issue/new-issue.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "testmonitor-new-issue",
66
name: "New Issue",
77
description: "Emit new event when a new issue is created.",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/testmonitor/sources/new-test-result/new-test-result.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "testmonitor-new-test-result",
66
name: "New Test Result",
77
description: "Emit new event when a new test result is created.",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/testmonitor/testmonitor.app.mjs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,48 @@ export default {
5454
}));
5555
},
5656
},
57+
testCaseId: {
58+
type: "integer",
59+
label: "Test Case Id",
60+
description: "The test case identifier where this test result belongs to.",
61+
async options({
62+
page, projectId,
63+
}) {
64+
const { data } = await this.getTestCases({
65+
page: page + 1,
66+
params: {
67+
project_id: projectId,
68+
},
69+
});
70+
return data.map(({
71+
id: value, name: label,
72+
}) => ({
73+
label,
74+
value,
75+
}));
76+
},
77+
},
78+
testRunId: {
79+
type: "integer",
80+
label: "Test Run Id",
81+
description: "The test run identifier where this test result belongs to.",
82+
async options({
83+
page, projectId,
84+
}) {
85+
const { data } = await this.getTestRuns({
86+
page: page + 1,
87+
params: {
88+
project_id: projectId,
89+
},
90+
});
91+
return data.map(({
92+
id: value, name: label,
93+
}) => ({
94+
label,
95+
value,
96+
}));
97+
},
98+
},
5799
query: {
58100
type: "string",
59101
label: "Query",
@@ -104,6 +146,25 @@ export default {
104146

105147
return axios($, config);
106148
},
149+
createTestResult(opts = {}) {
150+
return this._makeRequest({
151+
method: "POST",
152+
path: "test-results",
153+
...opts,
154+
});
155+
},
156+
getTestCases(opts = {}) {
157+
return this._makeRequest({
158+
path: "test-cases",
159+
...opts,
160+
});
161+
},
162+
getTestRuns(opts = {}) {
163+
return this._makeRequest({
164+
path: "test-runs",
165+
...opts,
166+
});
167+
},
107168
getIssue({
108169
$, issueId,
109170
}) {

0 commit comments

Comments
 (0)