Skip to content

fix(store): validate courseProgressStore updates with type guard - #899

Merged
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
Nacho1499:fix/courseProgressStore.ts
Jul 28, 2026
Merged

fix(store): validate courseProgressStore updates with type guard#899
RUKAYAT-CODER merged 4 commits into
rinafcode:mainfrom
Nacho1499:fix/courseProgressStore.ts

Conversation

@Nacho1499

Copy link
Copy Markdown
Contributor

Closes #808

Summary:
Implemented runtime validation and narrowing for lessonData updates in courseProgressStore.ts to prevent incomplete or invalid state transitions:

  • Added isValidLessonProgress type guard to verify required LessonProgress fields (lessonId, completed, lastPosition, timeSpent, completedAt).
  • Created and threw a custom InvalidLessonProgressError whenever incomplete lessonData is supplied before spreading candidate progress into the store.
  • Updated tsconfig.json test exclusion boundaries and added unit tests in courseProgressStore.test.ts covering type guard logic, invalid state rejection, and store state immutability on thrown errors.

Type of Change:
[x] Bug fix (non-breaking change which fixes an issue)

Testing Done:
[x] Unit Tests
[x] Manual Verification (e.g., iOS/Android UI checks)

Security Considerations:
[x] Are all user inputs validated?

Checklist:
[x] I have read the CONTRIBUTING guide.
[x] My code follows the style guidelines of this project.
[x] I have updated the documentation accordingly.

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Nacho1499 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit c0221dc into rinafcode:main Jul 28, 2026
1 of 13 checks passed
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.

[TypeScript] courseProgressStore.ts spreads Partial<LessonProgress> without required field verification

2 participants