Skip to content

test: cover the CSV importer file preparation - #42082

Open
ricardogarim wants to merge 1 commit into
developfrom
test/csv-importer-coverage
Open

test: cover the CSV importer file preparation#42082
ricardogarim wants to merge 1 commit into
developfrom
test/csv-importer-coverage

Conversation

@ricardogarim

@ricardogarim ricardogarim commented Sep 9, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

CsvImporter.prepareUsingLocalFile had no direct tests — only an E2E happy path through the UI. This adds 24 server unit tests covering archive processing, parsing, progress reporting and post-import reconciliation, with no production code changed. csv-parse, adm-zip and addParsedContacts run unmocked against real zip files; only Meteor-bound boundaries are stubbed. Assertions were validated by mutation testing (61 single-line mutations of the production file, all detected).

Coverage — apps/meteor/server/lib/import/csv/CsvImporter.ts

Before After
Lines 0% 100.00% (142/142)
Statements 0% 100.00% (144/144)
Functions 0% 100.00% (9/9)
Branches 0% 96.15% (50/52)

Before, the file was never loaded by any unit spec, so it did not appear in the nyc report at all. The 2 uncovered branches are transpiler artifacts. Full mocha suite: 2494 passing, 0 failing (2470 before this PR).

Issue(s)

CORE-2665

Steps to test or reproduce

cd apps/meteor && yarn .testunit:server --grep "CsvImporter"

Further comments

Two pre-existing issues found while testing, neither touched here nor pinned as correct by any assertion: CsvImporter filters __MACOSX but not .DS_Store (unlike SlackImporter), and csv-parse accepts the binary silently, so general/.DS_Store is imported as a message; and messagesCount counts direct-message rows that are later skipped, so count.total can overshoot.

No changeset: tests only, nothing user-facing.

Review in cubic

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for CSV imports, including archive filtering, progress tracking, error handling, and parsing of channels, users, contacts, and messages.
    • Added validation for direct-message room reconciliation and post-import processing, including notifications, import tracking, and user updates.
    • These checks help ensure CSV imports remain reliable across common and edge-case scenarios.

@dionisio-bot

dionisio-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9078d63

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 94df38cf-c408-47ed-b284-7ea1faf6a03e

📥 Commits

Reviewing files that changed from the base of the PR and between 45a2738 and 9078d63.

📒 Files selected for processing (1)
  • apps/meteor/tests/unit/server/lib/import/CsvImporter.spec.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 📦 Meteor Build (coverage)
  • GitHub Check: CodeQL-Build
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/tests/unit/server/lib/import/CsvImporter.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/tests/unit/server/lib/import/CsvImporter.spec.ts

Walkthrough

A new CsvImporter unit test suite stubs importer dependencies and validates archive handling, CSV parsing, message reconciliation, progress behavior, and post-processing outcomes.

Changes

CsvImporter unit test coverage

Layer / File(s) Summary
Test harness and fixtures
apps/meteor/tests/unit/server/lib/import/CsvImporter.spec.ts
Adds dependency stubs, temporary-directory setup, archive helpers, execution helpers, progress assertions, and CSV fixtures.
Archive processing and CSV parsing
apps/meteor/tests/unit/server/lib/import/CsvImporter.spec.ts
Tests archive filtering, progress handling, room identifiers, channel parsing, user and contact records, and channel and direct-message parsing.
Import finalization and reconciliation
apps/meteor/tests/unit/server/lib/import/CsvImporter.spec.ts
Tests settings updates, listener notifications, user import identifiers, direct-message recipient reconciliation, record counts, and empty-import results.

Priority: ⚪ Not assessed

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 9078d

This change adds CSV importer test coverage without changing runtime behavior. No current merge-readiness risk is identified.

Suggested labels: type: chore

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding test coverage for CSV importer file preparation.

Warning

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ricardogarim ricardogarim added this to the 8.9.0 milestone Sep 9, 2026
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.55%. Comparing base (72b183d) to head (9078d63).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #42082      +/-   ##
===========================================
+ Coverage    69.49%   69.55%   +0.05%     
===========================================
  Files         4291     4300       +9     
  Lines       171574   171709     +135     
  Branches     31098    31101       +3     
===========================================
+ Hits        119243   119430     +187     
+ Misses       47154    47079      -75     
- Partials      5177     5200      +23     
Flag Coverage Δ
e2e 59.02% <ø> (+<0.01%) ⬆️
e2e-api 46.28% <ø> (-0.28%) ⬇️
unit 71.24% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ricardogarim
ricardogarim marked this pull request as ready for review September 9, 2026 20:11
@ricardogarim
ricardogarim requested a review from a team as a code owner September 9, 2026 20:11

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant