Skip to content

Commit

Permalink
test: fix ui test (#12567)
Browse files Browse the repository at this point in the history
* test: fix todolist sql test

* test: fix large notification bot case

---------

Co-authored-by: Ivan_Chen <v-ivanchen@microsoft.com>
  • Loading branch information
ayachensiyuan and Ivan_Chen authored Oct 22, 2024
1 parent 1911def commit dc2ed64
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 85 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ui-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ jobs:
AZURE_SUBSCRIPTION_NAME: ${{ secrets.TEST_SUBSCRIPTION_NAME }}
AZURE_ACCOUNT_NAME: ${{ secrets.TEST_USER_NAME }}
AZURE_ACCOUNT_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
STORAGE_ACCOUNT_KEY: ${{ secrets.TEST_STORAGE_ACCOUNT_KEY }}

AZURE_OPENAI_DEPLOYMENT_NAME: "gpt-4-32k"
AZURE_OPENAI_ENDPOINT: "https://aoai-jasozdr.openai.azure.com/"
Expand Down
4 changes: 2 additions & 2 deletions packages/tests/scripts/randomCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"bot-upgrade-debug",
"sample-remotedebug-todo-list-with-spfx",
"sample-remotedebug-todo-list-with-m365",
"sample-localdebug-react-retail-dashboard",
"sample-localdebug-spfx-productivity-dashboard",
"sample-remotedebug-react-retail-dashboard",
"sample-remotedebug-spfx-productivity-dashboard",
Expand Down Expand Up @@ -131,7 +130,8 @@
"basic-tab-provision-upgrade-provision-debug",
"bot-provision-upgrade-provision-debug",
"sample-localdebug-todo-list-with-spfx",
"sample-localdebug-todo-list-with-m365"
"sample-localdebug-todo-list-with-m365",
"sample-localdebug-react-retail-dashboard"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ class LargeNotiTestCase extends CaseFactory {
fs.writeFileSync(envFile, envFileString);
console.log(`add endpoint ${envFileString} to .env.${env} file`);

// add storage account key
const envUserFile = path.resolve(
sampledebugContext.projectPath,
"env",
`.env.${env}.user`
);
let envUserFileString = fs.readFileSync(envUserFile, "utf-8");
envUserFileString += `\nSECRET_STORAGE_ACCOUNT_KEY=${process.env["STORAGE_ACCOUNT_KEY"]}`;
fs.writeFileSync(envUserFile, envUserFileString);
console.log(
`add SECRET_STORAGE_ACCOUNT_KEY ${process.env["STORAGE_ACCOUNT_KEY"]} to .env.${env}.user file`
);

// add connect string into local.setting.json
const configFilePath = path.resolve(
sampledebugContext.projectPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class TodoListBackendTestCase extends CaseFactory {
teamsAppId: string,
options?: {
teamsAppName: string;
type: string;
}
): Promise<Page> {
return await initTeamsPage(
Expand All @@ -84,6 +85,7 @@ class TodoListBackendTestCase extends CaseFactory {
Env.password,
{
teamsAppName: options?.teamsAppName,
type: options?.type,
}
);
}
Expand All @@ -110,6 +112,7 @@ class TodoListBackendTestCase extends CaseFactory {
Env.password,
{
teamsAppName: options?.teamsAppName,
type: options?.type,
}
);
}
Expand All @@ -123,7 +126,7 @@ new TodoListBackendTestCase(
[LocalDebugTaskLabel.StartFrontend, LocalDebugTaskLabel.StartBackend],
{
teamsAppName: "toDoList-local",
skipValidation: false,
testRootFolder: path.resolve(os.homedir(), "resourse"), // fix eslint error
type: "spfx",
}
).test();
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class TodoListBackendTestCase extends CaseFactory {
teamsAppId: string,
options?: {
teamsAppName: string;
type: string;
}
): Promise<Page> {
return await initTeamsPage(
Expand All @@ -118,6 +119,7 @@ class TodoListBackendTestCase extends CaseFactory {
Env.password,
{
teamsAppName: options?.teamsAppName,
type: options?.type,
}
);
}
Expand All @@ -134,7 +136,7 @@ new TodoListBackendTestCase(
[],
{
teamsAppName: "toDoList-dev",
skipValidation: false,
testRootFolder: path.resolve(os.homedir(), "resourse"), // fix eslint error
type: "spfx",
}
).test();
84 changes: 3 additions & 81 deletions packages/tests/src/utils/playwrightOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,46 +198,7 @@ export async function initPage(
}
}

// dashboard template will have a popup
if (options?.dashboardFlag) {
console.log("Before popup");
const [popup] = await Promise.all([
page
.waitForEvent("popup")
.then((popup) =>
popup
.waitForEvent("close", {
timeout: Timeout.playwrightConsentPopupPage,
})
.catch(() => popup)
)
.catch(() => {}),
addBtn?.click(),
]);
console.log("after popup");

if (popup && !popup?.isClosed()) {
// input password
console.log(`fill in password`);
await popup.fill(
"input.input[type='password'][name='passwd']",
password
);
// sign in
await Promise.all([
popup.click("input.button[type='submit'][value='Sign in']"),
popup.waitForNavigation(),
]);
await popup.click("input.button[type='submit'][value='Accept']");
try {
await popup?.close();
} catch (error) {
console.log("popup is closed");
}
}
} else {
await addBtn?.click();
}
await addBtn?.click();
await page.waitForTimeout(Timeout.shortTimeLoading);
// verify add page is closed
try {
Expand Down Expand Up @@ -347,46 +308,7 @@ export async function reopenPage(
}
}

// dashboard template will have a popup
if (options?.dashboardFlag && password) {
console.log("Before popup");
const [popup] = await Promise.all([
page
.waitForEvent("popup")
.then((popup) =>
popup
.waitForEvent("close", {
timeout: Timeout.playwrightConsentPopupPage,
})
.catch(() => popup)
)
.catch(() => {}),
addBtn?.click(),
]);
console.log("after popup");

if (popup && !popup?.isClosed()) {
// input password
console.log(`fill in password`);
await popup.fill(
"input.input[type='password'][name='passwd']",
password
);
// sign in
await Promise.all([
popup.click("input.button[type='submit'][value='Sign in']"),
popup.waitForNavigation(),
]);
await popup.click("input.button[type='submit'][value='Accept']");
try {
await popup?.close();
} catch (error) {
console.log("popup is closed");
}
}
} else {
await addBtn?.click();
}
await addBtn?.click();
await page.waitForTimeout(Timeout.shortTimeLoading);
console.log("[success] app loaded");
// verify add page is closed
Expand Down Expand Up @@ -2395,7 +2317,7 @@ export async function validateBasicDashboardTab(page: Page) {
export async function validateDashboardTab(page: Page) {
try {
console.log("start to verify dashboard tab");
await page.waitForTimeout(Timeout.shortTimeLoading);
await page.waitForTimeout(Timeout.longTimeWait);
const frameElementHandle = await page.waitForSelector(
`iframe[name="embedded-page-container"]`
);
Expand Down

0 comments on commit dc2ed64

Please sign in to comment.