Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions webapp/tests/chat.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

/* eslint-disable testing-library/prefer-screen-queries */
import { test } from '@playwright/test';
import * as simpletests from './testsBasic';
Expand Down
2 changes: 2 additions & 0 deletions webapp/tests/testsBasic.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

import { expect } from '@playwright/test';
import * as util from './utils';

Expand Down
2 changes: 2 additions & 0 deletions webapp/tests/testsMultiuser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.

import { expect } from '@playwright/test';
import * as util from './utils';

Expand Down
42 changes: 24 additions & 18 deletions webapp/tests/testsPlanner.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
// Copyright (c) Microsoft. All rights reserved.

import { expect } from '@playwright/test';
import * as util from './utils'
import * as util from './utils';

/*
Summary: Tests if the Copilot Chat can use the Planner with the Klarna plugin,
to generate a plan and execute it. Klarna doesnt require any auth credentials.
*/
export async function klarnaTest(page) {
await util.loginAndCreateNewChat(page);

// Enable Klarna
const pluginIdentifierText = 'Klarna ShoppingKlarnaEnableSearch';
await util.openPluginPopUp(page, pluginIdentifierText);
await util.enablePluginAndClosePopUp(page);

// Try using Klarna by sending a request to the bot and wait for the response.
const klarnaQuery = "Can you get me a list of prices of surface notebooks?";
const klarnaQuery = 'Can you get me a list of prices of surface notebooks?';
await util.sendChatMessageAndWaitForResponse(page, klarnaQuery);
await util.executePlanAndWaitForResponse(page);

// Expect the last message to be the bot's response.
const chatHistoryItems = page.getByTestId(new RegExp('chat-history-item-*'));
await expect(chatHistoryItems.last()).toHaveAttribute('data-username', 'Copilot');

// Specifically accessing the us site of klarna so any results should have a dollar sign
await expect(chatHistoryItems.last()).toContainText('$');

Expand All @@ -40,16 +42,16 @@ export async function jiraTest(page) {

// Enable Jira
await util.openPluginPopUp(page, 'JiraAtlassianEnableAuthorize');

// Enter Auth Credentials and server url
await page.locator('#plugin-email-input').fill(process.env.REACT_APP_TEST_JIRA_EMAIL as string);
await page.locator('#plugin-pat-input').fill(process.env.REACT_APP_TEST_JIRA_ACCESS_TOKEN as string);
await page.getByPlaceholder('Enter the server url').fill(process.env.REACT_APP_TEST_JIRA_SERVER_URL as string);

await util.enablePluginAndClosePopUp(page);

// Try using Jira by sending a request to the bot and wait for it to respond.
const jiraQuery = "Can you Get Issue details about SKTES-1 from jira ?";
const jiraQuery = 'Can you Get Issue details about SKTES-1 from jira ?';
await util.sendChatMessageAndWaitForResponse(page, jiraQuery);
await util.executePlanAndWaitForResponse(page);

Expand All @@ -60,7 +62,7 @@ export async function jiraTest(page) {

var chatbotResponse = await util.getLastChatMessageContentsAsStringWHistory(page, chatHistoryItems);
await util.disablePluginAndEvaluateResponse(page, jiraQuery, chatbotResponse);

await util.postUnitTest(page);
}

Expand All @@ -70,19 +72,23 @@ to generate a plan and execute it. The Github plugin uses a PAT token for auth.
*/
export async function githubTest(page) {
await util.loginAndCreateNewChat(page);

// Enable Github
await util.openPluginPopUp(page, 'GitHubMicrosoftEnableIntegrate');

// Enter Auth Credentials and server url
await page.locator('#plugin-pat-input').fill(process.env.REACT_APP_TEST_GITHUB_ACCESS_TOKEN as string);
await page.getByPlaceholder('Enter the account owner of repository').fill(process.env.REACT_APP_TEST_GITHUB_ACCOUNT_OWNER as string);
await page.getByPlaceholder('Enter the name of repository').fill(process.env.REACT_APP_TEST_GITHUB_REPOSITORY_NAME as string);

await page
.getByPlaceholder('Enter the account owner of repository')
.fill(process.env.REACT_APP_TEST_GITHUB_ACCOUNT_OWNER as string);
await page
.getByPlaceholder('Enter the name of repository')
.fill(process.env.REACT_APP_TEST_GITHUB_REPOSITORY_NAME as string);

await util.enablePluginAndClosePopUp(page);

// Try using Github by sending a request to the bot and wait for it to respond.
const githubQuery = "List the 5 most recent open pull requests";
const githubQuery = 'List the 5 most recent open pull requests';
await util.sendChatMessageAndWaitForResponse(page, githubQuery);
await util.executePlanAndWaitForResponse(page);

Expand All @@ -94,4 +100,4 @@ export async function githubTest(page) {
await util.disablePluginAndEvaluateResponse(page, githubQuery, chatbotResponse);

await util.postUnitTest(page);
}
}
4 changes: 2 additions & 2 deletions webapp/tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function loginHelper(page, useraccount, password) {
// Expect the page to contain a "Login" button.
await page.getByTestId('signinButton').click();
// Clicking the login button should redirect to the login page.
await expect(page).toHaveURL(new RegExp(`${process.env.REACT_APP_AAD_AUTHORITY}.*`));
await page.url().startsWith(process.env.REACT_APP_AAD_AUTHORITY);
// Login with the test user.
await page.getByPlaceholder('Email, phone, or Skype').click();
await page.getByPlaceholder('Email, phone, or Skype').fill(useraccount as string);
Expand All @@ -36,7 +36,7 @@ export async function loginHelperAnotherUser(page, useraccount, password) {
// 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}.*`));
await page.url().startsWith(process.env.REACT_APP_AAD_AUTHORITY);
// Login with the another user account.
await page.getByRole('button', { name: 'Use another account' }).click();
await page.getByPlaceholder('Email, phone, or Skype').click();
Expand Down