Skip to content

Conversation

@satvik007
Copy link
Contributor

@satvik007 satvik007 commented Jun 7, 2025

  • increase folder length, tcase title length
  • add type (standalone, template)
  • add custom fields support

Summary by CodeRabbit

  • New Features

    • Added support for custom fields in test cases, including dropdown and text types, with values shown in CSV exports.
    • CSV exports now include new columns for test case type, parameter values, and template suffix parameters.
    • Enhanced support for multiple requirements per test case with updated CSV formatting.
  • Bug Fixes

    • Improved validation to ensure all custom fields used in test cases are defined and values meet length limits.
  • Tests

    • Expanded test coverage to include success and failure scenarios for custom fields and dynamic string length validation.

- increase folder length, tcase title length
- add type (standalone, template)
- add custom fields support
@coderabbitai
Copy link

coderabbitai bot commented Jun 7, 2025

Caution

Review failed

The pull request is closed.

"""

Walkthrough

The changes introduce support for custom fields, test case types, parameter values, and template suffix parameters in the QA Sphere CSV export functionality. The data structures, validation logic, and CSV output were updated accordingly. Test coverage was expanded to include various success and failure scenarios involving custom fields and dynamic string length validation.

Changes

File(s) Change Summary
qascsv.go Added support for test case types, parameter values, template suffix params, and custom fields; updated data structures, validation, CSV header/row generation, and added methods for custom field handling.
qacsv_test.go Updated and expanded test cases for new fields and custom fields; added new tests for custom field success and failure scenarios; improved length validation testing with dynamic strings.

Sequence Diagram(s)

sequenceDiagram
    participant Tester
    participant QASphereCSV
    participant CSVExporter

    Tester->>QASphereCSV: AddCustomFields(customFields)
    Tester->>QASphereCSV: AddTestCases(testCases)
    QASphereCSV->>QASphereCSV: Validate test cases (types, custom fields, etc.)
    Tester->>QASphereCSV: Export to CSV
    QASphereCSV->>CSVExporter: Generate CSV rows (including custom fields)
    CSVExporter-->>Tester: Return CSV output
Loading

Possibly related PRs

  • Add initial commit #1: Initial commit establishing the base package and tests without advanced features; this PR builds directly upon and enhances that foundation.

Poem

🐇 In fields of tests where data grows,
New types and values in neat rows.
Custom fields with colors bright,
Parameters join the CSV light.
Rabbits hop with joyous cheer,
Testing’s clearer far and near! 🥕✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cadc895 and ef920a0.

📒 Files selected for processing (1)
  • qascsv.go (12 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@satvik007 satvik007 requested review from AndrianBdn and hi-rai June 7, 2025 13:08
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
qascsv.go (1)

234-248: Lookup of custom-field names is O(N²); cache the names once

Every time a test-case is validated we iterate over q.customFields for every entry in tc.CustomFields, yielding quadratic behaviour when many cases/fields are involved.

-   for systemName := range tc.CustomFields {
-       var found bool
-       for _, cf := range q.customFields {
-           if cf.SystemName == systemName {
-               found = true
-               break
-           }
-       }
-       if !found {
-           return errors.Errorf("custom field %s is not defined in QASphereCSV.customFields", systemName)
-       }
-   }
+   nameSet := make(map[string]struct{}, len(q.customFields))
+   for _, cf := range q.customFields {
+       nameSet[cf.SystemName] = struct{}{}
+   }
+   for systemName := range tc.CustomFields {
+       if _, ok := nameSet[systemName]; !ok {
+           return errors.Errorf("custom field %s is not defined in QASphereCSV.customFields", systemName)
+       }
+   }

For large data sets this single map construction slashes validation time.
[performance]

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa6dfd5 and b703528.

📒 Files selected for processing (2)
  • qacsv_test.go (8 hunks)
  • qascsv.go (11 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
qacsv_test.go (1)
qascsv.go (11)
  • CustomField (85-88)
  • CustomFieldTypeDropdown (82-82)
  • CustomFieldTypeText (81-81)
  • TestCase (96-136)
  • Priority (26-26)
  • CustomFieldValue (90-93)
  • Step (65-70)
  • Requirement (44-47)
  • File (56-62)
  • Link (50-53)
  • NewQASphereCSV (149-154)

Copy link
Contributor

@AndrianBdn AndrianBdn left a comment

Choose a reason for hiding this comment

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

great work! let's do few minor fixes and merge this

- add custom field duplicate check
- allow multiple requirements (backend already supports)
@satvik007 satvik007 requested a review from AndrianBdn June 9, 2025 10:04
Copy link
Contributor

@AndrianBdn AndrianBdn left a comment

Choose a reason for hiding this comment

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

Awesome - thank you @satvik007 !

Copy link
Collaborator

@hi-rai hi-rai left a comment

Choose a reason for hiding this comment

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

Looks okay to me. Few minor suggestion regarding adding/updating comments as this is a public repository

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
qascsv.go (2)

82-85: Complete validation for parameter value map entries.

The validation rule only validates map keys but not the string values, as noted in a previous review. Values could be oversized or empty and would pass validation.

Apply this fix to validate both keys and values:

-    Values   map[string]string `json:"values" validate:"required,dive,keys,max=255,endkeys"`
+    Values   map[string]string `json:"values" validate:"required,dive,keys,max=255,endkeys,max=255"`

63-67: Add security validation for file URLs.

The File struct contains URL fields that could reference external or unuploaded files, as highlighted in previous comments. Consider adding validation to ensure files are properly uploaded to QA Sphere.

The existing comment mentions users should upload files via the API. Consider adding validation to verify file IDs correspond to actual uploaded files in the QA Sphere project.

🧹 Nitpick comments (1)
qascsv.go (1)

107-107: Consider documenting the increased title length limit.

The title length limit was increased from 255 to 511 characters. This should be documented in comments or changelog to inform users of the expanded capability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dde6370 and cadc895.

📒 Files selected for processing (1)
  • qascsv.go (12 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
qascsv.go

[error] 198-205: gofumpt formatting check failed. The file qascsv.go has formatting differences detected by gofumpt.

🔇 Additional comments (5)
qascsv.go (5)

173-189: Good implementation addressing duplicate prevention.

The duplicate checking logic properly addresses the previous review concern about preventing duplicate custom field definitions.


259-276: Excellent custom field validation implementation.

The validation logic properly ensures that all custom fields referenced in test cases are pre-declared, preventing runtime errors during CSV generation.


202-204: Good default type handling.

Defaulting test case type to "standalone" when not specified provides a sensible fallback and maintains backward compatibility.


363-372: 🛠️ Refactor suggestion

Potential index mismatch in custom field column generation.

The custom field column assignment uses customFieldsMap[systemName] as the index, but if a test case doesn't have values for all declared custom fields, this could create sparse arrays with incorrect positioning.

Consider initializing the customFieldCols slice with empty strings to ensure all positions are filled:

-            customFieldCols := make([]string, len(customFieldsMap))
+            customFieldCols := make([]string, len(q.customFields))
+            for i := range customFieldCols {
+                customFieldCols[i] = ""
+            }
             for systemName, cfValue := range tc.CustomFields {
                 cfValueJSON, err := json.Marshal(cfValue)
                 if err != nil {
                     return nil, errors.Wrap(err, "json marshal custom field value")
                 }
 
                 customFieldCols[customFieldsMap[systemName]] = string(cfValueJSON)
             }

Likely an incorrect or invalid review comment.


306-312:

Details

❓ Verification inconclusive

Verify custom field header generation logic.

The custom field header format custom_field_{type}_{systemName} should be consistent with QA Sphere's CSV import expectations.

Please verify that the custom field header format matches QA Sphere's documentation:


🌐 Web query:

What is the expected CSV header format for custom fields in QA Sphere CSV imports?

💡 Result:

The CSV header format for custom fields in QA Sphere CSV imports follows a specific structure designed to properly import test cases into the QA Sphere Test Management System.

Test Case CSV Structure

QA Sphere requires the following standard columns in the CSV header for test case imports:

  • Folder
  • Name
  • Legacy ID
  • Draft
  • Priority
  • Tags
  • Requirements
  • Links
  • Files
  • Preconditions[1]

After these static columns, the CSV should contain dynamic columns for test steps in the following pattern:

  • Step1, Expected1
  • Step2, Expected2
  • And so on, depending on the maximum number of steps in any test case[1]

The steps columns appear as pairs, with each step followed by its expected result column. The number of step columns depends on how many steps your test cases require.

CSV Import Process

To import test cases in CSV format into QA Sphere:

  1. Open a project and navigate to the Test Cases tab
  2. Click the three dots menu
  3. Select Import
  4. When the CSV Import form appears, select your separator, choose the directory to import into, and pick your file[1]

During the import process, each test case is validated for proper formatting and content. The system automatically assigns the importing user as the author of the test cases and creates them as a contributor to the project after a successful import[1].

The qasphere-csv Go library is also available on GitHub to simplify the creation of CSV files for importing test cases into QA Sphere. This library helps with programmatically creating large projects and facilitates migration from older test management systems by converting exported data into QA Sphere's CSV format[9].

Citations:


Verify custom field header pattern
The current implementation in qascsv.go (lines 306–312) emits headers as:

customFieldHeader := fmt.Sprintf("custom_field_%s_%s", cf.Type, cf.SystemName)
rows[0] = append(rows[0], customFieldHeader)

QA Sphere’s public CSV import docs list only the standard columns and step/expected pairs and don’t explicitly define how custom fields must be named. Please confirm that custom_field_{type}_{systemName} aligns with the importer’s requirements (or adjust to the officially supported naming convention).

  • File: qascsv.go
  • Lines: 306–312

@satvik007 satvik007 merged commit 91795f7 into main Jun 9, 2025
1 check passed
@satvik007 satvik007 deleted the dev/satvik/update-qascsv branch June 9, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants