Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/parsera/parsera.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {
getFieldProps as additionalProps, getProperties,
} from "../../common/utils.mjs";
import tricentisQtest from "../../tricentis_qtest.app.mjs";

export default {
key: "tricentis_qtest-create-requirement",
name: "Create Requirement",
description: "Create a new requirement. [See the documentation](https://documentation.tricentis.com/qtest/od/en/content/apis/apis/requirement_apis.htm#CreateARequirement)",
version: "0.0.1",
type: "action",
props: {
tricentisQtest,
projectId: {
propDefinition: [
tricentisQtest,
"projectId",
],
},
parentId: {
propDefinition: [
tricentisQtest,
"parentId",
({ projectId }) => ({
projectId,
}),
],
reloadProps: true,
},
name: {
type: "string",
label: "Name",
description: "Requirement name",
},
},
additionalProps,
methods: {
getDataFields() {
return this.tricentisQtest.getRequirementFields(this.projectId);
},
getProperties,
},
async run({ $ }) {
const { // eslint-disable-next-line no-unused-vars
tricentisQtest, projectId, parentId, name, getProperties, getDataFields, ...fields
} = this;
const response = await tricentisQtest.createRequirement({
$,
projectId,
params: {
parentId,
},
data: {
name,
properties: getProperties(fields),
},
});
$.export("$summary", `Successfully created requirement (ID: ${response.id})`);
return response;
},
};
38 changes: 38 additions & 0 deletions components/tricentis_qtest/actions/get-defect/get-defect.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import tricentisQtest from "../../tricentis_qtest.app.mjs";

export default {
key: "tricentis_qtest-get-defect",
name: "Get Defect",
description: "Get details of a defect. [See the documentation](https://documentation.tricentis.com/qtest/od/en/content/apis/apis/defect_apis.htm#GetRecentlyUpdatedDefects)",
version: "0.0.1",
type: "action",
props: {
tricentisQtest,
projectId: {
propDefinition: [
tricentisQtest,
"projectId",
],
},
defectId: {
propDefinition: [
tricentisQtest,
"defectId",
({ projectId }) => ({
projectId,
}),
],
},
},
async run({ $ }) {
const {
tricentisQtest, ...args
} = this;
const response = await tricentisQtest.getDefect({
$,
...args,
});
$.export("$summary", `Successfully fetched defect (ID: ${args.defectId})`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import tricentisQtest from "../../tricentis_qtest.app.mjs";

export default {
key: "tricentis_qtest-get-requirement",
name: "Get Requirement",
description: "Get details of a requirement. [See the documentation](https://documentation.tricentis.com/qtest/od/en/content/apis/apis/requirement_apis.htm#GetARequirementByItsID)",
version: "0.0.1",
type: "action",
props: {
tricentisQtest,
projectId: {
propDefinition: [
tricentisQtest,
"projectId",
],
},
requirementId: {
propDefinition: [
tricentisQtest,
"requirementId",
({ projectId }) => ({
projectId,
}),
],
},
},
async run({ $ }) {
const {
tricentisQtest, ...args
} = this;
const response = await tricentisQtest.getRequirement({
$,
...args,
});
$.export("$summary", `Successfully fetched requirement (ID: ${args.requirementId})`);
return response;
},
};
43 changes: 43 additions & 0 deletions components/tricentis_qtest/actions/submit-defect/submit-defect.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
getFieldProps as additionalProps, getProperties,
} from "../../common/utils.mjs";
import tricentisQtest from "../../tricentis_qtest.app.mjs";

export default {
key: "tricentis_qtest-submit-defect",
name: "Submit Defect",
description: "Submit a new defect. [See the documentation](https://documentation.tricentis.com/qtest/od/en/content/apis/apis/defect_apis.htm#SubmitaDefect)",
version: "0.0.1",
type: "action",
props: {
tricentisQtest,
projectId: {
propDefinition: [
tricentisQtest,
"projectId",
],
reloadProps: true,
},
},
additionalProps,
methods: {
getDataFields() {
return this.tricentisQtest.getDefectFields(this.projectId);
},
getProperties,
},
async run({ $ }) {
const { // eslint-disable-next-line no-unused-vars
tricentisQtest, projectId, getProperties, getDataFields, ...fields
} = this;
const response = await tricentisQtest.createDefect({
$,
projectId,
data: {
properties: getProperties(fields),
},
});
$.export("$summary", `Successfully submitted defect (ID: ${response.id})`);
return response;
},
};
53 changes: 53 additions & 0 deletions components/tricentis_qtest/actions/update-defect/update-defect.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
getFieldProps as additionalProps, getProperties,
} from "../../common/utils.mjs";
import tricentisQtest from "../../tricentis_qtest.app.mjs";

export default {
key: "tricentis_qtest-update-defect",
name: "Update Defect",
description: "Update a defect. [See the documentation](https://documentation.tricentis.com/qtest/od/en/content/apis/apis/defect_apis.htm#UpdateADefect)",
version: "0.0.1",
type: "action",
props: {
tricentisQtest,
projectId: {
propDefinition: [
tricentisQtest,
"projectId",
],
},
defectId: {
propDefinition: [
tricentisQtest,
"defectId",
({ projectId }) => ({
projectId,
}),
],
reloadProps: true,
},
},
additionalProps,
methods: {
getDataFields() {
return this.tricentisQtest.getDefectFields(this.projectId);
},
getProperties,
},
async run({ $ }) {
const { // eslint-disable-next-line no-unused-vars
tricentisQtest, projectId, defectId, getProperties, getDataFields, ...fields
} = this;
const response = await tricentisQtest.updateDefect({
$,
projectId,
defectId,
data: {
properties: getProperties(fields),
},
});
$.export("$summary", `Successfully updated defect (ID: ${defectId})`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {
getFieldProps as additionalProps, getProperties,
} from "../../common/utils.mjs";
import tricentisQtest from "../../tricentis_qtest.app.mjs";

export default {
key: "tricentis_qtest-update-requirement",
name: "Update Requirement",
description: "Update a requirement. [See the documentation](https://documentation.tricentis.com/qtest/od/en/content/apis/apis/requirement_apis.htm#UpdateARequirement)",
version: "0.0.1",
type: "action",
props: {
tricentisQtest,
projectId: {
propDefinition: [
tricentisQtest,
"projectId",
],
},
requirementId: {
propDefinition: [
tricentisQtest,
"requirementId",
({ projectId }) => ({
projectId,
}),
],
reloadProps: true,
},
name: {
type: "string",
label: "Name",
description: "Requirement name",
},
},
additionalProps,
methods: {
getDataFields() {
return this.tricentisQtest.getRequirementFields(this.projectId);
},
getProperties,
},
async run({ $ }) {
const { /* eslint-disable no-unused-vars */
tricentisQtest,
projectId,
requirementId,
name,
getProperties,
getDataFields,
...fields
} = this; /* eslint-enable no-unused-vars */
const response = await tricentisQtest.updateRequirement({
$,
projectId,
requirementId,
data: {
name,
properties: getProperties(fields),
},
});
$.export("$summary", `Successfully updated requirement (ID: ${requirementId})`);
return response;
},
};
54 changes: 54 additions & 0 deletions components/tricentis_qtest/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export async function getFieldProps() {
if (this.useFields === false) return {};

const fields = await this.getDataFields();

function getFieldType(type) {
switch (type) {
case "LongText":
default:
return "string";
case "Number":
return "integer";
case "ArrayNumber":
return "integer[]";
}
}

const result = {};
const isUpdate = !!(this.requirementId || this.defectId);

fields?.forEach(({
id, label, attribute_type: fieldType, allowed_values: options, required,
}) => {
const type = getFieldType(fieldType);
result[`field_${id}`] = {
label,
type,
description: `Field ID: ${id}`,
optional: isUpdate || !required,
...(options && {
options: options.map(({
label, value,
}) => ({
label,
value: (type === "string" && typeof value !== "string")
? value.toString()
: value,
Comment on lines +34 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Handle potential null or undefined values in value

In the options mapping:

value: (type === "string" && typeof value !== "string")
  ? value.toString()
  : value,

Consider adding a check to handle cases where value might be null or undefined to prevent runtime errors when calling toString() on null or undefined.

Apply this diff to add a null check:

 value: (type === "string" && typeof value !== "string")
-  ? value.toString()
+  ? (value != null ? value.toString() : "")
   : value,

})),
}),
};
});

return result;
}

export function getProperties(fields) {
return fields && Object.entries(fields).map(([
id,
value,
]) => ({
field_id: id.split("_").pop(),
field_value: value,
}));
}
7 changes: 5 additions & 2 deletions components/tricentis_qtest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/tricentis_qtest",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Tricentis qTest Components",
"main": "tricentis_qtest.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
Loading
Loading