Skip to content

Commit a6bd870

Browse files
authored
enhancement: Chore/code cleanup (#133)
* refactor: streamline test run case handling in TestPlanItReporter - Removed unnecessary variable declarations and simplified the logic for retrieving or creating test run cases. - Enhanced logging to provide clearer feedback when cases are added to the run. - Cleaned up unused variables and improved code readability across multiple files. * refactor: simplify data handling and improve readability across components - Removed unnecessary fallback values in data assignments to enhance clarity. - Streamlined conditional checks and improved logic for better performance. - Cleaned up unused variables and optimized component rendering in various files.
1 parent 808476e commit a6bd870

47 files changed

Lines changed: 107 additions & 244 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/wdio-testplanit-reporter/src/reporter.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -888,19 +888,15 @@ export default class TestPlanItReporter extends WDIOReporter {
888888
}
889889

890890
// Get or create test run case
891-
let testRunCaseId: number | undefined;
892891
const runCaseKey = `${this.state.testRunId}_${repositoryCaseId}`;
893892

894-
if (this.state.testRunCaseMap.has(runCaseKey)) {
895-
testRunCaseId = this.state.testRunCaseMap.get(runCaseKey);
896-
} else {
893+
if (!this.state.testRunCaseMap.has(runCaseKey)) {
897894
const testRunCase = await this.client.findOrAddTestCaseToRun({
898895
testRunId: this.state.testRunId,
899896
repositoryCaseId,
900897
});
901-
testRunCaseId = testRunCase.id;
902-
this.state.testRunCaseMap.set(runCaseKey, testRunCaseId);
903-
this.log('Added case to run:', testRunCaseId);
898+
this.state.testRunCaseMap.set(runCaseKey, testRunCase.id);
899+
this.log('Added case to run:', testRunCase.id);
904900
}
905901

906902
// Get status ID for the JUnit result

testplanit/app/[locale]/admin/api-tokens/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ function ApiTokensList() {
447447
{tokens && tokens.length > 0 ? (
448448
<DataTable<ExtendedApiToken, unknown>
449449
columns={columns}
450-
data={tokens || []}
450+
data={tokens}
451451
onSortChange={handleSortChange}
452452
sortConfig={sortConfig}
453453
columnVisibility={columnVisibility}

testplanit/app/[locale]/admin/imports/TestmoImportPanel.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,13 +1073,6 @@ export function TestmoImportPanel() {
10731073
return false;
10741074
}
10751075

1076-
if (!storageKey) {
1077-
setProcessingState("idle");
1078-
setUploadProgress({ state: "idle", percent: 0 });
1079-
setErrorKey("upload-failed");
1080-
return false;
1081-
}
1082-
10831076
let success = false;
10841077
try {
10851078
setProcessingState("analyzing");

testplanit/app/[locale]/admin/projects/ProjectGroupPermissions.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ export function ProjectGroupPermissions({
152152
return null;
153153
}
154154

155-
let effectiveAccessDisplay = "";
156155
let combinedValue = ""; // For the Select component value
157156

158157
const currentAccessType = permission.accessType;
@@ -161,27 +160,22 @@ export function ProjectGroupPermissions({
161160
// Determine the current combined value for the select dropdown
162161
if (currentAccessType === "PROJECT_DEFAULT") {
163162
combinedValue = "PROJECT_DEFAULT";
164-
effectiveAccessDisplay = tGlobal("common.labels.access.projectDefault");
165163
} else if (currentAccessType === ProjectAccessType.NO_ACCESS) {
166164
combinedValue = "NO_ACCESS";
167-
effectiveAccessDisplay = tGlobal("common.labels.access.noAccess");
168165
} else if (currentAccessType === ProjectAccessType.GLOBAL_ROLE) {
169166
combinedValue = "GLOBAL_ROLE";
170-
effectiveAccessDisplay = tGlobal("common.labels.access.usersGlobalRole");
171167
} else if (
172168
currentAccessType === ProjectAccessType.SPECIFIC_ROLE &&
173169
currentRoleId &&
174170
currentRoleId !== "NONE"
175171
) {
176172
combinedValue = `ROLE_${currentRoleId}`;
177-
effectiveAccessDisplay = tGlobal("common.labels.access.specificRole");
178173
} else {
179174
// Fallback or inconsistent state - default to Project Default display
180175
console.warn(
181176
`Inconsistent permission state for group ${groupIdStr}: accessType=${currentAccessType}, roleId=${currentRoleId}`
182177
);
183178
combinedValue = "PROJECT_DEFAULT";
184-
effectiveAccessDisplay = tGlobal("common.labels.access.projectDefault");
185179
}
186180

187181
return (

testplanit/app/[locale]/projects/repository/[projectId]/BulkEditModal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,11 +1155,9 @@ export function BulkEditModal({
11551155
schema = strSchema.nullable(); // Allow null/empty string if not required
11561156
break;
11571157
case "Text Long":
1158-
// Start with string, apply nullability/parsing later
1159-
let textSchema: z.ZodTypeAny = z.string();
1160-
11611158
if (isRequired) {
1162-
textSchema = textSchema.refine(
1159+
// If required, it must be a non-empty, valid JSON string.
1160+
schema = z.string().refine(
11631161
(val) => {
11641162
if (!val) return false;
11651163
try {
@@ -1173,8 +1171,6 @@ export function BulkEditModal({
11731171
},
11741172
{ message: "Content is required" }
11751173
);
1176-
// If required, it must be a non-empty, valid JSON string.
1177-
// Nullable is handled separately.
11781174
} else {
11791175
// If not required, allow null/undefined, OR valid JSON string (can be empty)
11801176
schema = z

testplanit/app/[locale]/projects/repository/[projectId]/FieldValueInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,10 @@ export function FieldValueInput({
432432
);
433433

434434
case "Text Long":
435-
let initialTextContent = emptyEditorContent;
435+
let initialTextContent;
436436
try {
437437
initialTextContent = value ? JSON.parse(value) : emptyEditorContent;
438-
} catch (error) {
438+
} catch {
439439
initialTextContent = emptyEditorContent;
440440
}
441441

testplanit/app/[locale]/projects/repository/[projectId]/StepsForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,7 @@ const StepsForm: React.FC<StepsFormProps> = ({
815815
}
816816
const lowerCaseQuery = query.toLowerCase();
817817
// Correctly treat allSharedStepGroupsData as a direct array
818-
const typedData = (allSharedStepGroupsData ||
819-
[]) as SharedStepGroupWithCount[];
818+
const typedData = allSharedStepGroupsData as SharedStepGroupWithCount[];
820819

821820
const filtered = typedData.filter((group) =>
822821
group.name.toLowerCase().includes(lowerCaseQuery)
@@ -910,7 +909,7 @@ const StepsForm: React.FC<StepsFormProps> = ({
910909
>
911910
<Layers className="h-5 w-5" />
912911
{tRepoSteps("createSharedSteps", {
913-
number: selectedStepIndices.length || 0,
912+
number: selectedStepIndices.length,
914913
})}
915914
</Button>
916915
)}

testplanit/app/[locale]/projects/repository/[projectId]/[caseId]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ export default function TestCaseDetails() {
17561756
type="button"
17571757
variant="outline"
17581758
onClick={handleCancel}
1759-
disabled={isSubmitting || isLoadingSharedStepGroups}
1759+
disabled={isLoadingSharedStepGroups}
17601760
>
17611761
<div className="flex items-center">
17621762
<CircleSlash2 className="w-5 h-5 mr-2" />

testplanit/app/[locale]/projects/runs/[projectId]/DuplicateTestRunDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ const DuplicateTestRunDialog: React.FC<DuplicateTestRunDialogProps> = ({
343343
if (!open) return null;
344344
if (
345345
isLoadingOriginalRun ||
346-
(open && !testRunCasesDataForStatusList && isLoadingCasesForStatusList)
346+
(!testRunCasesDataForStatusList && isLoadingCasesForStatusList)
347347
) {
348348
return (
349349
<Dialog open={open} onOpenChange={onOpenChange}>

testplanit/app/[locale]/projects/runs/[projectId]/[runId]/TestRunFormControls.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ function TestRunFormControls({
409409
issueTypeIconUrl={issue.issueTypeIconUrl}
410410
/>
411411
))
412-
: !isEditMode && (
412+
: (
413413
<span className="text-muted-foreground text-sm">
414414
{t("common.access.none")}
415415
</span>

0 commit comments

Comments
 (0)