## 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.
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:** 🔄 Open
**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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1886
Author: @kai4avaya
Created: 6/17/2026
Status: 🔄 Open
Base:
dev← Head:kai/fixing-profile-setting-and-map📝 Commits (3)
ffb92e0add unit and E2E integration tests for community progress syncingaac11f5fix: resolve community portal login redirect loop due to missing refresh token4f94f98refactor: 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
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.
configuration parser, payload assembly, and token refresh logic
under offline mocked conditions.
- Added
tests/cli/test_live_submission.pyto perform E2Everification including programmatic Supabase login, progress
upload, and verification of profile details persistence.
- Updated
tests/cli/README.mdto document the new testsuites and explain how developers can configure a local
.envfile to run integration tests.
using a dummy refresh token fallback (
"dummy_refresh_token")if
storedRefreshis missing in local storage.- Modified auth.js to restore sessions in
verifySessionandhandleAutheven when the Netlifyauthentication proxy fails to return a
refresh_token.Python test files.
- Simplified redundant conditional
if (!sbSession && token)to
if (!sbSession)inauth.js.rebuilt/compiled using
quarto renderto ensure the compiledassets in
quarto/_build/community/modules/are updated withthese changes.
verified the browser login flow at
http://localhost:8000/community/index.html. Logging in usingthe test credentials correctly redirected to
profile_setup. htmland remained authenticated. Successfully completed theprofile update without encountering any loop, landing on
dashboard.html.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.