Skip to content

Expand e2e tests for WebSocket connection and message flow validation#43

Merged
mahata merged 12 commits intomainfrom
copilot/fix-42
Jul 11, 2025
Merged

Expand e2e tests for WebSocket connection and message flow validation#43
mahata merged 12 commits intomainfrom
copilot/fix-42

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 10, 2025

The e2e tests in files/e2e/app.spec.ts were minimal and needed expansion to cover critical WebSocket functionality and message flow scenarios.

Changes Made

Added two comprehensive e2e test scenarios to validate:

1. WebSocket Connection Status Test

test("WebSocket connection status changes from Connecting to Connected", async ({ page }) => {
  await page.goto("/");
  
  // Initially, the status should show "Connecting..."
  await expect(page.locator("#status")).toContainText("Connecting...");
  
  // Wait for the WebSocket connection to be established and status to change to "Connected"
  await expect(page.locator("#status")).toContainText("Connected", { timeout: 10000 });
  
  // Verify that the input and button are enabled after connection
  await expect(page.locator("#messageInput")).toBeEnabled();
  await expect(page.locator("#sendButton")).toBeEnabled();
});

2. Message Flow Test

test("Send message and verify it appears in messages div", async ({ page }) => {
  await page.goto("/");
  
  // Wait for WebSocket connection to be established
  await expect(page.locator("#status")).toContainText("Connected", { timeout: 10000 });
  
  const testMessage = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
  
  // Type the test message in the input field
  await page.locator("#messageInput").fill(testMessage);
  
  // Click the Send button
  await page.locator("#sendButton").click();
  
  // Verify that the message appears in the messages div
  await expect(page.locator("#messages")).toContainText(testMessage);
  
  // Verify that the input field is cleared after sending
  await expect(page.locator("#messageInput")).toHaveValue("");
});

Test Coverage

  • WebSocket Connection: Validates status changes from "Connecting..." to "Connected"
  • UI State: Verifies input/button are enabled after connection
  • Message Flow: Tests complete end-to-end message sending
  • UI Updates: Confirms message appears in messages div and input clears

Screenshots

Initial state showing WebSocket connection:
Initial state

After sending message:
Message sent

Additional Changes

  • Fixed playwright.config.ts to use npm start instead of pnpm start for the webServer command

Quality Assurance

  • ✅ TypeScript compilation passes
  • ✅ All existing unit tests continue to pass (17 tests)
  • ✅ Manual verification confirms both test scenarios work correctly
  • ✅ No application code changes - only test additions

Fixes #42.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits July 10, 2025 06:51
Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copilot AI changed the title [WIP] Expand e2e tests in files/e2e/app.spec.ts for WebSocket and message flow Expand e2e tests for WebSocket connection and message flow validation Jul 10, 2025
Copilot AI requested a review from mahata July 10, 2025 07:02
Comment thread playwright.config.ts Outdated
@mahata mahata marked this pull request as ready for review July 10, 2025 07:09
Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copilot AI requested a review from mahata July 10, 2025 07:14
@mahata
Copy link
Copy Markdown
Owner

mahata commented Jul 10, 2025

@copilot Fix CI in GitHub Actions.

Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 10, 2025

@copilot Fix CI in GitHub Actions.

Fixed the CI configuration by reordering pnpm setup, removing explicit version specification to use package.json's packageManager field, and adding dependency caching. The changes ensure pnpm is properly available for all build steps. (63570fd)

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@mahata
Copy link
Copy Markdown
Owner

mahata commented Jul 10, 2025

@copilot Let's work on it step-by-step. Let's fix CI / test first. Don't think about CI / e2e for now.

Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 10, 2025

@copilot Let's work on it step-by-step. Let's fix CI / test first. Don't think about CI / e2e for now.

Fixed the CI/test job configuration for better reliability:

  • Changed from ubuntu-24.04 to ubuntu-latest for improved compatibility
  • Added explicit cache-dependency-path for pnpm cache optimization
  • Added --frozen-lockfile flag for reproducible builds
  • Fixed linting formatting issue

All tests (17), linting, and build steps pass locally. (44f479e)

Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copilot AI requested a review from mahata July 10, 2025 08:16
Comment thread e2e/app.spec.ts Outdated
await page.goto("/");

// Initially, the status should show "Connecting..."
await expect(page.locator("#status")).toContainText("Connecting...");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot Let's get rid of this line. It seems like the transition from "Connecting..." to "Connected" happens too quickly, which is causing Playwright to miss the original text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the line that checks for "Connecting..." text since the transition to "Connected" happens too quickly for Playwright to reliably catch. The test now directly waits for the "Connected" status, making it more stable. (2147c6f)

Co-authored-by: mahata <23497+mahata@users.noreply.github.com>
Copilot AI requested a review from mahata July 10, 2025 08:29
Copy link
Copy Markdown
Owner

@mahata mahata left a comment

Choose a reason for hiding this comment

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

E2E tests are failing only on GitHub Actions. Fixing it will be done in the upcoming issues.

@mahata mahata merged commit ffc45da into main Jul 11, 2025
1 of 2 checks passed
@mahata mahata deleted the copilot/fix-42 branch July 11, 2025 03:00
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.

Expand e2e tests in files/e2e/app.spec.ts for WebSocket and message flow

2 participants