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

Copilot Chat: Scenario Tests #1376

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Playwright test init
  • Loading branch information
TaoChenOSU committed Jun 8, 2023
commit e448f5ceb4c0b48816be8bbcf85d2068a941b06b
43 changes: 43 additions & 0 deletions .github/workflows/copilot-chat-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Copilot Chat Tests
adrianwyatt marked this conversation as resolved.
Show resolved Hide resolved
on:
workflow_dispatch:
push:
branches: [ "main", "feature*" ]
paths:
- 'samples/apps/copilot-chat-app/**'
pull_request:
branches: [ "main", "feature*" ]
paths:
- 'samples/apps/copilot-chat-app/**'

jobs:
test:
defaults:
run:
working-directory: samples/apps/copilot-chat-app/webapp
strategy:
matrix:
os: [windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn install
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
env:
REACT_APP_BACKEND_URI: https://localhost:40443/
REACT_APP_AAD_CLIENT_ID: 123
REACT_APP_AAD_AUTHORITY: https://login.microsoftonline.com/common
run: yarn playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
1 change: 1 addition & 0 deletions samples/apps/copilot-chat-app/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@fluentui/react-components": "^9.13.0",
"@fluentui/react-icons": "^2.0.193",
"@fluentui/react-northstar": "^0.66.4",
"@playwright/test": "^1.34.3",
"@reduxjs/toolkit": "^1.9.1",
"debug": "^4.3.4",
"microsoft-cognitiveservices-speech-sdk": "^1.27.0",
Expand Down
64 changes: 64 additions & 0 deletions samples/apps/copilot-chat-app/webapp/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

// Read the .env file if it exists. This is usually for testing locally.
// Tests on CI should should get the environment variables from GitHub actions.
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);
const envPath = path.resolve(dirname, '.env');
if (fs.existsSync(envPath)) {
dotenv.config({ path: envPath });
}

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'yarn start',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
});
13 changes: 13 additions & 0 deletions samples/apps/copilot-chat-app/webapp/tests/login.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect, test } from '@playwright/test';

test('login required', async ({ page }) => {
await page.goto('/');

// Expect the title to be "Copilot Chat".
await expect(page).toHaveTitle("Copilot Chat");

// Expect the page to contain a "Login" button.
await page.getByRole('button').click();
// Clicking the login button should redirect to the login page.
await expect(page).toHaveURL(new RegExp('^'+process.env.REACT_APP_AAD_AUTHORITY));
});
17 changes: 16 additions & 1 deletion samples/apps/copilot-chat-app/webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,16 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@playwright/test@^1.34.3":
version "1.34.3"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.34.3.tgz#d9f1ac3f1a09633b5ca5351c50c308bf802bde53"
integrity sha512-zPLef6w9P6T/iT6XDYG3mvGOqOyb6eHaV9XtkunYs0+OzxBtrPAAaHotc0X+PJ00WPPnLfFBTl7mf45Mn8DBmw==
dependencies:
"@types/node" "*"
playwright-core "1.34.3"
optionalDependencies:
fsevents "2.3.2"

"@pmmmwh/react-refresh-webpack-plugin@^0.5.3":
version "0.5.10"
resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.10.tgz#2eba163b8e7dbabb4ce3609ab5e32ab63dda3ef8"
Expand Down Expand Up @@ -6147,7 +6157,7 @@ fs.realpath@^1.0.0:
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@^2.3.2, fsevents@~2.3.2:
fsevents@2.3.2, fsevents@^2.3.2, fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
Expand Down Expand Up @@ -8667,6 +8677,11 @@ pkg-up@^3.1.0:
dependencies:
find-up "^3.0.0"

playwright-core@1.34.3:
version "1.34.3"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.34.3.tgz#bc906ea1b26bb66116ce329436ee59ba2e78fe9f"
integrity sha512-2pWd6G7OHKemc5x1r1rp8aQcpvDh7goMBZlJv6Co5vCNLVcQJdhxRL09SGaY6HcyHH9aT4tiynZabMofVasBYw==

please-upgrade-node@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942"
Expand Down