RocketChat / RocketChat/Rocket.Chat.ReactNative

Add unit-test coverage for app/sagas/

Open
#7,341 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

✅ needs tests type: feature
Dominant language
TypeScript
Stars
2.4k
Forks
1.5k
Avg merge
1d 18h
Merged PRs (30d)
90

Description

Background

app/sagas/ has just two existing tests (videoConf.voipBlock.test.ts, deepLinking.test.ts). Core sagas — login.js, init.js, rooms.js, messages.js, encryption.js, state.js, selectServer.ts, room.js — have no direct unit-test coverage.

Motivating example

NATIVE-1180 / #7333 / #7340: an unconditional cancel(loginSuccessTask) in login.js's root() watcher imposed a hard 2-second deadline on handleLoginSuccess and stranded users on the login screen when permission/enterprise fetches ran long. The bug lived in root()'s cancel logic for ~3 weeks before a user reported it.

A small saga harness asserting that cancel(loginSuccessTask) only fires when SERVER.SELECT_REQUEST wins the race would have failed loudly the moment the regression landed.

Suggested scope

  • Set up a saga test harness under app/sagas/__tests__/ using runSaga or expectSaga from @redux-saga/testing-utils.
  • First pass: cover the root() watcher in login.jsSERVER.SELECT_REQUEST cancels handleLoginSuccess; 2s timeout does not.
  • Subsequent passes: high-traffic sagas (init.js, selectServer.ts, rooms.js).

Non-goals

  • Not aiming for 100% saga coverage. Pick the seams where regressions are most costly (auth, server switch, deep links, rooms sync).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing tests in app/sagas/tests/videoConf.voipBlock.test.ts and deepLinking.test.ts, then inspect app/sagas/login.js and its root() watcher. Set up the suggested runSaga or expectSaga harness and cover the SERVER.SELECT_REQUEST and timeout cases. Done means the root watcher behavior is asserted and the new tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native, typescript
Domain
mobile-dev, testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.