Migrate Conduit from Angular to React (TypeScript + Vite)#38
Draft
milind-cognition wants to merge 9 commits into
Draft
Migrate Conduit from Angular to React (TypeScript + Vite)#38milind-cognition wants to merge 9 commits into
milind-cognition wants to merge 9 commits into
Conversation
…ildren) + test setup
…ntics (mid-session 401 stays on page)
…lobalThis in test mock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the Conduit RealWorld app from Angular 21 to React 18 + TypeScript + Vite, with full behavioral parity. The framework-agnostic Playwright e2e suite in
e2e/(and itsSELECTORS.mdcontract) is the source of truth and passes unchanged — same routes, CSS classes,nameattributes, text labels,localStorage['jwtToken'],/assets/default-avatar.svg, and thewindow.__conduit_debug__interface.No backend changes, no new features, no redesign — a pure framework migration.
What changed
Removed all Angular code/config (
src/app/**,angular.json, Angular tsconfigs,vitest.config.ts, etc.).Added a React app under
src/:src/api/—fetch-based client (client.ts) replacing Angular'sHttpClient+ the api/token/error interceptors: prepends the API base URL, attachesAuthorization: Token <jwt>, normalizes errors to{ errors, status }(with the "Unable to connect" network fallback), triggers global logout on non-/user401s, and accepts any 2xx (200/204) for deletes. Thin resource modules:auth,articles,comments,profiles,tags.src/auth/AuthContext.tsx— React context replacingUserService+ interceptor 401 handling + the app initializer. Implements the 4-state machine (loading/authenticated/unauthenticated/unavailable) with token validation on startup, exponential-backoff retry, and thewindow.__conduit_debug__test hook.src/components/&src/pages/— every component/page ported (Header, Footer, ListErrors, ArticleMeta/Preview/List/Comment, Favorite/Follow buttons; Home, Auth, Article, Editor, Settings, Profile + nested Articles/Favorites). Routing viareact-router-domv6 withRequireAuth/RequireAnonguards.src/utils/—markdown(marked + DOMPurify sanitization, replacingDomSanitizer),image(default avatar),date(longDate),cx(ngClass helper).Tooling: Vite dev server on
:4200(so Playwright'swebServerworks unchanged); theme CSS imported from therealworldsubmodule; media SVGs copied to/assets(unhashed) viavite-plugin-static-copy;public/_redirectsfor SPA fallback. Scripts (start/build/test/test:e2e/format) remain runner-agnostic (npm or bun).Tests: Angular
TestBedspecs replaced with 55 Vitest tests for the API modules, utils, and theAuthProviderstate machine.Docs/CI: README, CLAUDE.md, and the deploy workflow's build path updated for React.
Notable parity decisions (uncovered via runtime testing)
RequireAuthlatches once access is granted, matching Angular's navigation-timecanActivatesemantics: a mid-session 401 (e.g. a form submit) keeps you on the page to see the error rather than reactively bouncing you to/login.Verification
tsc --noEmit: clean.vite build: clean.prettier --check: clean.api.realworld.showbackend): all suites pass —health,navigation,url-navigation,auth,articles,comments,social,settings,null-fields,error-handling,user-fetch-errors, and@securityXSS. A few article-creation-heavy tests are occasionally flaky purely due to the shared demo backend's timing and pass on retry (the suite's existing retry config handles this).Screenshots
To show artifacts inline, enable in settings.
Devin Review