Skip to content

Refactor (packages/web/src/components/Share.tsx): Function with many returns - #47

Open
lynseyyyyy wants to merge 2 commits into
CMU-313:mainfrom
lynseyyyyy:refactor-share-status-text
Open

Refactor (packages/web/src/components/Share.tsx): Function with many returns#47
lynseyyyyy wants to merge 2 commits into
CMU-313:mainfrom
lynseyyyyy:refactor-share-status-text

Conversation

@lynseyyyyy

Copy link
Copy Markdown

Issue for this PR

Closes #46

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This PR refactors getStatusText in packages/web/src/components/Share.tsx to replace the switch statement with a status-to-message lookup. The change removes the Qlty "Function with many returns" warning for getStatusText while keeping the existing status messages, error messages, and the fallback behaviour for unknown status.

I also added a separate testing file for unit tests for each status case and configured the web package tests to run through Turbo in CI.

How did you verify your code works?

  1. I created a separate test file named Share.test.ts, which covers all status values, error messages, and the fallback behaviour for unknown status.
  2. I ran 'bun test src/components/Share.test.ts` and the result shows 7 passed, 0 failed.
  3. I ran `bun test --coverage --coverage-dir=./coverage' to verify that the changed getStatusText code is exercised by tests.
  4. I reran Qlty and compared with the baseline results it doesn't show the "Function with many returns" warning for getStatusTextanymore.
  5. I ran the web tests through Turbo CI configuration and the result shows 7 passed, 0 failed.

Screenshots / recordings

Qlty before:
Screenshot 2026-09-04 at 2 34 01 AM

Qlty after:
Qlty After

Tests:
bun tests

Coverage:
coverage

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

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.

P1B: Refactor (packages/web/src/components/Share.tsx:24): Function with many returns (count = 6): getStatusText

1 participant