Skip to content

Conversation

@jirihofman
Copy link
Contributor

@jirihofman jirihofman commented Apr 7, 2025

  • properly trim checklist items input
  • add tests

Before

https://github.com/clientIO/appmixer-connectors/actions/runs/14308045256/job/40096243646

image

After

https://github.com/clientIO/appmixer-connectors/actions/runs/14308058070/job/40096283683

image

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue with the AddChecklistToCard component by trimming unnecessary whitespace in checklist items.
    • Updated error notifications to reflect an increased limit for checklist items from 5 to 10.
  • Tests
    • Added new unit tests to validate the AddChecklistToCard and CreateCard functionalities, ensuring proper error handling and API interactions.
  • Chores
    • Updated the application version to 2.1.5 and refreshed the changelog accordingly.

@jirihofman jirihofman self-assigned this Apr 7, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 7, 2025

Walkthrough

This pull request updates the Trello integration by modifying the application version and changelog in the bundle file, updating error messages in the CreateCard component to reflect a raised checklist item limit from 5 to 10, and adding new test suites. The tests validate the expected behavior of the AddChecklistToCard and CreateCard functionalities, covering scenarios such as whitespace handling in checklist items, error handling for exceeded limits, and ensuring proper API interactions.

Changes

File(s) Change Summary
src/appmixer/trello/bundle.json Updated version from "2.1.4" to "2.1.5" and added a changelog entry for a fix in AddChecklistToCard regarding trimming whitespace from checklist items.
src/appmixer/trello/…/CreateCard.js Modified error messaging to reflect an increased checklist items limit from 5 to 10 while retaining the existing control flow and checking logic.
test/trello/…/AddChecklistToCard.test.js
test/trello/…/createCard.test.js
Introduced new test suites for AddChecklistToCard and CreateCard functionalities using Mocha, Chai, and Sinon to validate API interactions and error handling in various scenarios.

Suggested reviewers

  • vtalas
✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

Copy link
Contributor

@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

🔭 Outside diff range comments (1)
test/trello/checklist/AddChecklistToCard.test.js (1)

1-65: ⚠️ Potential issue

Fix the failing test assertion on line 58.

The test is well structured but there's a pipeline failure at line 58 indicating a missing expected rejection. The test sends checklist items with a leading newline which creates 11 items when split, correctly triggering the error condition. However, the assertion might be failing due to how the error is being checked.

The issue likely relates to how assert.rejects is being used. Try modifying the assertion to explicitly check for the error:

await assert.rejects(
    async () => {
        await action.receive(context);
    },
-   context.CancelError('Maximum 10 checklist items are allowed')
+   error => {
+       return error instanceof context.CancelError &&
+              error.message === 'Maximum 10 checklist items are allowed';
+   }
);
🧰 Tools
🪛 GitHub Actions: Node.js CI

[error] 58-58: AssertionError [ERR_ASSERTION]: Missing expected rejection (Error).

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d0afb91 and df1241e.

📒 Files selected for processing (4)
  • src/appmixer/trello/bundle.json (2 hunks)
  • src/appmixer/trello/list/CreateCard/CreateCard.js (1 hunks)
  • test/trello/checklist/AddChecklistToCard.test.js (1 hunks)
  • test/trello/list/createCard.test.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*/bundle.json`: Every pull request should include changes to the related `bundle.json` file. This file contains version information, so all changes must also include a version ...

**/*/bundle.json: Every pull request should include changes to the related bundle.json file. This file contains version information, so all changes must also include a version update.

  • src/appmixer/trello/bundle.json
🧬 Code Definitions (3)
test/trello/checklist/AddChecklistToCard.test.js (1)
test/trello/list/createCard.test.js (5)
  • assert (1-1)
  • sinon (2-2)
  • testUtils (3-3)
  • action (4-4)
  • context (8-8)
src/appmixer/trello/list/CreateCard/CreateCard.js (3)
test/trello/checklist/AddChecklistToCard.test.js (1)
  • context (8-8)
test/trello/list/createCard.test.js (1)
  • context (8-8)
src/appmixer/trello/checklist/AddChecklistToCard/AddChecklistToCard.js (2)
  • context (9-9)
  • context (13-20)
test/trello/list/createCard.test.js (1)
test/trello/checklist/AddChecklistToCard.test.js (5)
  • assert (1-1)
  • sinon (2-2)
  • testUtils (3-3)
  • action (4-4)
  • context (8-8)
🪛 GitHub Actions: Node.js CI
test/trello/checklist/AddChecklistToCard.test.js

[error] 58-58: AssertionError [ERR_ASSERTION]: Missing expected rejection (Error).

test/trello/list/createCard.test.js

[error] 76-76: AssertionError [ERR_ASSERTION]: Missing expected rejection (Error).


[error] 94-94: AssertionError [ERR_ASSERTION]: Missing expected rejection (Error).

🔇 Additional comments (7)
src/appmixer/trello/bundle.json (2)

3-3: Version incremented properly.

The version update from 2.1.4 to 2.1.5 follows the semantic versioning practice for a patch update, which is appropriate for the type of change being made.


35-36: Changelog entry is concise and descriptive.

The changelog entry clearly describes the issue that was fixed in this version, which helps users understand what changed.

src/appmixer/trello/list/CreateCard/CreateCard.js (1)

76-76: Limit increased from 5 to 10 checklist items.

The error message has been updated to reflect an increased limit of checklist items from 5 to 10. This change is consistent with the actual implementation in line 75 that checks for items.length > 10.

test/trello/checklist/AddChecklistToCard.test.js (2)

29-45: Test properly checks for leading newline handling.

This test correctly verifies that whitespace trimming works properly by including a leading newline in the checklist items. When split by newlines, this would produce 11 items (first empty, plus 10 named items), exceeding the limit of 10.


47-61: Verify API request count for checklist items.

This test correctly verifies that exactly 11 API calls are made when processing 10 checklist items (1 call to create the checklist + 10 calls to add each item).

🧰 Tools
🪛 GitHub Actions: Node.js CI

[error] 58-58: AssertionError [ERR_ASSERTION]: Missing expected rejection (Error).

test/trello/list/createCard.test.js (2)

102-118: Comprehensive test for trimming whitespace in checklist items.

This test properly validates that leading and trailing whitespace in checklist items is trimmed when processing. It uses a variety of whitespace characters including newlines and spaces to ensure robust handling.


66-82:

Details

✅ Verification successful

Validate behavior with leading newlines.

This test is checking for the case where a leading newline in the checklist items would cause the total number of items to exceed the limit. Double-check if the input \na\nb\nc\nd\ne\nf\ng\nh\ni\nj actually produces 11 items when split by \n.


🏁 Script executed:

#!/bin/bash
# Verify item count when splitting with leading newline
node -e "
const items = '\na\nb\nc\nd\ne\nf\ng\nh\ni\nj'.split('\n');
console.log('Number of items:', items.length);
console.log('Items:', items);
"

Length of output: 265


Confirmed: Leading Newline Produces 11 Items

The verification confirms that splitting the input string \na\nb\nc\nd\ne\nf\ng\nh\ni\nj by \n indeed results in 11 items (with the first element being an empty string due to the leading newline). This validates the test case’s expectation that having a leading newline pushes the total count to 11, thereby triggering the error message "Maximum 10 checklist items are allowed."

No changes are required in the test implementation here.

🧰 Tools
🪛 GitHub Actions: Node.js CI

[error] 76-76: AssertionError [ERR_ASSERTION]: Missing expected rejection (Error).

Copy link
Contributor

@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 (1)
test/trello/list/createCard.test.js (1)

40-45: ⚠️ Potential issue

Fix the failing test assertions.

The current use of assert.rejects is problematic and causing the tests to fail. The pipeline shows errors at lines 77 and 94.

Modify all assertions to explicitly check for the error type and message:

await assert.rejects(
    async () => {
        await action.receive(context);
    },
-   context.CancelError('Maximum 10 checklist items are allowed')
+   error => {
+       return error instanceof context.CancelError &&
+              error.message === 'Maximum 10 checklist items are allowed';
+   }
);

Make this same change for all assert.rejects calls in the file (lines 40-45, 51-56, 59-64, 77-82, and 92-97).

Also applies to: 51-56, 59-64, 77-82, 92-97

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between df1241e and 5f5b91c.

📒 Files selected for processing (2)
  • src/appmixer/trello/checklist/AddChecklistToCard/AddChecklistToCard.js (1 hunks)
  • test/trello/list/createCard.test.js (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
src/appmixer/trello/checklist/AddChecklistToCard/AddChecklistToCard.js (1)
src/appmixer/trello/list/CreateCard/CreateCard.js (2)
  • items (73-73)
  • checklistItems (35-35)
test/trello/list/createCard.test.js (1)
test/trello/checklist/AddChecklistToCard.test.js (5)
  • assert (1-1)
  • sinon (2-2)
  • testUtils (3-3)
  • action (4-4)
  • context (8-8)
🔇 Additional comments (3)
src/appmixer/trello/checklist/AddChecklistToCard/AddChecklistToCard.js (1)

24-24: Good improvement to checklist item handling.

Adding trim() before splitting ensures that leading and trailing whitespace is properly removed from the input string, preventing empty items from being counted toward the limit. This aligns with the individual item trimming that was already happening on line 37.

test/trello/list/createCard.test.js (2)

100-116: Well-implemented test for trimming functionality.

This test effectively validates that the trimming functionality correctly handles checklist items with leading and trailing whitespace. It confirms that exactly 10 items are created when the limit is met, even when the input contains extra whitespace.


108-108: Good test coverage for whitespace handling.

The test input correctly simulates a user entering checklist items with leading and trailing whitespace and newlines, which is precisely the scenario that the trim functionality in AddChecklistToCard is designed to handle.

@jirihofman jirihofman requested a review from sayam-nasir April 7, 2025 11:36
Copy link
Contributor

@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

♻️ Duplicate comments (1)
test/trello/list/createCard.test.js (1)

77-82: ⚠️ Potential issue

Fix the failing test assertion as highlighted in pipeline errors.

This assertion is failing in the CI pipeline. The correct way to use assert.rejects is to provide a function that checks both error type and message.

await assert.rejects(
    async () => {
        await action.receive(context);
    },
-   context.CancelError('Maximum 10 checklist items are allowed')
+   error => {
+       return error instanceof context.CancelError &&
+              error.message === 'Maximum 10 checklist items are allowed';
+   }
);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f5b91c and efce946.

📒 Files selected for processing (1)
  • test/trello/list/createCard.test.js (1 hunks)
🔇 Additional comments (1)
test/trello/list/createCard.test.js (1)

85-101: Good test for checklist item trimming functionality.

This test effectively validates that checklist items with leading and trailing whitespace are properly handled. The test checks that with 10 valid items (after trimming), exactly 12 API requests are made (1 for card creation, 1 for checklist creation, and 10 for the items).

Comment on lines +59 to +64
await assert.rejects(
async () => {
await action.receive(context);
},
context.CancelError('Card name is required')
);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix the assertion usage for missing card name test.

Update the assertion to check both error type and message for consistency.

await assert.rejects(
    async () => {
        await action.receive(context);
    },
-   context.CancelError('Card name is required')
+   error => {
+       return error instanceof context.CancelError &&
+              error.message === 'Card name is required';
+   }
);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await assert.rejects(
async () => {
await action.receive(context);
},
context.CancelError('Card name is required')
);
await assert.rejects(
async () => {
await action.receive(context);
},
error => {
return error instanceof context.CancelError &&
error.message === 'Card name is required';
}
);

Comment on lines +51 to +56
await assert.rejects(
async () => {
await action.receive(context);
},
context.CancelError('Card name is required')
);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix the assertion usage for empty card name test.

Similar to the previous issue, update the assertion to properly check both error type and message.

await assert.rejects(
    async () => {
        await action.receive(context);
    },
-   context.CancelError('Card name is required')
+   error => {
+       return error instanceof context.CancelError &&
+              error.message === 'Card name is required';
+   }
);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await assert.rejects(
async () => {
await action.receive(context);
},
context.CancelError('Card name is required')
);
await assert.rejects(
async () => {
await action.receive(context);
},
error => {
return error instanceof context.CancelError &&
error.message === 'Card name is required';
}
);

Comment on lines +40 to +45
await assert.rejects(
async () => {
await action.receive(context);
},
context.CancelError('Checklist name is required to add checklist items')
);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix the assertion usage for better error validation.

The current usage of assert.rejects with a direct error object doesn't properly validate both the error type and message. This can lead to false positives in tests.

await assert.rejects(
    async () => {
        await action.receive(context);
    },
-   context.CancelError('Checklist name is required to add checklist items')
+   error => {
+       return error instanceof context.CancelError &&
+              error.message === 'Checklist name is required to add checklist items';
+   }
);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await assert.rejects(
async () => {
await action.receive(context);
},
context.CancelError('Checklist name is required to add checklist items')
);
await assert.rejects(
async () => {
await action.receive(context);
},
error => {
return error instanceof context.CancelError &&
error.message === 'Checklist name is required to add checklist items';
}
);

@sayam-nasir sayam-nasir merged commit 8cd038f into Appmixer-ai:dev Apr 7, 2025
2 checks passed
@jirihofman jirihofman deleted the trello-10-11 branch April 7, 2025 15:03
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.

2 participants