Repository navigation
[Angular 21] PWA, e2e parity suite and CI - #959
Conversation
…ceWorker Co-Authored-By: danial.asaria <danialasaria@gmail.com>
…lar21 Co-Authored-By: danial.asaria <danialasaria@gmail.com>
Co-Authored-By: danial.asaria <danialasaria@gmail.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| provideServiceWorker('ngsw-worker.js', { | ||
| enabled: !isDevMode(), | ||
| registrationStrategy: 'registerWhenStable:30000', | ||
| }), |
There was a problem hiding this comment.
🟡 New contributor absent from credits
After adding the PWA, README.md still omits this PR's contributor from its contributors list. The contribution rule requires an entry for each contributor.
Learn more
The contributor list is separate from the application code. CONTRIBUTING.md asks each contributor to add themselves there, and this PR introduces the PWA and parity suite without changing that list.
Example: A reader checks the README after this PR lands and finds no entry for its contributor, Devin AI.
Recommended fix: Add the contributor's preferred credit to the README contributors section as part of this PR.
Was this helpful? React with 👍 or 👎 to provide feedback.
| if [ ! -d "$LEGACY_DIR" ]; then | ||
| git -C "$REPO_DIR" fetch origin master | ||
| git -C "$REPO_DIR" worktree add --detach "$LEGACY_DIR" origin/master | ||
| fi |
There was a problem hiding this comment.
| const urlPath = decodeURIComponent(new URL(req.url, 'http://localhost').pathname); | ||
| let file = path.join(root, path.normalize(urlPath)); | ||
| if (!file.startsWith(root) || !fs.existsSync(file) || fs.statSync(file).isDirectory()) { | ||
| file = path.extname(urlPath) ? null : path.join(root, 'index.html'); |
There was a problem hiding this comment.
| }; | ||
|
|
||
| http.createServer((req, res) => { | ||
| const urlPath = decodeURIComponent(new URL(req.url, 'http://localhost').pathname); |
There was a problem hiding this comment.
🛡️ API Security Reviewer: Low — Single-request parity server denial of service
A reachable attacker can terminate either parity server with GET /%, because decodeURIComponent throws outside an exception handler. listen(port) binds all interfaces, exposing this crash to other hosts wherever network access permits.
View in Devin Review · Custom reviewer
Was this helpful? React with 👍 or 👎 to provide feedback.
b53f3d8
into
devin/angular21-base
Summary
Restores the PWA on Angular 21, replaces the removed Protractor e2e with a Playwright parity suite that runs the same specs against legacy (Angular 9,
master) and Angular 21, and adds GitHub Actions CI. Part of the 5-session Angular 21 migration. The other sessions are porting feeds, the story page, the user profile and header/footer/settings.PWA
app.config.ts:provideServiceWorker('ngsw-worker.js', { enabled: !isDevMode(), registrationStrategy: 'registerWhenStable:30000' }), with@angular/service-worker@^21.2.angular.jsonproduction config:"serviceWorker": "ngsw-config.json", using the existing config andsrc/manifest.json.ngsw-config.jsonprefetched/manifest.webmanifest, but that file does not exist onmasteror here. It now prefetches/manifest.json, the real manifest. I removed the dead<link rel="manifest" href="manifest.webmanifest">and the#1976d2theme-color meta left behind byng add @angular/pwafromindex.html.pwa.spec.tsproves the production build serves a working worker in both apps: manifest served,ngsw.jsonbuilt from the config,ngsw-worker.jsregistered and controlling the page, and the app shell loading with the network offline.Parity suite (
parity/)package.json, so Playwright does not touch the app's lockfile. Oneplaywright.config.tsdefines two projects:legacyon :4000 andangular21on :4200.scripts/serve-legacy.shcreates a worktree oforigin/masterin.parity-legacy/, runsnvm use 14andng build --prod.scripts/serve-angular21.shrunsnvm use 24andng build. Both serve the build through a dependency-free SPA static server. Playwright starts only the servers for the selected projects and reuses servers that are already running.fixtures/, so both apps render the same data and the specs can assert exact text.PARITY_LIVE=1switches to the live API.CI:
.github/workflows/ci.ymlruns on PRs (and on pushes tomaster/devin/angular21-base). It uses Node from.nvmrc(24) and runsnpm ci, the production build, a check thatngsw-worker.jsandngsw.jsonexist, andnpm test -- --watch=false.Results
legacyserve-legacy.sh; live API: 17 passed, 5 fixture-only skipped)angular21pwa.spec.ts). The other 19 fail because feeds, story, user and header/settings are still placeholders ondevin/angular21-base. This is expected until those PRs merge.ng test)How to run the suite
Useful environment variables:
LEGACY_DIR=/path/to/master-checkoutreuses an existingmastercheckout.PARITY_NO_SERVER=1uses servers you started yourself.PARITY_LIVE=1uses the live API.Details are in
parity/README.md.Needs a decision
node-hnapino longer serves/user/:id. With fixtures, both apps get the same user. In live mode the suite forwards the legacy call toapi.hnpwa.com/v0/user/:id.json, the endpoint the Angular 21 base already uses.masteritself is not changed.1 comment(singular), and the base pipe keeps that. The specs assert legacy behaviour..travis.yml(Node 6.9, Firebase deploy frommaster) is left untouched. Delete it or port it to Actions?angular21parity job makes sense once the feature PRs land.Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/dac47e7b0bbc45db81e29beff9221705
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/dac47e7b0bbc45db81e29beff9221705?variant=devin