Skip to content

[scanner] 🌱 split analytics-events.test.ts (1546 lines) into focused modules#19322

Merged
clubanderson merged 4 commits into
mainfrom
scanner/fix-18598
Jun 21, 2026
Merged

[scanner] 🌱 split analytics-events.test.ts (1546 lines) into focused modules#19322
clubanderson merged 4 commits into
mainfrom
scanner/fix-18598

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Fixes #18598

Splits the oversized analytics-events.test.ts test file (1546 lines) into 3 focused modules based on logical groupings:

  • analytics-events.cards-interactions.test.ts (684 lines) — Dashboard, cards, search, and UI interactions
  • analytics-events.system-operations.test.ts (639 lines) — Auth, settings, APIs, and cluster operations
  • analytics-events.engagement-lifecycle.test.ts (668 lines) — Nudges, recommendations, features, and ACMM

Each new file contains logically grouped test suites with proper structure. This is the first step in addressing the 20+ oversized test files reported in the issue.

…used modules

Split the oversized analytics-events.test.ts test file into 3 focused modules:
- analytics-events.cards-interactions.test.ts (684 lines) - Dashboard, cards, search, and UI interactions
- analytics-events.system-operations.test.ts (639 lines) - Auth, settings, APIs, and cluster operations
- analytics-events.engagement-lifecycle.test.ts (668 lines) - Nudges, recommendations, features, and ACMM

This addresses issue #18598 by reducing one of the largest oversized test files.
Each new file contains logically grouped test suites with proper structure and closure.

Signed-off-by: hive-scanner <scanner@kubestellar.io>
Signed-off-by: Hive Scanner <hive-scanner@kubestellar.local>
Copilot AI review requested due to automatic review settings June 21, 2026 00:34
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 21, 2026
@netlify

netlify Bot commented Jun 21, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 97656ca
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a374b3ef001a30008ecf1d3
😎 Deploy Preview https://deploy-preview-19322.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jun 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the analytics emitter test coverage by removing the monolithic web/src/lib/__tests__/analytics-events.test.ts and replacing it with three separate Vitest modules intended to be organized by logical event groupings (per #18598’s “oversized files” initiative).

Changes:

  • Deleted the 1546-line analytics-events.test.ts.
  • Added analytics-events.cards-interactions.test.ts, analytics-events.system-operations.test.ts, and analytics-events.engagement-lifecycle.test.ts to distribute the suites across multiple files.
  • Replicated the shared mocking/setup boilerplate into each new module.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
web/src/lib/tests/analytics-events.test.ts Removed the original monolithic analytics-events emitter test file.
web/src/lib/tests/analytics-events.cards-interactions.test.ts Added one of the split test modules; currently contains a syntax/braces issue at EOF and includes suites beyond “cards interactions”.
web/src/lib/tests/analytics-events.system-operations.test.ts Added one of the split test modules covering operational/system-related emitters and flows.
web/src/lib/tests/analytics-events.engagement-lifecycle.test.ts Added one of the split test modules covering engagement/lifecycle-related emitters and flows.

import { send, setAnalyticsUserProperties, emitError } from '../analytics-core'
import { isDemoMode } from '../demoMode'
import { getDeploymentType } from '../analytics-session'
import { CAPABILITY_TOOL_EXEC, CAPABILITY_CHAT } from '../analytics-types'
import { send, setAnalyticsUserProperties, emitError } from '../analytics-core'
import { isDemoMode } from '../demoMode'
import { getDeploymentType } from '../analytics-session'
import { CAPABILITY_TOOL_EXEC, CAPABILITY_CHAT } from '../analytics-types'
Comment on lines +1 to +6
/**
* Tests for analytics-events.ts emit functions.
*
* We mock the `send` function from analytics-core and verify that each
* emitter calls it with the correct event name and parameters.
*/
Comment on lines +469 to +481
describe('Auth', () => {
it('emitLogin sends method', () => {
emitLogin('github')
expect(mockSend).toHaveBeenCalledWith('login', { method: 'github' })
})

it('emitLogout sends event', () => {
emitLogout()
expect(mockSend).toHaveBeenCalledWith('ksc_logout')
})
})

describe('Feedback', () => {
Comment on lines +27 to +203
import {
emitCardAdded,
emitCardRemoved,
emitCardExpanded,
emitCardDragged,
emitCardConfigured,
emitCardReplaced,
emitGlobalSearchOpened,
emitGlobalSearchQueried,
emitGlobalSearchSelected,
emitGlobalSearchAskAI,
emitCardSortChanged,
emitCardSortDirectionChanged,
emitCardLimitChanged,
emitCardSearchUsed,
emitCardClusterFilterChanged,
emitCardPaginationUsed,
emitCardListItemClicked,
emitMissionStarted,
emitMissionCompleted,
emitMissionError,
emitMissionRated,
emitFixerSearchStarted,
emitFixerSearchCompleted,
emitFixerBrowsed,
emitFixerViewed,
emitFixerImported,
emitFixerImportError,
emitFixerLinkCopied,
emitFixerGitHubLink,
emitLogin,
emitLogout,
emitFeedbackSubmitted,
emitScreenshotAttached,
emitScreenshotUploadFailed,
emitScreenshotUploadSuccess,
emitNPSSurveyShown,
emitNPSResponse,
emitNPSDismissed,
emitOrbitMissionCreated,
emitOrbitMissionRun,
emitGroundControlDashboardCreated,
emitGroundControlCardRequestOpened,
emitSessionExpired,
emitTourStarted,
emitTourCompleted,
emitTourSkipped,
emitMarketplaceInstall,
emitMarketplaceRemove,
emitMarketplaceInstallFailed,
emitThemeChanged,
emitLanguageChanged,
emitAIModeChanged,
emitAIPredictionsToggled,
emitConfidenceThresholdChanged,
emitConsensusModeToggled,
emitGitHubTokenConfigured,
emitGitHubTokenRemoved,
emitApiProviderConnected,
emitDemoModeToggled,
emitAgentTokenFailure,
emitWsAuthMissing,
emitSseAuthFailure,
emitSessionRefreshFailure,
emitAgentConnected,
emitAgentDisconnected,
emitClusterInventory,
emitAgentProvidersDetected,
emitApiKeyConfigured,
emitApiKeyRemoved,
emitInstallCommandCopied,
emitConversionStep,
emitDeployWorkload,
emitDeployTemplateApplied,
emitComplianceDrillDown,
emitComplianceFilterChanged,
emitBenchmarkViewed,
emitClusterCreated,
emitGitHubConnected,
emitClusterAction,
emitClusterStatsDrillDown,
emitWidgetLoaded,
emitWidgetNavigation,
emitWidgetInstalled,
emitWidgetDownloaded,
emitNudgeShown,
emitNudgeDismissed,
emitNudgeActioned,
emitSmartSuggestionsShown,
emitSmartSuggestionAccepted,
emitSmartSuggestionsAddAll,
emitCardRecommendationsShown,
emitCardRecommendationActioned,
emitMissionSuggestionsShown,
emitMissionSuggestionActioned,
emitAddCardModalOpened,
emitAddCardModalAbandoned,
emitDashboardScrolled,
emitPwaPromptShown,
emitPwaPromptDismissed,
emitLinkedInShare,
emitSessionContext,
emitUpdateChecked,
emitUpdateTriggered,
emitUpdateCompleted,
emitUpdateFailed,
emitUpdateRefreshed,
emitUpdateStalled,
emitDrillDownOpened,
emitDrillDownClosed,
emitCardRefreshed,
emitGlobalClusterFilterChanged,
emitGlobalSeverityFilterChanged,
emitGlobalStatusFilterChanged,
emitPredictionFeedbackSubmitted,
emitSnoozed,
emitUnsnoozed,
emitDashboardCreated,
emitDashboardDeleted,
emitDashboardRenamed,
emitDashboardImported,
emitDashboardExported,
emitDataExported,
emitUserRoleChanged,
emitUserRemoved,
emitMarketplaceItemViewed,
emitInsightViewed,
emitGameStarted,
emitGameEnded,
emitSidebarNavigated,
emitLocalClusterCreated,
emitDeveloperSession,
emitCardCategoryBrowsed,
emitRecommendedCardShown,
emitDashboardViewed,
emitFeatureHintShown,
emitFeatureHintDismissed,
emitFeatureHintActioned,
emitGettingStartedShown,
emitGettingStartedActioned,
emitPostConnectShown,
emitPostConnectActioned,
emitDemoToLocalShown,
emitDemoToLocalActioned,
emitAdopterNudgeShown,
emitAdopterNudgeActioned,
emitModalOpened,
emitModalTabViewed,
emitModalClosed,
emitInsightAcknowledged,
emitInsightDismissed,
emitActionClicked,
emitAISuggestionViewed,
emitWelcomeViewed,
emitWelcomeActioned,
emitFromLensViewed,
emitFromLensActioned,
emitFromLensTabSwitch,
emitFromLensCommandCopy,
emitFromHeadlampViewed,
emitFromHeadlampActioned,
emitFromHeadlampTabSwitch,
emitFromHeadlampCommandCopy,
emitWhiteLabelViewed,
emitWhiteLabelActioned,
emitWhiteLabelTabSwitch,
emitWhiteLabelCommandCopy,
emitTipShown,
emitStreakDay,
emitBlogPostClicked,
emitWhatsNewModalOpened,
emitWhatsNewUpdateClicked,
emitWhatsNewRemindLater,
emitACMMScanned,
emitACMMMissionLaunched,
emitACMMLevelMissionLaunched,
} from '../analytics-events'
import { send, setAnalyticsUserProperties, emitError } from '../analytics-core'
import { isDemoMode } from '../demoMode'
import { getDeploymentType } from '../analytics-session'
import { CAPABILITY_TOOL_EXEC, CAPABILITY_CHAT } from '../analytics-types'
Comment on lines +27 to +203
import {
emitCardAdded,
emitCardRemoved,
emitCardExpanded,
emitCardDragged,
emitCardConfigured,
emitCardReplaced,
emitGlobalSearchOpened,
emitGlobalSearchQueried,
emitGlobalSearchSelected,
emitGlobalSearchAskAI,
emitCardSortChanged,
emitCardSortDirectionChanged,
emitCardLimitChanged,
emitCardSearchUsed,
emitCardClusterFilterChanged,
emitCardPaginationUsed,
emitCardListItemClicked,
emitMissionStarted,
emitMissionCompleted,
emitMissionError,
emitMissionRated,
emitFixerSearchStarted,
emitFixerSearchCompleted,
emitFixerBrowsed,
emitFixerViewed,
emitFixerImported,
emitFixerImportError,
emitFixerLinkCopied,
emitFixerGitHubLink,
emitLogin,
emitLogout,
emitFeedbackSubmitted,
emitScreenshotAttached,
emitScreenshotUploadFailed,
emitScreenshotUploadSuccess,
emitNPSSurveyShown,
emitNPSResponse,
emitNPSDismissed,
emitOrbitMissionCreated,
emitOrbitMissionRun,
emitGroundControlDashboardCreated,
emitGroundControlCardRequestOpened,
emitSessionExpired,
emitTourStarted,
emitTourCompleted,
emitTourSkipped,
emitMarketplaceInstall,
emitMarketplaceRemove,
emitMarketplaceInstallFailed,
emitThemeChanged,
emitLanguageChanged,
emitAIModeChanged,
emitAIPredictionsToggled,
emitConfidenceThresholdChanged,
emitConsensusModeToggled,
emitGitHubTokenConfigured,
emitGitHubTokenRemoved,
emitApiProviderConnected,
emitDemoModeToggled,
emitAgentTokenFailure,
emitWsAuthMissing,
emitSseAuthFailure,
emitSessionRefreshFailure,
emitAgentConnected,
emitAgentDisconnected,
emitClusterInventory,
emitAgentProvidersDetected,
emitApiKeyConfigured,
emitApiKeyRemoved,
emitInstallCommandCopied,
emitConversionStep,
emitDeployWorkload,
emitDeployTemplateApplied,
emitComplianceDrillDown,
emitComplianceFilterChanged,
emitBenchmarkViewed,
emitClusterCreated,
emitGitHubConnected,
emitClusterAction,
emitClusterStatsDrillDown,
emitWidgetLoaded,
emitWidgetNavigation,
emitWidgetInstalled,
emitWidgetDownloaded,
emitNudgeShown,
emitNudgeDismissed,
emitNudgeActioned,
emitSmartSuggestionsShown,
emitSmartSuggestionAccepted,
emitSmartSuggestionsAddAll,
emitCardRecommendationsShown,
emitCardRecommendationActioned,
emitMissionSuggestionsShown,
emitMissionSuggestionActioned,
emitAddCardModalOpened,
emitAddCardModalAbandoned,
emitDashboardScrolled,
emitPwaPromptShown,
emitPwaPromptDismissed,
emitLinkedInShare,
emitSessionContext,
emitUpdateChecked,
emitUpdateTriggered,
emitUpdateCompleted,
emitUpdateFailed,
emitUpdateRefreshed,
emitUpdateStalled,
emitDrillDownOpened,
emitDrillDownClosed,
emitCardRefreshed,
emitGlobalClusterFilterChanged,
emitGlobalSeverityFilterChanged,
emitGlobalStatusFilterChanged,
emitPredictionFeedbackSubmitted,
emitSnoozed,
emitUnsnoozed,
emitDashboardCreated,
emitDashboardDeleted,
emitDashboardRenamed,
emitDashboardImported,
emitDashboardExported,
emitDataExported,
emitUserRoleChanged,
emitUserRemoved,
emitMarketplaceItemViewed,
emitInsightViewed,
emitGameStarted,
emitGameEnded,
emitSidebarNavigated,
emitLocalClusterCreated,
emitDeveloperSession,
emitCardCategoryBrowsed,
emitRecommendedCardShown,
emitDashboardViewed,
emitFeatureHintShown,
emitFeatureHintDismissed,
emitFeatureHintActioned,
emitGettingStartedShown,
emitGettingStartedActioned,
emitPostConnectShown,
emitPostConnectActioned,
emitDemoToLocalShown,
emitDemoToLocalActioned,
emitAdopterNudgeShown,
emitAdopterNudgeActioned,
emitModalOpened,
emitModalTabViewed,
emitModalClosed,
emitInsightAcknowledged,
emitInsightDismissed,
emitActionClicked,
emitAISuggestionViewed,
emitWelcomeViewed,
emitWelcomeActioned,
emitFromLensViewed,
emitFromLensActioned,
emitFromLensTabSwitch,
emitFromLensCommandCopy,
emitFromHeadlampViewed,
emitFromHeadlampActioned,
emitFromHeadlampTabSwitch,
emitFromHeadlampCommandCopy,
emitWhiteLabelViewed,
emitWhiteLabelActioned,
emitWhiteLabelTabSwitch,
emitWhiteLabelCommandCopy,
emitTipShown,
emitStreakDay,
emitBlogPostClicked,
emitWhatsNewModalOpened,
emitWhatsNewUpdateClicked,
emitWhatsNewRemindLater,
emitACMMScanned,
emitACMMMissionLaunched,
emitACMMLevelMissionLaunched,
} from '../analytics-events'
clubanderson and others added 2 commits June 20, 2026 21:27
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Hive Scanner <hive-scanner@kubestellar.local>
@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Jun 21, 2026
import { send, setAnalyticsUserProperties, emitError } from '../analytics-core'
import { isDemoMode } from '../demoMode'
import { getDeploymentType } from '../analytics-session'
import { CAPABILITY_TOOL_EXEC, CAPABILITY_CHAT } from '../analytics-types'
Comment on lines +27 to +203
import {
emitCardAdded,
emitCardRemoved,
emitCardExpanded,
emitCardDragged,
emitCardConfigured,
emitCardReplaced,
emitGlobalSearchOpened,
emitGlobalSearchQueried,
emitGlobalSearchSelected,
emitGlobalSearchAskAI,
emitCardSortChanged,
emitCardSortDirectionChanged,
emitCardLimitChanged,
emitCardSearchUsed,
emitCardClusterFilterChanged,
emitCardPaginationUsed,
emitCardListItemClicked,
emitMissionStarted,
emitMissionCompleted,
emitMissionError,
emitMissionRated,
emitFixerSearchStarted,
emitFixerSearchCompleted,
emitFixerBrowsed,
emitFixerViewed,
emitFixerImported,
emitFixerImportError,
emitFixerLinkCopied,
emitFixerGitHubLink,
emitLogin,
emitLogout,
emitFeedbackSubmitted,
emitScreenshotAttached,
emitScreenshotUploadFailed,
emitScreenshotUploadSuccess,
emitNPSSurveyShown,
emitNPSResponse,
emitNPSDismissed,
emitOrbitMissionCreated,
emitOrbitMissionRun,
emitGroundControlDashboardCreated,
emitGroundControlCardRequestOpened,
emitSessionExpired,
emitTourStarted,
emitTourCompleted,
emitTourSkipped,
emitMarketplaceInstall,
emitMarketplaceRemove,
emitMarketplaceInstallFailed,
emitThemeChanged,
emitLanguageChanged,
emitAIModeChanged,
emitAIPredictionsToggled,
emitConfidenceThresholdChanged,
emitConsensusModeToggled,
emitGitHubTokenConfigured,
emitGitHubTokenRemoved,
emitApiProviderConnected,
emitDemoModeToggled,
emitAgentTokenFailure,
emitWsAuthMissing,
emitSseAuthFailure,
emitSessionRefreshFailure,
emitAgentConnected,
emitAgentDisconnected,
emitClusterInventory,
emitAgentProvidersDetected,
emitApiKeyConfigured,
emitApiKeyRemoved,
emitInstallCommandCopied,
emitConversionStep,
emitDeployWorkload,
emitDeployTemplateApplied,
emitComplianceDrillDown,
emitComplianceFilterChanged,
emitBenchmarkViewed,
emitClusterCreated,
emitGitHubConnected,
emitClusterAction,
emitClusterStatsDrillDown,
emitWidgetLoaded,
emitWidgetNavigation,
emitWidgetInstalled,
emitWidgetDownloaded,
emitNudgeShown,
emitNudgeDismissed,
emitNudgeActioned,
emitSmartSuggestionsShown,
emitSmartSuggestionAccepted,
emitSmartSuggestionsAddAll,
emitCardRecommendationsShown,
emitCardRecommendationActioned,
emitMissionSuggestionsShown,
emitMissionSuggestionActioned,
emitAddCardModalOpened,
emitAddCardModalAbandoned,
emitDashboardScrolled,
emitPwaPromptShown,
emitPwaPromptDismissed,
emitLinkedInShare,
emitSessionContext,
emitUpdateChecked,
emitUpdateTriggered,
emitUpdateCompleted,
emitUpdateFailed,
emitUpdateRefreshed,
emitUpdateStalled,
emitDrillDownOpened,
emitDrillDownClosed,
emitCardRefreshed,
emitGlobalClusterFilterChanged,
emitGlobalSeverityFilterChanged,
emitGlobalStatusFilterChanged,
emitPredictionFeedbackSubmitted,
emitSnoozed,
emitUnsnoozed,
emitDashboardCreated,
emitDashboardDeleted,
emitDashboardRenamed,
emitDashboardImported,
emitDashboardExported,
emitDataExported,
emitUserRoleChanged,
emitUserRemoved,
emitMarketplaceItemViewed,
emitInsightViewed,
emitGameStarted,
emitGameEnded,
emitSidebarNavigated,
emitLocalClusterCreated,
emitDeveloperSession,
emitCardCategoryBrowsed,
emitRecommendedCardShown,
emitDashboardViewed,
emitFeatureHintShown,
emitFeatureHintDismissed,
emitFeatureHintActioned,
emitGettingStartedShown,
emitGettingStartedActioned,
emitPostConnectShown,
emitPostConnectActioned,
emitDemoToLocalShown,
emitDemoToLocalActioned,
emitAdopterNudgeShown,
emitAdopterNudgeActioned,
emitModalOpened,
emitModalTabViewed,
emitModalClosed,
emitInsightAcknowledged,
emitInsightDismissed,
emitActionClicked,
emitAISuggestionViewed,
emitWelcomeViewed,
emitWelcomeActioned,
emitFromLensViewed,
emitFromLensActioned,
emitFromLensTabSwitch,
emitFromLensCommandCopy,
emitFromHeadlampViewed,
emitFromHeadlampActioned,
emitFromHeadlampTabSwitch,
emitFromHeadlampCommandCopy,
emitWhiteLabelViewed,
emitWhiteLabelActioned,
emitWhiteLabelTabSwitch,
emitWhiteLabelCommandCopy,
emitTipShown,
emitStreakDay,
emitBlogPostClicked,
emitWhatsNewModalOpened,
emitWhatsNewUpdateClicked,
emitWhatsNewRemindLater,
emitACMMScanned,
emitACMMMissionLaunched,
emitACMMLevelMissionLaunched,
} from '../analytics-events'
@clubanderson clubanderson merged commit dac4e86 into main Jun 21, 2026
34 of 43 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the scanner/fix-18598 branch June 21, 2026 03:01
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: dac4e86a6b586f1d4a91f99a33a11208de0bd658
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/27891661553

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit dac4e86a6b586f1d4a91f99a33a11208de0bd658.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Pull request generated by AI dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Auto-QA] Oversized source files detected

2 participants