Skip to content

Upgrade Angular build process and tests#590

Merged
uldisrudzitis merged 7 commits intomasterfrom
enh-upgrade-angular-build-and-tests
Oct 17, 2025
Merged

Upgrade Angular build process and tests#590
uldisrudzitis merged 7 commits intomasterfrom
enh-upgrade-angular-build-and-tests

Conversation

@uldisrudzitis
Copy link
Copy Markdown
Collaborator

@uldisrudzitis uldisrudzitis commented Oct 15, 2025

Summary by CodeRabbit

  • New Features

    • Updated build and serve tooling to the latest Angular build system and added an explicit browser entry for consistent app startup.
  • Chores

    • Switched polyfill handling to the modern runtime, consolidated and tightened TypeScript and Angular compiler configs, and removed legacy test/bootstrap artifacts.
  • Tests

    • Upgraded the test toolchain, removed the old test runner configuration, added a focused unit test scaffold, and enabled Angular tests in CI.
  • Documentation

    • Removed an outdated Angular upgrade log and trimmed related dev commands.

@uldisrudzitis uldisrudzitis self-assigned this Oct 15, 2025
@uldisrudzitis uldisrudzitis added Enhancement dependencies Pull requests that update a dependency file labels Oct 15, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Swap Angular DevKit builders to @angular/build, move tsconfig app/spec to repository root and enable stricter TypeScript/Angular checks, remove src-level polyfills/test bootstrap and Karma config, update package.json test/tooling deps, add a lightweight component unit test and CI job for Angular tests.

Changes

Cohort / File(s) Summary of changes
Builder migration & public config
editor/angular.json
Replace builders from @angular-devkit/* to @angular/build:*; add browser: "src/main.ts"; change build polyfills to ["zone.js"]; update test polyfills to ["zone.js","zone.js/testing"]; update tsConfig paths to top-level tsconfig.*.json; add inlineStyleLanguage: "scss" for tests.
Tooling & test deps
editor/package.json
Remove core-js; replace @angular-devkit/build-angular tooling with @angular/build; upgrade testing deps (jasmine, karma, typings), replace karma-coverage-istanbul-reporter with karma-coverage and adjust reporters.
Polyfills & test bootstrap removal
editor/src/polyfills.ts, editor/src/test.ts
Delete src-level polyfills and the Angular test bootstrap file (removes TestBed init and zone.js/testing import from that path).
Karma config removal
editor/src/karma.conf.js
Remove existing Karma configuration file and its test-run setup.
Src-level tsconfigs removed
editor/src/tsconfig.app.json, editor/src/tsconfig.spec.json
Delete former src-level tsconfig.app.json and tsconfig.spec.json.
New top-level tsconfigs
editor/tsconfig.app.json, editor/tsconfig.spec.json
Add top-level tsconfig.app.json and tsconfig.spec.json extending base tsconfig.json; app config sets outDir and excludes spec files; spec config sets outDir and includes Jasmine types.
Base tsconfig hardening
editor/tsconfig.json
Replace previous lib/typeRoots/outDir entries; set module: "preserve"; enable many strict TS flags and Angular compiler strict options; add empty files and references pointing to app/spec tsconfigs.
Removed update docs
editor/angular.update.log.md
Delete Angular update log/documentation file.
New/updated tests
editor/src/app/app.component.spec.ts
Add lightweight TestAppComponent and unit tests using NO_ERRORS_SCHEMA to assert component creation, presence of <main>, and title property.
CI workflow changes
.github/workflows/tests.yml
Rename CI job, upgrade actions checkout to v4, and add angular-tests job that sets up Node 20, runs npm ci in editor, and executes headless Chrome tests.
Docs tweak
WARP.md
Remove Angular Editor lint/e2e commands and update wording to "Component-based modular architecture with inline templates".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant CLI as npm / ng scripts
  participant Builder as @angular/build
  participant DevServer as Dev Server
  participant TestRunner as Karma/@angular/build:karma
  participant Browser as Browser

  Dev->>CLI: ng serve / npm start
  CLI->>Builder: invoke dev-server builder (browser: src/main.ts, polyfills: zone.js)
  Builder->>DevServer: start serving assets
  DevServer-->>Browser: deliver app

  Dev->>CLI: ng test / npm test
  CLI->>Builder: invoke karma builder (polyfills: zone.js/testing, tsConfig: tsconfig.spec.json)
  Builder->>TestRunner: run tests (Jasmine + karma-coverage)
  TestRunner-->>CLI: return test results
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

I nibble configs in the night,
swapped builders, tightened the light.
Zones now hum, tests take wing,
TS stands stern — I hop and sing.
A rabbit cheers — new builds take flight. 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Upgrade Angular build process and tests" accurately reflects the primary changes in this pull request. The changeset encompasses a comprehensive upgrade of the Angular build system by migrating builders from @Angular-devkit to @angular/build, reorganizing TypeScript configuration files, and upgrading testing libraries (Jasmine, Karma, TypeScript types). The title correctly identifies both major themes—the build process upgrades and test-related changes—without attempting to enumerate every modification, which is appropriate for a title.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enh-upgrade-angular-build-and-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
editor/tsconfig.spec.json (1)

1-8: Limit spec compilation to spec files to reduce build time and noise

Including all source files in tests is unnecessary. Let TypeScript pull app files via imports from specs.

 {
   "extends": "./tsconfig.json",
   "compilerOptions": {
     "outDir": "./out-tsc/spec",
-    "types": ["jasmine"]
+    "types": ["jasmine"]
   },
-  "include": ["src/**/*.ts"]
+  "include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
 }

Optional: add "node" to types if tests use Node globals (e.g., process, Buffer).

editor/angular.json (3)

64-70: Use hidden source maps in production (safer for Sentry uploads)

Avoid serving source maps publicly while keeping them for Sentry.

-              "sourceMap": true,
+              "sourceMap": { "hidden": true },

71-75: Disable optimization in development for faster rebuilds and better debugging

Current dev config has optimization enabled; turn it off.

-            "development": {
-              "optimization": true,
+            "development": {
+              "optimization": false,
               "extractLicenses": false,
               "sourceMap": true
             }

96-103: Add ChromeHeadless to CI test target

Pin Karma to run headless in CI by adding the browsers option:

       "test": {
         "builder": "@angular/build:karma",
         "options": {
           "polyfills": ["zone.js", "zone.js/testing"],
           "tsConfig": "tsconfig.spec.json",
+          "browsers": "ChromeHeadless",
           "inlineStyleLanguage": "scss",
           "assets": ["src/favicon.ico", "src/assets"],
           "styles": ["src/styles/styles.scss"]
         }
       }

No references to polyfills.ts or src/test.ts remain in the codebase.

editor/tsconfig.json (1)

6-18: Consider turning on TS/Angular strictness and bundler resolution (staged)

To catch more issues at build time and align with esbuild:

  • Enable strict and strictTemplates (can be staged per sub-option).
  • Use moduleResolution: "bundler" for modern ESM/package exports.
   "compilerOptions": {
     "baseUrl": "./",
     "sourceMap": true,
-    "strict": false,
-    "noImplicitOverride": false,
-    "noPropertyAccessFromIndexSignature": false,
-    "noImplicitReturns": false,
+    "strict": true,
+    "noImplicitOverride": true,
+    "noPropertyAccessFromIndexSignature": true,
+    "noImplicitReturns": true,
     "noFallthroughCasesInSwitch": true,
     "skipLibCheck": true,
     "isolatedModules": true,
     "experimentalDecorators": true,
     "importHelpers": true,
     "useDefineForClassFields": false,
     "target": "ES2022",
-    "module": "preserve"
+    "module": "preserve",
+    "moduleResolution": "bundler"
   },
   "angularCompilerOptions": {
     "enableI18nLegacyMessageIdFormat": false,
     "strictInjectionParameters": true,
     "strictInputAccessModifiers": true,
     "typeCheckHostBindings": true,
-    "strictTemplates": false
+    "strictTemplates": true
   },

If this is too noisy right now, enable incrementally (e.g., first noImplicitOverride, then strictTemplates).

Also applies to: 19-25

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ae1439 and 59ce337.

⛔ Files ignored due to path filters (1)
  • editor/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (11)
  • editor/angular.json (3 hunks)
  • editor/angular.update.log.md (0 hunks)
  • editor/package.json (1 hunks)
  • editor/src/karma.conf.js (0 hunks)
  • editor/src/polyfills.ts (0 hunks)
  • editor/src/test.ts (0 hunks)
  • editor/src/tsconfig.app.json (0 hunks)
  • editor/src/tsconfig.spec.json (0 hunks)
  • editor/tsconfig.app.json (1 hunks)
  • editor/tsconfig.json (1 hunks)
  • editor/tsconfig.spec.json (1 hunks)
💤 Files with no reviewable changes (6)
  • editor/src/tsconfig.app.json
  • editor/angular.update.log.md
  • editor/src/polyfills.ts
  • editor/src/tsconfig.spec.json
  • editor/src/karma.conf.js
  • editor/src/test.ts
🔇 Additional comments (2)
editor/tsconfig.app.json (1)

1-9: App/spec split looks correct

Includes app sources and excludes specs; empty types avoids Jasmine leakage. LGTM.

editor/package.json (1)

43-61: DevDependencies versions are compatible with Angular 20
All specified versions (TS ~5.8.3, Node 24.x, @angular/*@20.3.x) satisfy official Angular 20 compatibility requirements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
editor/angular.json (2)

49-55: Scripts/CommonJS and polyfills: verify builder compatibility

  • polyfills: ["zone.js"] is correct for apps. Ensure zone.js is present in deps.
  • allowedCommonJsDependencies warnings/behavior differ with @angular/build (esbuild). Verify it’s still honored; if not, expect either no CJS warnings or different suppression.
  • Global scripts from node_modules work, but prefer module imports to avoid globals and improve tree-shaking.

Refactor suggestion (if Twig supports ESM or side-effect import):

-            "scripts": ["./node_modules/twig/twig.min.js"]
+            "scripts": []

Then import once in your app bootstrap (e.g., main.ts or a dedicated module):

// main.ts
import 'twig/twig.min.js';

If Twig lacks ESM, keep the script but drop the leading "./" for consistency:

-            "scripts": ["./node_modules/twig/twig.min.js"]
+            "scripts": ["node_modules/twig/twig.min.js"]

96-103: Karma builder migration: verify defaults and assets/styles inclusion

@angular/build:karma with updated polyfills and tsconfig looks consistent. Since karma.conf.js is removed, ensure defaults (browsers, reporters, coverage) meet CI needs. Including assets/styles under test is atypical; keep only if tests rely on them to render components with global styles/assets.

If not needed:

-            "assets": ["src/favicon.ico", "src/assets"],
-            "styles": ["src/styles/styles.scss"]
+            "assets": [],
+            "styles": []
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd35a2 and a22be87.

📒 Files selected for processing (1)
  • editor/angular.json (3 hunks)
🔇 Additional comments (5)
editor/angular.json (5)

40-47: Double-check outputPath object and path traversal outside workspace

The object form of outputPath is typically used for SSR (browser/server splits). Here, base: "../engine/dist" escapes the workspace root; newer builders may block that. Confirm @angular/build:application accepts:

  • object shape without SSR,
  • and an output directory outside the workspace.

If disallowed, switch to a workspace-internal path and move/copy artifacts in a follow-up step.

-            "outputPath": {
-              "base": "../engine/dist",
-              "browser": ""
-            },
+            "outputPath": "dist/engine",

72-75: Dev options naming parity

Development config uses sourceMap: true. Confirm whether the new builder expects sourcemap. If mismatched, the option may be ignored or fail validation.

If needed:

-              "sourceMap": true
+              "sourcemap": true

79-86: Serve migration looks good

@angular/build:dev-server with buildTarget: "berta:build" is correct for the new builder.


90-94: i18n extraction migration looks good

@angular/build:extract-i18n with buildTarget is aligned with the new tooling.


66-69: Remove legacy namedChunks and adjust sourceMap
@angular/build:application no longer supports the Webpack-era namedChunks option or the { "hidden": true } shape under sourceMap. Replace both with the new sourcemap boolean (e.g., sourcemap: false) or the proper schema for hidden source maps in your Angular CLI version.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 16, 2025

Note

Unit test generation is an Early Access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 16, 2025

Caution

The CodeRabbit agent failed during execution: Stream setup permanently failed: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/tests.yml (1)

12-12: Update checkout action to v4.

Both jobs use actions/checkout@v3, which is outdated. Update to @v4 to ensure compatibility with the current GitHub Actions runner environment.

Apply this diff:

       - name: Checkout
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4

Apply to both occurrences (lines 12 and 33).

Also applies to: 33-33

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a22be87 and c375a74.

📒 Files selected for processing (3)
  • .github/workflows/tests.yml (2 hunks)
  • WARP.md (1 hunks)
  • editor/src/app/app.component.spec.ts (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.8)
.github/workflows/tests.yml

33-33: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 LanguageTool
WARP.md

[grammar] ~51-~51: There might be a mistake here.
Context: ...dular architecture with inline templates - Outputs built files to ../engine/dist/...

(QB_NEW_EN)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Angular Editor Tests
🔇 Additional comments (3)
.github/workflows/tests.yml (1)

27-46: Angular tests job is well-configured.

The new Angular tests job correctly sets up Node.js 20, uses npm caching for improved performance, and runs tests in headless Chrome mode—appropriate for CI environments.

editor/src/app/app.component.spec.ts (2)

4-25: Consider the limitations of testing a substitute component.

While creating a TestAppComponent is pragmatic given NGXS dependencies, this approach means you're not actually testing the real AppComponent behavior, state management, or lifecycle. Consider whether integration tests with mocked NGXS stores or selective unit tests of specific AppComponent methods might provide better coverage in the future.


31-39: Test setup is appropriate.

Using NO_ERRORS_SCHEMA is a reasonable choice here to avoid having to declare or mock all child components (berta-header, berta-preview, etc.), keeping the test focused on the component structure.

Comment thread editor/src/app/app.component.spec.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
editor/src/app/app.component.spec.ts (1)

34-34: Consider using mock components instead of NO_ERRORS_SCHEMA.

NO_ERRORS_SCHEMA suppresses all template errors, which can hide legitimate issues with child components. While it simplifies setup, it reduces test reliability.

If the goal is just to ignore specific child components, consider creating mock components:

@Component({ selector: 'berta-header', template: '' })
class MockHeaderComponent {}

@Component({ selector: 'berta-preview', template: '' })
class MockPreviewComponent {}

@Component({ selector: 'berta-popup', template: '' })
class MockPopupComponent {}

// Then in TestBed:
declarations: [TestAppComponent, MockHeaderComponent, MockPreviewComponent, MockPopupComponent],
// schemas: [NO_ERRORS_SCHEMA], // Remove this

This approach is more explicit and catches typos or missing components.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c375a74 and b742c7a.

📒 Files selected for processing (2)
  • .github/workflows/tests.yml (2 hunks)
  • editor/src/app/app.component.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/tests.yml
🔇 Additional comments (3)
editor/src/app/app.component.spec.ts (3)

1-6: Good documentation of the testing approach.

The comment clearly explains why a simplified test component is used instead of the real AppComponent. The imports are appropriate for the testing approach.


7-25: Consider mocking NGXS dependencies instead of using a test double.

While the test component approach is documented, it means the real AppComponent is never tested. Over time, the TestAppComponent could diverge from the actual implementation, reducing test value.

Can NGXS dependencies be mocked using provideMockStore or similar utilities to test the real AppComponent instead? This would provide more confidence that the actual component works as expected.


41-54: Tests look good; past review feedback has been addressed.

The test naming issue from the previous review has been resolved. The test on line 45 is now appropriately named "should render main template structure" which accurately describes what it verifies.

The three tests provide basic coverage:

  • Component instantiation
  • Template structure rendering
  • Property initialization

Comment thread editor/src/app/app.component.spec.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
editor/src/app/app.component.spec.ts (3)

4-25: Pragmatic approach with room for enhancement.

The comment clearly explains the rationale for using a simplified test component, which is reasonable given NGXS dependency complexity. The TestAppComponent structure mirrors the real component adequately for lightweight testing.

One consideration: the template includes <router-outlet> (line 13) but no router setup is provided. This works only because NO_ERRORS_SCHEMA suppresses the error. If you later want to test routing behavior, you'd need to add RouterTestingModule to the imports.

Consider for future enhancements:

// In TestBed.configureTestingModule
imports: [RouterTestingModule],

31-35: Consider shallow component testing as an alternative to NO_ERRORS_SCHEMA.

The current setup works and is pragmatic for a lightweight test. However, NO_ERRORS_SCHEMA can mask genuine template errors. As an optional improvement, consider using component stubs instead:

// Create stub components
@Component({selector: 'berta-header', template: ''})
class BertaHeaderStub {}

@Component({selector: 'berta-preview', template: ''})
class BertaPreviewStub {}

@Component({selector: 'berta-popup', template: ''})
class BertaPopupStub {}

// Then in TestBed:
await TestBed.configureTestingModule({
  declarations: [TestAppComponent, BertaHeaderStub, BertaPreviewStub, BertaPopupStub],
  imports: [RouterTestingModule],
  // Remove NO_ERRORS_SCHEMA
}).compileComponents();

This approach catches more errors while still keeping tests lightweight. However, given the PR's focus on build infrastructure, the current NO_ERRORS_SCHEMA approach is acceptable.


41-54: Tests are functional and past issues have been addressed.

Good work addressing the previous review comments:

  • ✅ Test name "should render main template structure" now accurately reflects what's being tested
  • ✅ Describe block correctly named "TestAppComponent"

The tests provide basic coverage appropriate for a lightweight test suite. As optional enhancements, you could add more comprehensive template structure verification:

it('should render main template structure', () => {
  fixture.detectChanges();
  const compiled = fixture.nativeElement as HTMLElement;
  expect(compiled.querySelector('main')).toBeTruthy();
  // Optional: verify other key template elements
  expect(compiled.querySelector('berta-header')).toBeTruthy();
  expect(compiled.querySelector('berta-preview')).toBeTruthy();
  expect(compiled.querySelector('berta-popup')).toBeTruthy();
  expect(compiled.querySelector('router-outlet')).toBeTruthy();
});

However, given the PR's focus on upgrading the build process and test infrastructure, the current minimal test coverage is acceptable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b742c7a and 6f05fa6.

📒 Files selected for processing (1)
  • editor/src/app/app.component.spec.ts (1 hunks)
🔇 Additional comments (1)
editor/src/app/app.component.spec.ts (1)

1-2: LGTM!

The imports are appropriate for this lightweight test setup. NO_ERRORS_SCHEMA is imported for pragmatic reasons explained in the file comments.

@uldisrudzitis uldisrudzitis merged commit cdf5f3e into master Oct 17, 2025
5 checks passed
This was referenced Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant