Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sbom upselling UI #1538

Merged
merged 1 commit into from
Mar 12, 2025
Merged

sbom upselling UI #1538

merged 1 commit into from
Mar 12, 2025

Conversation

avzz-19
Copy link
Contributor

@avzz-19 avzz-19 commented Feb 26, 2025

No description provided.

Copy link

coderabbitai bot commented Feb 26, 2025

Walkthrough

This pull request refines SBOM-related functionality across various components. The changes simplify the SBOM dashboard logic by removing unnecessary feature checks and incorporate persistent state management via local storage for support interactions. Additionally, new upselling components and associated styling are introduced to promote the SBOM feature. Routing and conditional rendering have been updated in the dashboard to reflect the SBOM enablement, and new translation entries have been added to support both English and Japanese locales.

Changes

File(s) Change Summary
app/components/appknox-wrapper/index.ts Modified SBOM logic: simplified getter in Appknox component.
app/components/file/report-drawer/sbom-reports/sample/index.ts Added local storage state management for tracking support contact.
app/routes/authenticated/dashboard/sbom.ts Updated routing: added model method for isSbomEnabled.
app/templates/authenticated/dashboard/sbom.hbs Introduced conditional rendering to display either the outlet or the upselling component.
app/components/sbom/upselling/index.{hbs,ts}
app/components/upselling-module/index.{hbs,ts,scss}
Introduced new upselling components for SBOM with corresponding templates, TypeScript classes, and SCSS styles, including support contact actions and feature displays.
app/styles/_component-variables.scss
app/styles/_theme.scss
app/styles/_icons.scss
Added new CSS variables, custom properties, and an icon class to support upselling module design and theming.
translations/en.json
translations/ja.json
Added SBOM-related translation entries covering feature introduction, overview, detailed features, and support contact messages.
tests/integration/components/appknox-wrapper-test.js Updated tests to ensure consistent rendering of the sbom feature in component menu items.
tests/integration/components/file/report-drawer/sbom-reports/index-test.js
tests/integration/components/file/report-drawer/sbom-reports/sample-test.js
tests/integration/components/sbom/upselling-test.js
Introduced new integration tests for SBOM components, ensuring proper rendering and local storage interactions.

Poem

I'm a rabbit hopping with glee,
Through code meadows, wild and free.
New upsells bloom like springtime flowers,
With streamlined logic to empower.
Bugs hide away in burrows small 🐰,
Celebrating changes, one and all!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @storybook/[email protected]
npm error Found: [email protected]
npm error node_modules/ember-source
npm error dev ember-source@"~5.12.0" from the root project
npm error peer ember-source@"3.28.12 || ^4.0.4 || ^5.0.0 || ^6.0.0" from @ember-data/[email protected]
npm error node_modules/@ember-data/adapter
npm error @ember-data/adapter@"5.3.11" from [email protected]
npm error node_modules/ember-data
npm error dev ember-data@"~5.3.8" from the root project
npm error 3 more (ember-changeset, ember-cli-mirage, ember-data-resources)
npm error 33 more (@ember-data/debug, @ember-data/graph, ...)
npm error
npm error Could not resolve dependency:
npm error peer ember-source@"~3.28.1 || ^4.0.0" from @storybook/[email protected]
npm error node_modules/@storybook/ember
npm error dev @storybook/ember@"8.4.6" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/ember-source
npm error peer ember-source@"~3.28.1 || ^4.0.0" from @storybook/[email protected]
npm error node_modules/@storybook/ember
npm error dev @storybook/ember@"8.4.6" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /.npm/_logs/2025-03-12T11_18_26_692Z-eresolve-report.txt
npm error A complete log of this run can be found in: /.npm/_logs/2025-03-12T11_18_26_692Z-debug-0.log

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@avzz-19 avzz-19 marked this pull request as draft February 26, 2025 14:54
Copy link

cloudflare-workers-and-pages bot commented Feb 26, 2025

Deploying irenestaging with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90be5d3
Status: ✅  Deploy successful!
Preview URL: https://ef685429.irenestaging.pages.dev
Branch Preview URL: https://pd-1717-sbom-upselling-ui.irenestaging.pages.dev

View logs

coderabbitai[bot]

This comment was marked as outdated.

Copy link

cypress bot commented Feb 26, 2025

Irene    Run #611

Run Properties:  status check passed Passed #611  •  git commit 9324d69ef4 ℹ️: Merge a2e8aba87d3fafcaf82dc185cefca2898fafe10a into 351b48ecb107efe9bbe06c98660d...
Project Irene
Branch Review PD-1717-sbom-upselling-ui
Run status status check passed Passed #611
Run duration 11m 20s
Commit git commit 9324d69ef4 ℹ️: Merge a2e8aba87d3fafcaf82dc185cefca2898fafe10a into 351b48ecb107efe9bbe06c98660d...
Committer Avi Shah
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 32
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Copy link

@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 (4)
app/components/sbom/upselling/index.ts (4)

20-20: Externalize the endpoint.

Storing the endpoint in a config file or environment variable could improve maintainability and facilitate environment-specific overrides (e.g., dev/staging/production).

- CONTACT_SUPPORT_ENDPOINT = 'v2/feature_request/sbom';
+ CONTACT_SUPPORT_ENDPOINT = config.API_BASE_URL + '/feature_request/sbom';

22-28: Handle localStorage unavailability gracefully.

Accessing localStorage might fail in private browsing or SSR contexts. Consider a defensive check or try/catch to ensure robust error handling in such cases.


30-37: Avoid hard-coding feature strings in code.

Defining these feature descriptions as a higher-level constant or storing them in a separate config or translation file would increase maintainability and clarity.


39-43: Prevent multiple submission attempts.

When the user clicks the contact CTA, consider disabling the button or showing a loading indicator until the task finishes. This prevents duplicate requests while the task is ongoing.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abf7043 and a2e8aba.

⛔ Files ignored due to path filters (1)
  • public/images/sbom-upselling.png is excluded by !**/*.png
📒 Files selected for processing (18)
  • app/components/appknox-wrapper/index.ts (1 hunks)
  • app/components/file/report-drawer/sbom-reports/sample/index.ts (2 hunks)
  • app/components/sbom/upselling/index.hbs (1 hunks)
  • app/components/sbom/upselling/index.ts (1 hunks)
  • app/components/upselling-module/index.hbs (1 hunks)
  • app/components/upselling-module/index.scss (1 hunks)
  • app/components/upselling-module/index.ts (1 hunks)
  • app/routes/authenticated/dashboard/sbom.ts (1 hunks)
  • app/styles/_component-variables.scss (1 hunks)
  • app/styles/_icons.scss (1 hunks)
  • app/styles/_theme.scss (1 hunks)
  • app/templates/authenticated/dashboard/sbom.hbs (1 hunks)
  • tests/integration/components/appknox-wrapper-test.js (2 hunks)
  • tests/integration/components/file/report-drawer/sbom-reports/index-test.js (2 hunks)
  • tests/integration/components/file/report-drawer/sbom-reports/sample-test.js (3 hunks)
  • tests/integration/components/sbom/upselling-test.js (1 hunks)
  • translations/en.json (1 hunks)
  • translations/ja.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (12)
  • app/components/upselling-module/index.hbs
  • app/templates/authenticated/dashboard/sbom.hbs
  • app/components/upselling-module/index.ts
  • app/components/sbom/upselling/index.hbs
  • app/styles/_theme.scss
  • app/components/appknox-wrapper/index.ts
  • app/styles/_icons.scss
  • app/components/file/report-drawer/sbom-reports/sample/index.ts
  • translations/en.json
  • translations/ja.json
  • app/components/upselling-module/index.scss
  • app/styles/_component-variables.scss
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Run E2E Tests (5)
  • GitHub Check: Run E2E Tests (4)
  • GitHub Check: Run E2E Tests (3)
  • GitHub Check: Run E2E Tests (2)
  • GitHub Check: Run E2E Tests (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (13)
tests/integration/components/appknox-wrapper-test.js (2)

281-283: Explicit configuration setup looks good!

Adding the configuration service lookup and explicitly setting enterprise to false makes the test setup more clear and better reflects the component's behavior, where SBOM visibility now depends on the enterprise property.


318-318: Hardcoded SBOM flag correctly matches component behavior.

Changing from a dynamic value (sectionConfig.sbom) to a hardcoded true aligns with the updated component logic where SBOM visibility is now determined solely by the enterprise flag rather than a feature configuration.

tests/integration/components/file/report-drawer/sbom-reports/index-test.js (1)

9-9: Good browser service setup for testing component interactions.

The addition of setupBrowserFakes with window and localStorage parameters is a good practice for testing components that interact with browser APIs. Clearing localStorage before each test ensures test isolation.

Also applies to: 26-26, 33-35

app/routes/authenticated/dashboard/sbom.ts (1)

10-14: Well-designed pattern change for upselling flow.

This is a good architectural change from redirecting users without the SBOM feature to conditionally rendering content based on feature availability. The model now provides the isSbomEnabled flag which can be used by the template to conditionally render either the feature or an upselling component.

tests/integration/components/file/report-drawer/sbom-reports/sample-test.js (3)

22-36: Clean localStorage implementation for testing.

Well-designed implementation of the localStorage interface using a Map for storing data during tests. This approach provides good isolation between tests and mimics the actual localStorage API.


72-82: Good test setup for the contact support feature.

Proper setup of the server mock for the feature request endpoint and clearing localStorage before each test to ensure a clean state.


128-131: Good persistence verification.

This assertion correctly verifies that the user's interest in SBOM is persisted to localStorage when they contact support.

tests/integration/components/sbom/upselling-test.js (3)

9-23: Well-structured test module setup.

The test module is properly configured with the necessary test helpers and hooks. Good practice to clear localStorage before each test to ensure isolation.


24-65: Comprehensive UI rendering test.

The test thoroughly verifies all UI elements of the upselling component, including the title, subtitle, features list, and call-to-action button. The assertions against translation keys ensure proper internationalization.


67-89: Complete interaction flow testing.

This test effectively verifies both the user interaction (clicking the CTA button) and its side effects (localStorage persistence and UI changes). The success path is fully covered.

app/components/sbom/upselling/index.ts (3)

1-10: All import statements look good.

No issues or redundancies are apparent. Everything is correctly imported and typed, including the concurrency and internationalization services.


13-16: Consider consistency and potential SSR usage.

Declaring multiple services, including window, works for client-side. If server-side rendering (SSR) is ever introduced, confirm that these services are guarded or stubbed to avoid undefined references to localStorage.


57-61: Registry declaration looks correct.

The Glint registry entry is properly declared, enabling correct component usage in TypeScript-aware Ember setups.

Copy link

@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 (1)
app/components/sbom/upselling/index.ts (1)

20-20: Consider externalizing the endpoint configuration.
Storing the CONTACT_SUPPORT_ENDPOINT in an environment-specific configuration or constants module helps ensure maintainability and flexibility, especially if the endpoint changes or needs to differ across environments.

- CONTACT_SUPPORT_ENDPOINT = 'v2/feature_request/sbom';
+ // For example, refer to an environment config or constants file
+ CONTACT_SUPPORT_ENDPOINT = ENV.APP.FEATURE_REQUEST_ENDPOINT || 'v2/feature_request/sbom';
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39d7ad7 and d35fe5f.

📒 Files selected for processing (8)
  • app/components/appknox-wrapper/index.ts (1 hunks)
  • app/components/file/report-drawer/sbom-reports/sample/index.ts (2 hunks)
  • app/components/sbom/upselling/index.hbs (1 hunks)
  • app/components/sbom/upselling/index.ts (1 hunks)
  • app/components/upselling-module/index.hbs (1 hunks)
  • app/components/upselling-module/index.scss (1 hunks)
  • app/components/upselling-module/index.ts (1 hunks)
  • app/routes/authenticated/dashboard/sbom.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • app/components/appknox-wrapper/index.ts
  • app/components/file/report-drawer/sbom-reports/sample/index.ts
  • app/components/upselling-module/index.hbs
  • app/routes/authenticated/dashboard/sbom.ts
  • app/components/sbom/upselling/index.hbs
  • app/components/upselling-module/index.scss
  • app/components/upselling-module/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish to Cloudflare Pages
  • GitHub Check: Setup & Build Application
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
app/components/sbom/upselling/index.ts (3)

1-6: All good here.
No issues found in the import statements.


44-54: Display a success notification to assure the user.
Currently, you only display an error notification when the request fails. Displaying a success message helps users understand that their request was processed.

try {
  await waitForPromise(this.ajax.post(this.CONTACT_SUPPORT_ENDPOINT));

  this.window.localStorage.setItem('sbomRequest', 'true');
  this.hasContactedSupport = true;
+ this.notify.success(
+   this.intl.t('sbomModule.contactSupportSuccess')
+ );
} catch (err) {
  this.notify.error(parseError(err, this.intl.t('pleaseTryAgain')));
}

57-61: No issues with Glint registry declaration.
This ensures that the component is recognized by Glint’s type system.

Copy link

@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 (1)
translations/ja.json (1)

1290-1298: Ensure language consistency.
These new SBOM-related translations are presented in English under the Japanese locale file. Double-check if you intend to keep them in English or if you plan to localize them to Japanese for consistency across the application.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d35fe5f and 1b2d197.

⛔ Files ignored due to path filters (1)
  • public/images/sbom-upselling.png is excluded by !**/*.png
📒 Files selected for processing (18)
  • app/components/appknox-wrapper/index.ts (1 hunks)
  • app/components/file/report-drawer/sbom-reports/sample/index.ts (2 hunks)
  • app/components/sbom/upselling/index.hbs (1 hunks)
  • app/components/sbom/upselling/index.ts (1 hunks)
  • app/components/upselling-module/index.hbs (1 hunks)
  • app/components/upselling-module/index.scss (1 hunks)
  • app/components/upselling-module/index.ts (1 hunks)
  • app/routes/authenticated/dashboard/sbom.ts (1 hunks)
  • app/styles/_component-variables.scss (1 hunks)
  • app/styles/_icons.scss (1 hunks)
  • app/styles/_theme.scss (1 hunks)
  • app/templates/authenticated/dashboard/sbom.hbs (1 hunks)
  • tests/integration/components/appknox-wrapper-test.js (2 hunks)
  • tests/integration/components/file/report-drawer/sbom-reports/index-test.js (2 hunks)
  • tests/integration/components/file/report-drawer/sbom-reports/sample-test.js (3 hunks)
  • tests/integration/components/sbom/upselling-test.js (1 hunks)
  • translations/en.json (1 hunks)
  • translations/ja.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (14)
  • app/styles/_icons.scss
  • app/templates/authenticated/dashboard/sbom.hbs
  • app/components/appknox-wrapper/index.ts
  • tests/integration/components/file/report-drawer/sbom-reports/index-test.js
  • app/components/file/report-drawer/sbom-reports/sample/index.ts
  • app/styles/_theme.scss
  • app/components/upselling-module/index.hbs
  • app/components/upselling-module/index.scss
  • app/components/sbom/upselling/index.hbs
  • tests/integration/components/appknox-wrapper-test.js
  • app/styles/_component-variables.scss
  • app/components/upselling-module/index.ts
  • app/routes/authenticated/dashboard/sbom.ts
  • tests/integration/components/file/report-drawer/sbom-reports/sample-test.js
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: Run Integration Tests - Part 8
  • GitHub Check: Run Integration Tests - Part 7
  • GitHub Check: Run Integration Tests - Part 6
  • GitHub Check: Run Integration Tests - Part 5
  • GitHub Check: Run Integration Tests - Part 4
  • GitHub Check: Run Integration Tests - Part 3
  • GitHub Check: Run Integration Tests - Part 2
  • GitHub Check: Run Integration Tests - Part 1
  • GitHub Check: Run Acceptance Tests
  • GitHub Check: Run Unit Tests
  • GitHub Check: Run Linting
  • GitHub Check: Publish to Cloudflare Pages
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (13)
translations/en.json (1)

1290-1298: Well-structured translations for SBOM upselling feature!

The new translation keys for the SBOM upselling module are clear and descriptive. The feature descriptions provide good value propositions for end users.

tests/integration/components/sbom/upselling-test.js (4)

1-8: Good test setup with comprehensive imports

The imports cover all the necessary testing utilities for Ember, including internationalization support, Mirage for HTTP mocking, and browser fakes for localStorage testing.


9-23: Proper test module setup with appropriate hooks

The module setup includes all necessary hooks for rendering, internationalization, Mirage, and browser fakes. The beforeEach hook correctly clears localStorage before each test to ensure test isolation.


24-65: Comprehensive rendering test with detailed assertions

The first test thoroughly verifies that all elements of the upselling component render correctly, including images, title, subtitle, features, and CTA. Each assertion has a clear purpose and checks against expected translations.


67-89: Well-implemented user interaction test

This test effectively verifies the component's behavior when a user expresses interest in SBOM:

  1. Properly mocks the server response
  2. Verifies the UI change after clicking the CTA
  3. Checks localStorage is updated
  4. Confirms the success message appears

This ensures the feature's core functionality works correctly.

app/components/sbom/upselling/index.ts (8)

1-7: Imports look good.
No issues found in these import statements.


9-11: No concerns with these utility imports.
They appear correctly referenced and maintain clear code organization.


12-21: Confirm endpoint configuration.
Make sure the 'v2/feature_request/sbom' path is correct and matches your backend’s expected route structure (leading slash vs. relative path, etc.).


22-29: Local storage usage is acceptable.
Initialization logic is straightforward. Just take note that localStorage might be unavailable in certain SSR or testing contexts.


30-37: Feature list generation looks correct.
Using the intl service for translations is standard; the property is neatly returning the array for display.


39-43: CTA action is handled appropriately.
This action is concise and clean, simply invoking the task.


44-55: Consider displaying a success notification.
Currently, the code only shows errors to the user. Providing a success toast or message can help confirm that the request was received.


57-61: Glint environment declaration is properly structured.
No issues found in this registry module extension.

@future-pirate-king future-pirate-king force-pushed the PD-1717-sbom-upselling-ui branch from 1b2d197 to 90be5d3 Compare March 12, 2025 11:16
Copy link

@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)
translations/en.json (1)

1290-1297: New SBOM Translation Keys Added
The new keys—introducingSBOM, sbomOverview, and the nested keys under sbomFeatures (i.e. oneClickAnalysis, identifyDependencies, uncoverVulnerabilities, and componentInsights)—are clear and descriptive. They effectively communicate the value of the SBOM feature to end users. Please ensure that:

  • These keys are consistently referenced in the SBOM upselling UI.
  • Equivalent translations for these keys are provided in other locale files (especially Japanese) to maintain localization consistency.
tests/integration/components/sbom/upselling-test.js (2)

67-89: Add error case testing for more robust coverage

The interaction test successfully verifies the happy path (successful API call), but doesn't test error scenarios. Consider adding a test case for when the server request fails.

test('it handles server errors gracefully', async function (assert) {
  this.server.post('/v2/feature_request/sbom', () => {
    return new Response(500, {}, { error: 'Server error' });
  });

  await render(hbs`<Sbom::Upselling />`);
  await click('[data-test-upselling-module-contact-cta]');
  
  // Verify error handling behavior
  assert.dom('[data-test-error-message]').exists();
  assert.dom('[data-test-upselling-module-contact-cta]').exists();
}); 

43-61: Consider simplifying feature text assertions

The current approach to testing feature text is verbose. Consider using a loop with an array of expected translation keys for a more maintainable test.

-    const featureElements = document.querySelectorAll(
-      '[data-test-upselling-module-feature]'
-    );
-
-    assert
-      .dom(featureElements[0])
-      .hasText(t('sbomModule.sbomFeatures.oneClickAnalysis'));
-
-    assert
-      .dom(featureElements[1])
-      .hasText(t('sbomModule.sbomFeatures.identifyDependencies'));
-
-    assert
-      .dom(featureElements[2])
-      .hasText(t('sbomModule.sbomFeatures.uncoverVulnerabilities'));
-
-    assert
-      .dom(featureElements[3])
-      .hasText(t('sbomModule.sbomFeatures.componentInsights'));
+    const featureKeys = [
+      'sbomModule.sbomFeatures.oneClickAnalysis',
+      'sbomModule.sbomFeatures.identifyDependencies',
+      'sbomModule.sbomFeatures.uncoverVulnerabilities',
+      'sbomModule.sbomFeatures.componentInsights'
+    ];
+
+    const featureElements = document.querySelectorAll('[data-test-upselling-module-feature]');
+    featureKeys.forEach((key, index) => {
+      assert.dom(featureElements[index]).hasText(t(key));
+    });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b2d197 and 90be5d3.

⛔ Files ignored due to path filters (1)
  • public/images/sbom-upselling.png is excluded by !**/*.png
📒 Files selected for processing (18)
  • app/components/appknox-wrapper/index.ts (1 hunks)
  • app/components/file/report-drawer/sbom-reports/sample/index.ts (2 hunks)
  • app/components/sbom/upselling/index.hbs (1 hunks)
  • app/components/sbom/upselling/index.ts (1 hunks)
  • app/components/upselling-module/index.hbs (1 hunks)
  • app/components/upselling-module/index.scss (1 hunks)
  • app/components/upselling-module/index.ts (1 hunks)
  • app/routes/authenticated/dashboard/sbom.ts (1 hunks)
  • app/styles/_component-variables.scss (1 hunks)
  • app/styles/_icons.scss (1 hunks)
  • app/styles/_theme.scss (1 hunks)
  • app/templates/authenticated/dashboard/sbom.hbs (1 hunks)
  • tests/integration/components/appknox-wrapper-test.js (2 hunks)
  • tests/integration/components/file/report-drawer/sbom-reports/index-test.js (2 hunks)
  • tests/integration/components/file/report-drawer/sbom-reports/sample-test.js (3 hunks)
  • tests/integration/components/sbom/upselling-test.js (1 hunks)
  • translations/en.json (1 hunks)
  • translations/ja.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (15)
  • app/templates/authenticated/dashboard/sbom.hbs
  • app/styles/_icons.scss
  • tests/integration/components/file/report-drawer/sbom-reports/index-test.js
  • app/styles/_theme.scss
  • app/components/upselling-module/index.hbs
  • app/components/appknox-wrapper/index.ts
  • app/components/upselling-module/index.ts
  • app/routes/authenticated/dashboard/sbom.ts
  • app/components/file/report-drawer/sbom-reports/sample/index.ts
  • app/components/upselling-module/index.scss
  • app/components/sbom/upselling/index.hbs
  • app/styles/_component-variables.scss
  • tests/integration/components/file/report-drawer/sbom-reports/sample-test.js
  • app/components/sbom/upselling/index.ts
  • translations/ja.json
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Publish to Cloudflare Pages
  • GitHub Check: Setup & Build Application
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
tests/integration/components/appknox-wrapper-test.js (2)

355-357: Configuration service now explicitly defined for enterprise flag control

This change adds explicit configuration of the enterprise flag which controls SBOM visibility. Setting enterprise to false in the test configuration aligns with the simplification of SBOM dashboard logic mentioned in the PR summary.


392-392: SBOM menu item now always visible for non-enterprise users

The SBOM menu item visibility is now hardcoded to true rather than being dependent on sectionConfig.sbom. This change aligns with the updated architecture where SBOM visibility is now controlled solely by the enterprise flag instead of through feature flags.

tests/integration/components/sbom/upselling-test.js (4)

1-8: LGTM on the imports!

All necessary imports for testing the component are properly included, with appropriate libraries for rendering, internationalization, Mirage for API mocking, and browser service testing.


9-23: Good setup of test environment

The test module correctly sets up all required hooks for rendering, internationalization, Mirage, and browser fakes. The beforeEach hook properly clears localStorage to prevent test data leakage.


24-65: Well-structured rendering test with comprehensive assertions

The test thoroughly verifies all aspects of the component's rendering:

  • Presence of the upselling module
  • Correct translations for titles and subtitles
  • All four features with proper text content
  • Initial state of UI elements (CTA exists, success message doesn't)

The use of data-test attributes for DOM selection is a good practice.


76-89: Good job on verifying localStorage interaction

The test effectively checks that user interaction updates localStorage and changes the UI accordingly. This is important for persistence of user preferences across page loads.

@future-pirate-king future-pirate-king merged commit bb43022 into develop Mar 12, 2025
19 checks passed
@future-pirate-king future-pirate-king deleted the PD-1717-sbom-upselling-ui branch March 12, 2025 11:24
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.

3 participants