Skip to content

Commit 064b9ae

Browse files
committed
Update Defect + many adjustments & improvements
1 parent fed537e commit 064b9ae

File tree

5 files changed

+93
-21
lines changed

5 files changed

+93
-21
lines changed

components/tricentis_qtest/actions/create-requirement/create-requirement.mjs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@ export default {
2525
projectId,
2626
}),
2727
],
28+
reloadProps: true,
2829
},
2930
name: {
3031
type: "string",
3132
label: "Name",
3233
description: "Requirement name",
3334
},
34-
useFields: {
35-
propDefinition: [
36-
tricentisQtest,
37-
"useFields",
38-
],
39-
},
4035
},
4136
additionalProps,
4237
methods: {
@@ -47,7 +42,7 @@ export default {
4742
},
4843
async run({ $ }) {
4944
const { // eslint-disable-next-line no-unused-vars
50-
tricentisQtest, projectId, parentId, useFields, name, getProperties, getDataFields, ...fields
45+
tricentisQtest, projectId, parentId, name, getProperties, getDataFields, ...fields
5146
} = this;
5247
const response = await tricentisQtest.createRequirement({
5348
$,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {
2+
getFieldProps as additionalProps, getProperties,
3+
} from "../../common/utils.mjs";
4+
import tricentisQtest from "../../tricentis_qtest.app.mjs";
5+
6+
export default {
7+
key: "tricentis_qtest-update-defect",
8+
name: "Update Defect",
9+
description: "Update a defect. [See the documentation](https://documentation.tricentis.com/qtest/od/en/content/apis/apis/defect_apis.htm#UpdateADefect)",
10+
version: "0.0.{{ts}}",
11+
type: "action",
12+
props: {
13+
tricentisQtest,
14+
projectId: {
15+
propDefinition: [
16+
tricentisQtest,
17+
"projectId",
18+
],
19+
},
20+
defectId: {
21+
propDefinition: [
22+
tricentisQtest,
23+
"defectId",
24+
({ projectId }) => ({
25+
projectId,
26+
}),
27+
],
28+
reloadProps: true,
29+
},
30+
},
31+
additionalProps,
32+
methods: {
33+
getDataFields() {
34+
return this.tricentisQtest.getDefectFields(this.projectId);
35+
},
36+
getProperties,
37+
},
38+
async run({ $ }) {
39+
const { // eslint-disable-next-line no-unused-vars
40+
tricentisQtest, projectId, defectId, getProperties, getDataFields, ...fields
41+
} = this;
42+
const response = await tricentisQtest.updateDefect({
43+
$,
44+
projectId,
45+
defectId,
46+
data: {
47+
properties: getProperties(fields),
48+
},
49+
});
50+
$.export("$summary", `Successfully updated defect (ID: ${defectId})`);
51+
return response;
52+
},
53+
};

components/tricentis_qtest/actions/update-requirement/update-requirement.mjs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@ export default {
2525
projectId,
2626
}),
2727
],
28+
reloadProps: true,
2829
},
2930
name: {
3031
type: "string",
3132
label: "Name",
3233
description: "Requirement name",
3334
},
34-
useFields: {
35-
propDefinition: [
36-
tricentisQtest,
37-
"useFields",
38-
],
39-
},
4035
},
4136
additionalProps,
4237
methods: {
@@ -50,7 +45,6 @@ export default {
5045
tricentisQtest,
5146
projectId,
5247
requirementId,
53-
useFields,
5448
name,
5549
getProperties,
5650
getDataFields,

components/tricentis_qtest/common/utils.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function getFieldProps() {
1818
console.log(fields);
1919

2020
const result = {};
21-
const isUpdate = this.requirementId || this.defectId;
21+
const isUpdate = !!(this.requirementId || this.defectId);
2222

2323
fields?.forEach(({
2424
id, label, attribute_type: fieldType, allowed_values: options, required,

components/tricentis_qtest/tricentis_qtest.app.mjs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ export default {
4040
page, projectId,
4141
}) {
4242
const requirements = await this.getRequirements({
43-
page,
4443
projectId,
44+
params: {
45+
page,
46+
},
4547
});
4648
return (requirements ?? []).map(({
4749
id, name,
@@ -51,11 +53,39 @@ export default {
5153
}));
5254
},
5355
},
54-
useFields: {
55-
type: "boolean",
56-
label: "Set Field Values",
57-
description: "Set to `true` to see available fields.",
58-
reloadProps: true,
56+
defectId: {
57+
type: "string",
58+
label: "Defect ID",
59+
description: "The ID of a defect. The listed options are defects that have been updated in the last 30 days.",
60+
async options({
61+
page, projectId, prevContext: { startTime },
62+
}) {
63+
if (!startTime) {
64+
const date = new Date();
65+
date.setDate(date.getDate() - 30);
66+
startTime = date.toISOString();
67+
}
68+
const fields = await this.getDefectFields(projectId);
69+
const summaryId = fields.find(({ label }) => label === "Summary")?.id;
70+
const defects = await this.getDefects({
71+
projectId,
72+
params: {
73+
page,
74+
startTime,
75+
},
76+
});
77+
return {
78+
options: (defects ?? []).map(({
79+
id, properties,
80+
}) => ({
81+
label: properties.find((f) => f.field_id === summaryId)?.field_value ?? id,
82+
value: id,
83+
})),
84+
context: {
85+
startTime,
86+
},
87+
};
88+
},
5989
},
6090
},
6191
methods: {

0 commit comments

Comments
 (0)