[PR #1886] [CLOSED] add unit and E2E integration tests for community progress syncing #33439

Closed
opened 2026-07-13 12:04:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/harvard-edge/cs249r_book/pull/1886
Author: @kai4avaya
Created: 6/17/2026
Status: Closed

Base: devHead: kai/fixing-profile-setting-and-map


📝 Commits (3)

  • ffb92e0 add unit and E2E integration tests for community progress syncing
  • aac11f5 fix: resolve community portal login redirect loop due to missing refresh token
  • 4f94f98 refactor: clean up unused imports and redundant condition flagged by CodeQL

📊 Changes

5 files changed (+366 additions, -9 deletions)

View changed files

📝 tinytorch/quarto/community/modules/auth.js (+4 -4)
📝 tinytorch/quarto/community/modules/guard.js (+2 -2)
📝 tinytorch/tests/cli/README.md (+30 -3)
tinytorch/tests/cli/test_community_flow.py (+146 -0)
tinytorch/tests/cli/test_live_submission.py (+184 -0)

📄 Description

## Summary

This PR adds unit and end-to-end integration tests to verify

the TinyTorch CLI progress syncing flow, resolves a login
redirect loop on the community portal website caused by a
missing refresh token, and resolves subsequent CodeQL code
quality findings.

## Area

- [ ] Book (textbook content, figures, exercises)
- [x] TinyTorch (modules, tests, milestones)
- [ ] StaffML (interview questions, challenges)
- [ ] Kits (hardware labs)
- [x] Infrastructure (CI/CD, scripts, config)

## Changes

### CLI Progress Syncing Tests:
- Added `tests/cli/test_community_flow.py` to validate CLI

configuration parser, payload assembly, and token refresh logic
under offline mocked conditions.
- Added tests/cli/test_live_submission.py to perform E2E
verification including programmatic Supabase login, progress
upload, and verification of profile details persistence.
- Updated tests/cli/README.md to document the new test
suites and explain how developers can configure a local .env
file to run integration tests.

### Website Auth Loop Fix:
- Modified guard.js to restore sessions on page load

using a dummy refresh token fallback ("dummy_refresh_token")
if storedRefresh is missing in local storage.
- Modified auth.js to restore sessions in
verifySession and handleAuth even when the Netlify
authentication proxy fails to return a refresh_token.

### Code Quality (CodeQL) Cleanups:
- Removed unused imports (`os`, `auth`, `patch`) from the new

Python test files.
- Simplified redundant conditional if (!sbSession && token)
to if (!sbSession) in auth.js.

> [!IMPORTANT]
> **REMINDER**: The TinyTorch community site must be

rebuilt/compiled using quarto render to ensure the compiled
assets in quarto/_build/community/modules/ are updated with
these changes.

## Testing

- [x] Rendered the book locally (`quarto render`)
- [x] Ran tests (`pytest tests/`)
- [ ] Ran `tito module test NN` for affected module(s)
- [x] Manual verification (describe below)

### Manual Verification details:
- Verified that CLI unit tests pass successfully offline.
- Started the local server via `./run-community.sh` and

verified the browser login flow at
http://localhost:8000/community/index.html. Logging in using
the test credentials correctly redirected to profile_setup. html and remained authenticated. Successfully completed the
profile update without encountering any loop, landing on
dashboard.html.

## Related Issues
- Related to community site student progress sync issues.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/harvard-edge/cs249r_book/pull/1886 **Author:** [@kai4avaya](https://github.com/kai4avaya) **Created:** 6/17/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `kai/fixing-profile-setting-and-map` --- ### 📝 Commits (3) - [`ffb92e0`](https://github.com/harvard-edge/cs249r_book/commit/ffb92e06664749785be05fea0dab97599f2345cc) add unit and E2E integration tests for community progress syncing - [`aac11f5`](https://github.com/harvard-edge/cs249r_book/commit/aac11f5eefec5d6823e876c5ed64999ff93099e6) fix: resolve community portal login redirect loop due to missing refresh token - [`4f94f98`](https://github.com/harvard-edge/cs249r_book/commit/4f94f98112ec1273186ce8e01f4246641c5d55ca) refactor: clean up unused imports and redundant condition flagged by CodeQL ### 📊 Changes **5 files changed** (+366 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `tinytorch/quarto/community/modules/auth.js` (+4 -4) 📝 `tinytorch/quarto/community/modules/guard.js` (+2 -2) 📝 `tinytorch/tests/cli/README.md` (+30 -3) ➕ `tinytorch/tests/cli/test_community_flow.py` (+146 -0) ➕ `tinytorch/tests/cli/test_live_submission.py` (+184 -0) </details> ### 📄 Description ## Summary This PR adds unit and end-to-end integration tests to verify the TinyTorch CLI progress syncing flow, resolves a login redirect loop on the community portal website caused by a missing refresh token, and resolves subsequent CodeQL code quality findings. ## Area - [ ] Book (textbook content, figures, exercises) - [x] TinyTorch (modules, tests, milestones) - [ ] StaffML (interview questions, challenges) - [ ] Kits (hardware labs) - [x] Infrastructure (CI/CD, scripts, config) ## Changes ### CLI Progress Syncing Tests: - Added `tests/cli/test_community_flow.py` to validate CLI configuration parser, payload assembly, and token refresh logic under offline mocked conditions. - Added `tests/cli/test_live_submission.py` to perform E2E verification including programmatic Supabase login, progress upload, and verification of profile details persistence. - Updated `tests/cli/README.md` to document the new test suites and explain how developers can configure a local `.env` file to run integration tests. ### Website Auth Loop Fix: - Modified guard.js to restore sessions on page load using a dummy refresh token fallback (`"dummy_refresh_token"`) if `storedRefresh` is missing in local storage. - Modified auth.js to restore sessions in `verifySession` and `handleAuth` even when the Netlify authentication proxy fails to return a `refresh_token`. ### Code Quality (CodeQL) Cleanups: - Removed unused imports (`os`, `auth`, `patch`) from the new Python test files. - Simplified redundant conditional `if (!sbSession && token)` to `if (!sbSession)` in `auth.js`. > [!IMPORTANT] > **REMINDER**: The TinyTorch community site must be rebuilt/compiled using `quarto render` to ensure the compiled assets in `quarto/_build/community/modules/` are updated with these changes. ## Testing - [x] Rendered the book locally (`quarto render`) - [x] Ran tests (`pytest tests/`) - [ ] Ran `tito module test NN` for affected module(s) - [x] Manual verification (describe below) ### Manual Verification details: - Verified that CLI unit tests pass successfully offline. - Started the local server via `./run-community.sh` and verified the browser login flow at `http://localhost:8000/community/index.html`. Logging in using the test credentials correctly redirected to `profile_setup. html` and remained authenticated. Successfully completed the profile update without encountering any loop, landing on `dashboard.html`. ## Related Issues - Related to community site student progress sync issues. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-07-13 12:04:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/cs249r_book#33439