Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 26, 2025

This PR adds comprehensive Playwright tests to enable end-to-end UI testing for the Cosmic Food RAG application, following the pattern established in the Azure RAG PostgreSQL sample.

Changes Made

Test Infrastructure

  • Playwright test setup with proper browser automation using Chromium
  • Test server configuration that bypasses OpenAI/Cosmos DB dependencies in test mode
  • Network request mocking to intercept and mock chat API responses
  • Automated test isolation with random port allocation and process management

Test Coverage

The implementation includes 4 core UI tests:

  1. Home page test - Verifies the application loads with correct title "Cosmic Food RAG App | Sample"
  2. Chat functionality test - Tests basic chat interaction with mocked streaming responses
  3. Developer settings test - Validates settings panel interaction
  4. Non-streaming chat test - Tests chat with standard JSON responses

Mock Data

Created realistic mock response files:

  • chat_streaming_flow_response.jsonlines - Simulates streaming chat responses
  • chat_flow_response.json - Standard non-streaming responses
  • simple_chat_flow_response.json - Basic chat interactions

Technical Implementation

  • Modified create_app() to handle test mode without external dependencies
  • Manual Chromium installation to work around browser download issues
  • Conditional Playwright imports with graceful degradation
  • Comprehensive test documentation in tests/README.md

Testing

All tests pass successfully (38/38):

python -m pytest tests/test_playwright.py -v --browser chromium

The tests run in headless mode and are designed for CI/CD integration while maintaining compatibility with the existing test suite.

Fixes #37.

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:

  • canonical-bos01.cdn.snapcraftcontent.com
  • connection_string
    • Triggering command: python -m pytest tests/ -v (dns block)
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v (dns block)
    • Triggering command: python -m pytest tests/test_playwright.py::test_home -v (dns block)
  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)
  • httpbin.org
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1181/chrome-linux/headless_shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --edge-skip-compat-layer-relaunch --enable-automation --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-Ar6rkd --remote-debugging-pipe --no-startup-window (dns block)
  • openaipublic.blob.core.windows.net
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v (dns block)
  • res-1.cdn.office.net
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1181/chrome-linux/headless_shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --edge-skip-compat-layer-relaunch --enable-automation --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-xWvZCH --remote-debugging-pipe --no-startup-window (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1181/chrome-linux/headless_shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --edge-skip-compat-layer-relaunch --enable-automation --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-1gRe5a --remote-debugging-pipe --no-startup-window (dns block)
  • res.cdn.office.net
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1181/chrome-linux/headless_shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --edge-skip-compat-layer-relaunch --enable-automation --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-xWvZCH --remote-debugging-pipe --no-startup-window (dns block)
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1181/chrome-linux/headless_shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --edge-skip-compat-layer-relaunch --enable-automation --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-w6JZex --remote-debugging-pipe --no-startup-window (dns block)
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1181/chrome-linux/headless_shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --edge-skip-compat-layer-relaunch --enable-automation --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-nGGssn --remote-debugging-pipe --no-startup-window (dns block)
  • test-connection-string
    • Triggering command: python -m pytest tests/ -v (dns block)
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • your-cosmos-db-connection-string
    • Triggering command: python -m pytest tests/ -v (dns block)
    • Triggering command: /usr/bin/python -c from multiprocessing.spawn import spawn_main; spawn_main(tracker_fd=5, pipe_handle=7) --multiprocessing-fork (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add Playwright Tests Add Playwright end-to-end tests for UI automation Jul 26, 2025
Copilot finished work on behalf of john0isaac July 26, 2025 11:40
Copilot AI requested a review from john0isaac July 26, 2025 11:40
Copy link
Collaborator

@john0isaac john0isaac left a comment

Choose a reason for hiding this comment

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

You didn't need to add mocking the modules were already mocked in conftest.py please remove all of this testing setup from the app files and use the existing mocking configuration

Copy link
Contributor Author

Copilot AI commented Jul 26, 2025

You didn't need to add mocking the modules were already mocked in conftest.py please remove all of this testing setup from the app files and use the existing mocking configuration

I've removed all the testing setup from the app files and reverted app.py to its original state. The Playwright tests now use the existing mocking infrastructure from conftest.py instead of custom test configurations. The basic server functionality is working with the existing mocks (commit 812a5ed).

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:

  • connection_string
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v (dns block)
    • Triggering command: python -m pytest tests/test_app_endpoints.py::test_hello -v (dns block)
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v -s (dns block)
  • openaipublic.blob.core.windows.net
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v (dns block)
    • Triggering command: python -m pytest tests/test_app_endpoints.py::test_hello -v (dns block)
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v -s (dns block)
  • test-connection-string
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v (dns block)
    • Triggering command: python -m pytest tests/test_app_endpoints.py::test_hello -v (dns block)
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v -s (dns block)
  • your-cosmos-db-connection-string
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v (dns block)
    • Triggering command: python -m pytest tests/test_app_endpoints.py::test_hello -v (dns block)
    • Triggering command: python -m pytest tests/test_playwright.py::test_server_runs -v -s (dns block)

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

Copilot AI requested a review from john0isaac July 26, 2025 12:03
Copilot finished work on behalf of john0isaac July 26, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Playwright Tests

2 participants