Skip to content

Refactor tests and add integration tests#122

Merged
schiwekM merged 4 commits into
mainfrom
addApp
Apr 10, 2026
Merged

Refactor tests and add integration tests#122
schiwekM merged 4 commits into
mainfrom
addApp

Conversation

@eric-pSAP
Copy link
Copy Markdown
Contributor

Refactor the unit tests to increase readability and complete code coverage. In addition, the bookshop application was added in the test folder along with some initial integration testing. Structure of the package.json was also adjusted to handle the integration testing.

@hyperspace-insights
Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Refactor Unit Tests and Add Bookshop Integration Tests

Refactor

♻️ Refactored the unit test suite for improved readability and code coverage, and introduced a full bookshop sample application under tests/bookshop/ to support integration testing.

Changes

  • package.json: Added @cap-js/cds-test and @cap-js/sqlite as dev dependencies to support integration testing. Reorganized the cds.requires configuration to correctly scope environment-specific notification settings ([development], [hybrid], [production]) under the requires block. Added a workspaces entry pointing to tests/bookshop/.

  • srv/service.js: Removed the legacy OutboxedNotificationService workaround that was previously required when cds.outboxed was unavailable.

  • tests/bookshop/ (new): Added a complete CAP bookshop sample application used as the integration test target. Includes domain model (db/schema.cds), services (srv/admin-service.cds, srv/cat-service.cds), seed data (CSV files), notification types definition, Fiori UI annotations, and app manifests for both browse and admin UIs.

  • tests/integration/bookshop.test.js (new): Added integration tests that boot the bookshop app with the notifications plugin active and verify end-to-end behavior — including service resolution, notification type loading, console logging for default/typed notifications, and warning output for invalid inputs.

  • tests/unit/lib/content-deployment.test.js (new, replaces tests/lib/content-deployment.test.js): Relocated and improved unit tests for contentDeployment, covering log level setup, valid/invalid notification type processing, and missing configuration fallbacks.

  • tests/unit/lib/notificationTypes.test.js (new, replaces tests/lib/notificationTypes.test.js): Expanded and restructured tests for notification type management, covering create, update, delete, and no-change scenarios across a wide variety of inputs.

  • tests/unit/lib/notifications.test.js (new, replaces tests/lib/notifications.test.js): Refactored tests for NotifyToRest.postNotification, including HTTP error status handling with unrecoverable flag assertions.

  • tests/unit/lib/utils.test.js (new, replaces tests/lib/utils.test.js): Significantly expanded coverage for buildNotification, validateNotificationTypes, readFile, getNotificationDestination, and configuration-based behavior (e.g., authenticationIdentifier, $app-name prefix fallback).

  • tests/unit/srv/notifyToRest.test.js (new, replaces tests/srv/notifyToRest.test.js): Refactored tests for NotifyToRest.notify, covering warning messages and correct notification body construction across all call signatures.


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.10 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • File Content Strategy: Full file content
  • Output Template: Default Template
  • Summary Prompt: Default Prompt
  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: 9bb14cb0-33f8-11f1-8810-892dff37599e
  • Event Trigger: pull_request.opened

💌 Have ideas or want to contribute? Create an issue and share your thoughts with us!
📑 Check out the documentation for more information.
📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!

Made with ❤️ by Hyperspace.

Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights Bot left a comment

Choose a reason for hiding this comment

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

The PR introduces a solid test restructure with improved readability and adds a useful bookshop-based integration test suite. However, there are several correctness issues: multiple unit tests in notificationTypes.test.js don't return their promises, meaning assertion failures would be silently swallowed and the tests would always pass; the integration test setup is not properly awaited; error-path assertions in notifications.test.js can be skipped silently without expect.assertions; the route pattern in manifest.json has a syntax error making the AuthorsDetails target unreachable; and the types path in the bookshop's package.json is likely incorrect for the CDS root context used during integration testing.

PR Bot Information

Version: 1.20.10 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: 9bb14cb0-33f8-11f1-8810-892dff37599e
  • Event Trigger: pull_request.opened
  • File Content Strategy: Full file content

Comment thread tests/integration/bookshop.test.js Outdated
Comment thread tests/unit/lib/notifications.test.js
Comment thread tests/unit/lib/notificationTypes.test.js Outdated
Comment thread tests/unit/lib/notificationTypes.test.js
Comment thread tests/unit/lib/notificationTypes.test.js Outdated
Comment thread tests/bookshop/package.json Outdated
Comment thread tests/bookshop/app/admin-books/webapp/manifest.json Outdated
Comment thread tests/bookshop/srv/notification-types.json Outdated
@eric-pSAP eric-pSAP self-assigned this Apr 10, 2026
@schiwekM schiwekM merged commit f5ddaf7 into main Apr 10, 2026
2 checks passed
@schiwekM schiwekM deleted the addApp branch April 10, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants