Skip to content

Fix MI Welcome Page auto-opening when Test Explorer opened on non-MI project (#1371)#1960

Open
SasinduDilshara wants to merge 2 commits intomainfrom
fix/issue-1371
Open

Fix MI Welcome Page auto-opening when Test Explorer opened on non-MI project (#1371)#1960
SasinduDilshara wants to merge 2 commits intomainfrom
fix/issue-1371

Conversation

@SasinduDilshara
Copy link
Copy Markdown
Contributor

@SasinduDilshara SasinduDilshara commented Apr 10, 2026

Summary

  • Issue: wso2/mi-vscode#1371 — MI Welcome Page opens when accessing VS Code Test Explorer even for non-MI projects
  • Changed newProject state initial substate from viewLoading to viewReady in stateMachine.ts so the MI Welcome webview only opens on an explicit OPEN_VIEW event, not passively on onView:MI.mock-services activation
  • Added E2E regression test (nonMiProjectActivation.spec.ts) and unit test (nonMiProjectActivation.test.ts) to prevent regressions

Root Cause

When VS Code fires the implicit onView:MI.mock-services activation event (triggered by the user opening Test Explorer), the MI extension activates and the state machine enters the newProject state. Because newProject had initial: "viewLoading", it immediately invoked openWebPanel, showing the MI Welcome webview panel to users working on non-MI projects.

Fix

- initial: "viewLoading",
+ initial: "viewReady",

The viewReady substate is passive — it only opens the webview on an explicit OPEN_VIEW event (e.g., the MI.openWelcome command or the "Create New Project" toolbar button). This preserves the intended UX while preventing the unwanted auto-open behavior.

Test Plan

  • Dev test: started code-server with a non-MI workspace; MI extension activated via workspaceContains:pom.xml; confirmed MI Welcome Page did NOT auto-open
  • Verification script (Playwright): opened Testing view on non-MI JS project; confirmed no MI Welcome tab/webview appeared
  • Unit tests added in src/test/suite/nonMiProjectActivation.test.ts
  • E2E tests added in src/test/e2e-playwright-tests/nonMiProjectActivation.spec.ts
  • Run full E2E test suite

Changes

File Change
workspaces/mi/mi-extension/src/stateMachine.ts initial: "viewLoading"initial: "viewReady" in newProject state
workspaces/mi/mi-extension/src/test/suite/nonMiProjectActivation.test.ts New unit tests (regression guards)
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/nonMiProjectActivation.spec.ts New E2E tests
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/test.list.ts Register new E2E test suite

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Refined the state machine initialization for new project activation to properly handle non-MI project scenarios and improve overall startup behavior.
  • Tests

    • Expanded test coverage with new end-to-end and unit tests for non-MI project activation, ensuring the extension correctly identifies and manages workspaces without MI-specific project artifacts.

choreo-cicd and others added 2 commits March 25, 2026 15:13
Change `newProject` state machine initial substate from `viewLoading` to
`viewReady` so that the MI Welcome webview is only opened in response to
an explicit OPEN_VIEW event (e.g., MI.openWelcome command), not on passive
activation events like `onView:MI.mock-services` triggered by Test Explorer.

Adds unit tests (nonMiProjectActivation.test.ts) and E2E tests
(nonMiProjectActivation.spec.ts) as regression guards.

Fixes: wso2/mi-vscode#1371
@SasinduDilshara
Copy link
Copy Markdown
Contributor Author

Issue Analysis — [Issue #1371]: MI Welcome Page opens when accessing VS Code Test Explorer (even for non-MI projects)

Classification

  • Type: Bug
  • Severity Assessment: Medium — unexpected webview panel appears when user navigates to Test Explorer, disrupting their workflow even when they have no MI project open
  • Affected Component(s): wso2.micro-integrator VS Code extension — extension activation path and state machine initialization (extension.ts activate function, stateMachine.ts newProject state)
  • Affected Feature(s): Extension activation for non-MI workspaces; MI Welcome Page webview display logic

Reproducibility

  • Reproducible: No — the bug was not observed at runtime in this environment (see evidence and environment notes below)
  • Reproduction method: Playwright (browser automation via code-server + Chrome CDP)
  • Environment:
    • code-server v4.114.0 (VS Code 1.114.0) on macOS Darwin 24.0.0
    • wso2.micro-integrator v3.1.526032514 (installed)
    • orta.vscode-jest v6.4.4 (installed to provide a test controller and make the Testing icon visible)
    • Workspace: /tmp/mi-repro-issue-1371/workspace/my-sample-app — a non-MI JavaScript project with jest.config.js, node_modules/.bin/jest, and no pom.xml
  • Steps Executed:
    1. Killed all running code-server and Chrome instances; freed ports 8080 and 9222
    2. Created fresh non-MI workspace at /tmp/mi-repro-issue-1371/workspace/my-sample-app with jest.config.js, package.json, and node_modules/.bin/jest — deliberately no pom.xml
    3. Installed orta.vscode-jest to provide a VS Code test controller (without a test controller, the Testing beaker icon never appears in the activity bar)
    4. Started code-server and Chrome with remote debugging; opened workspace URL
    5. Dismissed workspace trust dialog; waited for VS Code activity bar to appear
    6. Observed extension activations via ~/.local/share/code-server/logs/20260410T161036/exthost*/remoteexthost.log
    7. Attempted to open Testing view via command palette (F1View: Show Testing) and via activity bar click
    8. Checked for MI Welcome Page content in the main DOM and all webview frames (including active-frame)
  • Expected Behavior: Opening the VS Code Test Explorer on a non-MI project should show the jest test tree; the MI Welcome Page should remain invisible since no MI project is open
  • Actual Behavior Observed: The MI Welcome Page did not appear. The Testing icon was absent from the activity bar in the current session (extension host exthost17); the wso2.micro-integrator extension never activated. The command palette did not offer View: Show Testing, confirming no test controller was registered in this session.
  • Evidence:
    • Screenshots: .ai/screenshots-1371/final-01-initial-load.png through final-12-final-state.png — activity bar shows only standard VS Code icons (Explorer, Search, Source Control, Run/Debug, Extensions), no Testing beaker and no WSO2 icon
    • Extension host log exthost17/remoteexthost.log: only built-in VS Code extensions activated (vscode.git, vscode.github, vscode.debug-auto-launch, vscode.merge-conflict); no wso2.micro-integrator, wso2.wso2-integrator, or Orta.vscode-jest activations logged
    • Earlier session (exthost9) with BOTH pom.xml AND jest.config.js present: MI extension activated via workspaceContains:pom.xml; Testing icon appeared; clicking Testing opened the Testing view but MI Welcome Page still did not appear

Why the Bug Was Not Reproduced

The reproduction is blocked by a chain of preconditions that did not align in this environment:

  1. onView:MI.mock-services implicit activation not triggered in code-server web mode. The MI extension lists no onView: event in its activationEvents array. VS Code desktop automatically adds implicit onView:<viewId> for all contributed views (including MI.mock-services in the test container), but code-server web mode appears not to fire this implicit activation for views whose when condition (MI.status == 'projectLoaded') is false at startup. Without a trigger, the MI extension stays dormant.

  2. Primary activation event requires pom.xml. Without pom.xml in the workspace, none of the MI extension's explicit activation events match (workspaceContains:pom.xml, workspaceContains:.project, onLanguage:SynapseXml).

  3. Extension host degraded after excessive restarts. After 17 extension host restarts (exthost1–exthost17) accumulated during the session, user extensions including orta.vscode-jest stopped activating reliably even with matching workspaceContains:node_modules/.bin/jest present. This prevented the Testing icon from appearing, making it impossible to click the Testing view.

Root Cause Analysis

The bug mechanism is confirmed by source code inspection of the installed extension at ~/.local/share/code-server/extensions/wso2.micro-integrator-3.1.526032514/:

Trigger path:

  1. User opens VS Code Test Explorer (activity bar beaker icon or View: Show Testing command)
  2. VS Code fires the implicit onView:MI.mock-services activation event (the MI extension contributes MI.mock-services to the test view container in package.json)
  3. extension.ts activate() runs — it calls getStateMachine(firstProject) where firstProject is the first workspace folder path
  4. The state machine initializes (stateMachine.ts:699) with projectUri: projectUri and view: MACHINE_VIEW.Welcome, then starts in the initialize state
  5. checkIfMiProject(context.projectUri!) runs and detects the workspace is NOT an MI project → returns isProject=false, isOldProject=false
  6. The state machine transitions to the newProject state (stateMachine.ts:103–108) with view: MACHINE_VIEW.Welcome
  7. newProject.viewLoading immediately invokes openWebPanel (stateMachine.ts:337)
  8. openWebPanel creates a VisualizerWebview panel showing the MI Welcome Page and calls webview.reveal() (stateMachine.ts:416–450)
  9. Result: The MI Welcome webview panel opens in the editor area, showing "Welcome to WSO2 Integrator: MI" with Create/Open project buttons — even though the user opened Test Explorer on an unrelated project

Why the when condition does not prevent this:

  • contributes.views.test[0].when = "MI.status == 'projectLoaded'" controls the view's visibility in the Testing sidebar — it is false for non-MI projects, so the Mock Services item does not appear in the UI
  • But VS Code fires onView:MI.mock-services before the extension activates (it fires to cause activation), so at that point MI.status is not yet set, and the when condition is irrelevant to the activation trigger
  • Once activated, the extension sets MI.status = 'unknownProject' only after the state machine completes initialization, but the Welcome webview opens during initialization before the status context is updated

Static configuration evidence (from package.json):

  • contributes.views.test: { "id": "MI.mock-services", "name": "Mock Services", "when": "MI.status == 'projectLoaded'" } — the MI extension registers a view in the VS Code Testing container
  • viewsWelcome for testing view: { "view": "testing", "contents": "[Add Unit Test](...)", "when": "MI.status == 'projectLoaded'" } — correctly gated, but the separate Welcome webview panel is opened programmatically and is not gated

Test Coverage Assessment

  • Existing tests covering this path:
    • src/test/suite/extension.test.ts — contains only a stub sample test, no meaningful coverage
    • src/test/e2e-playwright-tests/ — e2e tests cover MI project creation, artifact management, data mapper, unit test suite; all tests open a proper MI project workspace (never a non-MI project)
    • src/test/e2e-playwright-tests/components/UnitTest.ts:94 — clicks the Testing section tab but only in the context of an already-loaded MI project
  • Coverage gaps identified:
    • No test covers extension behavior when activated in a workspace without pom.xml or MI project structure
    • No test verifies the Welcome Page does NOT appear when the extension is activated via onView:MI.mock-services (Test Explorer) for a non-MI project
    • No test for the newProject state machine path (the path taken when checkIfMiProject returns isProject=false)
  • Proposed test plan:
    • Unit test: Mock checkIfMiProject to return { isProject: false, isOldProject: false } and assert that openWebPanel is NOT called (or is only called after explicit user action, not automatically on activation)
    • Integration test: Use getStateMachine(projectUri) with a non-MI workspace path; verify the state machine enters newProject state but does NOT create a webview panel without user interaction
    • E2E test: Open code-server with a JavaScript-only workspace (no pom.xml), activate the MI extension via the Test Explorer icon, and assert that no MI Welcome webview panel (MACHINE_VIEW.Welcome) opens in the editor area; page.locator('.webview') should show 0 or only non-MI webviews
    • Negative case: Verify MI.status is correctly set to 'unknownProject' (not 'projectLoaded') for non-MI workspaces — the sidebar viewsWelcome text is correctly gated, but the programmatic webview panel is not

@SasinduDilshara
Copy link
Copy Markdown
Contributor Author

Fix Plan — Issue #1371

Dev Test Result

  • Status: PASSED
  • What was tested: Started code-server with a non-MI workspace containing a plain pom.xml (no <projectType>integration-project</projectType>), which triggered workspaceContains:pom.xml activation of the wso2.micro-integrator extension. Verified that the MI Welcome webview panel did NOT auto-open.
  • Result:
    • Extension host log confirmed: wso2.micro-integrator activated via workspaceContains:pom.xml
    • checkIfMiProject returned isProject=false (no MI project marker in pom.xml)
    • State machine transitioned to newProject state → started in viewReady sub-state (not viewLoading)
    • No MI Welcome webview panel was created
    • Screenshot shows VS Code's standard "Get Started" page in the editor, not the MI Welcome page
    • Test script output: TEST PASSED — MI Welcome Page did NOT auto-open for non-MI workspace

Changes Made

Repo File Change
wso2/vscode-extensions workspaces/mi/mi-extension/src/stateMachine.ts Changed initial: "viewLoading" to initial: "viewReady" in the newProject state (line 326)

Root Cause & Fix Explanation

Root cause: The newProject state in the XState machine (stateMachine.ts) had initial: "viewLoading", causing it to immediately invoke openWebPanel (which creates the MI Welcome webview) upon entering the state. This state is entered whenever the MI extension activates in a workspace that is NOT an MI project (i.e., checkIfMiProject returns isProject=false, isOldProject=false). Since VS Code fires the implicit onView:MI.mock-services activation event when the user opens the Testing sidebar, the extension activates and auto-opens the Welcome page even for completely unrelated projects (e.g., JavaScript/Jest projects).

Fix: Changed initial: "viewLoading" to initial: "viewReady" in the newProject state. The viewReady sub-state is passive — it only responds to explicit OPEN_VIEW events (e.g., from the MI.openWelcome command). This prevents the Welcome webview from opening automatically on passive activation events like onView:MI.mock-services, while preserving the ability to explicitly open the Welcome page via the MI.openWelcome command (Create New Project toolbar button or MI: Open MI Welcome command palette entry).

Known Issues

None — dev test passed. The explicit MI.openWelcome command path is unaffected because it sends an OPEN_VIEW event to the state machine, which the viewReady sub-state handles by transitioning to viewLoadingopenWebPanel.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

The PR addresses issue #1371 by modifying the state machine's newProject entry point from viewLoading to viewReady, preventing automatic MI Welcome page invocation on non-MI workspaces. A version bump and comprehensive test suites (unit and e2e) validate the fix.

Changes

Cohort / File(s) Summary
Version & State Machine Fix
workspaces/mi/mi-extension/package.json, workspaces/mi/mi-extension/src/stateMachine.ts
Bumped extension version to 3.1.526032514 and changed initial nested state in newProject from viewLoading to viewReady, altering startup control flow to skip automatic openWebPanel invocation for non-MI projects.
Unit Test Suite
workspaces/mi/mi-extension/src/test/suite/nonMiProjectActivation.test.ts
Added issue #1371 test suite validating non-MI workspace detection, verifying the state machine enters newProject.viewReady substate on activation, and confirming no VisualizerWebview is created for non-MI directories (empty, plain Maven, or JavaScript layouts).
E2E Test Suite
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/nonMiProjectActivation.spec.ts
Added Playwright e2e tests with negative regression checks: verifies MI Welcome tab/iframe does not appear and Test Explorer "Mock Services" section remains hidden when activating non-MI workspaces.
Test Registration
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/test.list.ts
Registered new nonMiProjectActivationTests Playwright suite.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A hasty welcome once did bloom,
For non-MI projects in their room,
But now viewReady leads the way,
No false greetings here today!
Issue 1371's fixed with care,
Through unit tests and e2e there. 🧪

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: preventing the MI Welcome Page from auto-opening when Test Explorer is accessed on non-MI projects, directly addressing issue #1371.
Description check ✅ Passed The description covers Purpose (with issue link), Goals, Approach, Test Plan, and Changes summary. However, several template sections (UI Components, Icons, User Stories, Release Notes, Documentation, Training, etc.) are not addressed.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1371
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/issue-1371

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.

@SasinduDilshara
Copy link
Copy Markdown
Contributor Author

Fix Verification Report

Issue: wso2/mi-vscode#1371
Verdict: FIXED
Verification method: Playwright (browser automation via code-server + Chrome CDP)

Reproduction Steps Executed

  1. Created a non-MI JavaScript workspace at /tmp/mi-verify-1371-20260410-174546/workspace/my-js-app containing:

    • package.json, index.js, index.test.js, jest.config.js (plain JS project)
    • pom.xml with plain Maven structure — no <projectType>integration-project</projectType> (mimics the bug trigger: a non-MI project with pom.xml present to trigger workspaceContains:pom.xml activation)
  2. Started code-server with the workspace pre-containing pom.xml so the workspaceContains:pom.xml activation event fires at startup.

  3. Confirmed MI extension activation via extension host log:

    2026-04-10 17:49:25.312 [info] ExtensionService#_doActivateExtension wso2.micro-integrator,
      startup: true, activationEvent: 'workspaceContains:pom.xml'
    
  4. Opened the VS Code Testing view via command palette (F1View: Show Testing), which is the action described in the issue's reproduction steps.

  5. Checked for MI Welcome Page in:

    • All open editor tabs (.tab-label elements)
    • All page frames (checking for "Welcome to WSO2" / "Create New Project" text)
    • Webview panels in the editor area
  6. Playwright script exit code: 0 (PASSED)

Result

The MI Welcome Page did not auto-open when the Testing view was opened on a non-MI workspace.

  • The Testing sidebar correctly showed the Jest test runner entry (my-js-app (watch))
  • The editor displayed VS Code's standard "Get Started with VS Code for the Web" page — not the MI Welcome webview
  • No MI Welcome tab appeared in the editor tab bar
  • No "Welcome to WSO2" or "Create New Project" content was found in any iframe

Fix mechanism confirmed: The newProject state in stateMachine.ts:326 now has initial: "viewReady" instead of initial: "viewLoading". The viewReady sub-state is passive and does not invoke openWebPanel automatically. The Welcome webview only opens when an explicit OPEN_VIEW event is dispatched (e.g., via the MI.openWelcome command).

Evidence

Extension Host Log (confirms MI extension activation on non-MI workspace)

2026-04-10 17:49:21.995 [info] ExtensionService#_doActivateExtension redhat.vscode-yaml,
  startup: true, activationEvent: 'workspaceContains:pom.xml', root cause: wso2.micro-integrator
2026-04-10 17:49:22.076 [info] ExtensionService#_doActivateExtension wso2.wso2-integrator,
  startup: true, activationEvent: 'workspaceContains:pom.xml'
2026-04-10 17:49:22.287 [info] ExtensionService#_doActivateExtension wso2.wso2-platform,
  startup: true, activationEvent: 'workspaceContains:pom.xml', root cause: wso2.micro-integrator
2026-04-10 17:49:25.312 [info] ExtensionService#_doActivateExtension wso2.micro-integrator,
  startup: true, activationEvent: 'workspaceContains:pom.xml'

Playwright Test Output

=== TEST RESULTS ===
MI Welcome in main page: false
MI Welcome in any frame: false
MI Welcome tab present: false
Webview panels in editor: 1

TEST PASSED ✓
The MI Welcome Page did NOT auto-open when Test Explorer was opened on a non-MI project.
Fix confirmed: newProject state correctly starts in viewReady, not viewLoading.

Screenshots

Screenshot Description
.ai/screenshots-1371/verify/01-initial-state.png VS Code loaded with non-MI workspace. Explorer shows pom.xml present. No MI Welcome tab open. Standard VS Code "Get Started" walkthrough visible.
.ai/screenshots-1371/verify/05-after-show-testing.png After opening Testing view via View: Show Testing. Testing sidebar shows Jest entry. No MI Welcome Page in editor.
.ai/screenshots-1371/verify/07-final-state.png Final state after all interactions. Testing view open, no MI Welcome Page, correct non-MI behavior confirmed.

Source Fix (confirmed in repo)

File: vscode-extensions/workspaces/mi/mi-extension/src/stateMachine.ts:326

newProject: {
    entry: () => logDebug("State Machine: Entering 'newProject' state"),
    initial: "viewReady",   // ← FIX: was "viewLoading" (auto-opened Welcome webview)
    states: {
        viewLoading: { ... invoke: { src: 'openWebPanel' } ... },
        viewReady: {
            // Passive state — only opens webview on explicit OPEN_VIEW event
            on: { OPEN_VIEW: { target: "viewLoading", ... } }
        }
    }
}

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@workspaces/mi/mi-extension/src/test/e2e-playwright-tests/nonMiProjectActivation.spec.ts`:
- Around line 43-52: The test currently calls initTest(...) once inside
test.describe, causing shared beforeAll/afterAll and a single VS Code session;
change the structure so each activation scenario gets its own fresh session by
moving initTest(...) into separate test.describe blocks or by creating two
distinct describe() suites that each call initTest(true, true, false, ...)
independently (referencing createTests(), test.describe, and initTest) so
beforeAll/afterAll run per-scenario and the cold-activation case is exercised in
its own fresh extension/workspace.

In `@workspaces/mi/mi-extension/src/test/suite/nonMiProjectActivation.test.ts`:
- Around line 151-162: The test currently only asserts that sm.context().view is
defined; update the assertion to check that the view equals the specific
MACHINE_VIEW.Welcome value. Locate the test "newProject state machine context
carries Welcome view type" and replace the loose check on ctx.view (from
getStateMachine(...) and waitForTopState(...)) with a strict equality/assertion
against MACHINE_VIEW.Welcome (use the same ctx = sm.context() as any and
assert.strictEqual or equivalent to ensure ctx.view === MACHINE_VIEW.Welcome).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 84260bd8-a055-4376-90fe-37de00a2fe6d

📥 Commits

Reviewing files that changed from the base of the PR and between 031d074 and 382236b.

📒 Files selected for processing (5)
  • workspaces/mi/mi-extension/package.json
  • workspaces/mi/mi-extension/src/stateMachine.ts
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/nonMiProjectActivation.spec.ts
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/test.list.ts
  • workspaces/mi/mi-extension/src/test/suite/nonMiProjectActivation.test.ts

Comment on lines +43 to +52
export default function createTests() {
test.describe('Issue #1371 — Non-MI Project Activation', {
tag: '@issue1371',
}, async () => {
// `newProject: true` → always start with a clean workspace directory
// `skipProjectCreation: true` → do NOT run createProject(); the workspace
// stays empty (no pom.xml) so the MI extension
// will not detect an MI project.
initTest(true, true, false, undefined, undefined, 'issue1371');

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.

⚠️ Potential issue | 🟠 Major

Run each activation scenario in a fresh VS Code session.

initTest() installs beforeAll/afterAll, so calling it once here makes both cases share the same workspace and extension instance. That means the second test no longer verifies cold activation on a non-MI Maven workspace, which weakens the regression guard for the exact bug this suite is targeting. Consider isolating each scenario in its own describe/initTest(...) block or otherwise relaunching between tests.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@workspaces/mi/mi-extension/src/test/e2e-playwright-tests/nonMiProjectActivation.spec.ts`
around lines 43 - 52, The test currently calls initTest(...) once inside
test.describe, causing shared beforeAll/afterAll and a single VS Code session;
change the structure so each activation scenario gets its own fresh session by
moving initTest(...) into separate test.describe blocks or by creating two
distinct describe() suites that each call initTest(true, true, false, ...)
independently (referencing createTests(), test.describe, and initTest) so
beforeAll/afterAll run per-scenario and the cold-activation case is exercised in
its own fresh extension/workspace.

Comment on lines +151 to +162
test('newProject state machine context carries Welcome view type', async () => {
// After transitioning to newProject, context.view should be set to
// MACHINE_VIEW.Welcome — but the webview must NOT be opened yet.
const sm = getStateMachine(tempDir);
await waitForTopState(sm, 'newProject');

const ctx = sm.context() as any;
assert.ok(
ctx.view !== undefined,
'State machine context must have a view property after entering newProject'
);
});
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.

⚠️ Potential issue | 🟡 Minor

Assert the actual Welcome view, not just “some view”.

This test currently passes for any non-undefined ctx.view, so it would miss a regression that routes non-MI activation to the wrong screen. Please assert the specific MACHINE_VIEW.Welcome value here.

Suggested tightening
 import * as fs from 'fs';
 import { isOldProjectOrWorkspace, getStateMachine, deleteStateMachine } from '../../stateMachine';
 import { webviews } from '../../visualizer/webview';
+import { MACHINE_VIEW } from '@wso2/mi-core';
-        assert.ok(
-            ctx.view !== undefined,
-            'State machine context must have a view property after entering newProject'
-        );
+        assert.strictEqual(
+            ctx.view,
+            MACHINE_VIEW.Welcome,
+            'State machine context must point to MACHINE_VIEW.Welcome after entering newProject'
+        );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workspaces/mi/mi-extension/src/test/suite/nonMiProjectActivation.test.ts`
around lines 151 - 162, The test currently only asserts that sm.context().view
is defined; update the assertion to check that the view equals the specific
MACHINE_VIEW.Welcome value. Locate the test "newProject state machine context
carries Welcome view type" and replace the loose check on ctx.view (from
getStateMachine(...) and waitForTopState(...)) with a strict equality/assertion
against MACHINE_VIEW.Welcome (use the same ctx = sm.context() as any and
assert.strictEqual or equivalent to ensure ctx.view === MACHINE_VIEW.Welcome).

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ SasinduDilshara
❌ choreo-cicd
You have signed the CLA already but the status is still pending? Let us recheck it.

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