Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:OfficeDev/TeamsFx into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
huimiu committed Jun 19, 2024
2 parents b29cc5c + 7df24cf commit a73012f
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ describe("Local Debug M365 Tests", function () {
);
await localDebugTestContext.validateLocalStateForTab();
await validateReactTab(page, Env.displayName, true);
const url = page.url();
const pattern =
/https:\/\/teams\.microsoft\.com\/_#\/apps\/(.*)\/sections\/index.*/;
const result = url.match(pattern);
const internalId = result![1];
const m365AppId = await localDebugTestContext.getM365AppId();
await page.goto(
`https://outlook.office.com/host/${internalId}/index?login_hint=${Env.username}`
`https://outlook.office.com/host/${m365AppId}/index?login_hint=${Env.username}`
);
await validateReactOutlookTab(page, Env.displayName, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ describe("Local Debug M365 Tests", function () {
);
await localDebugTestContext.validateLocalStateForTab();
await validateReactTab(page, Env.displayName, true);
const url = page.url();
const pattern =
/https:\/\/teams\.microsoft\.com\/_#\/apps\/(.*)\/sections\/index.*/;
const result = url.match(pattern);
const internalId = result![1];
const m365AppId = await localDebugTestContext.getM365AppId();
await page.goto(
`https://outlook.office.com/host/${internalId}/index?login_hint=${Env.username}`
`https://outlook.office.com/host/${m365AppId}/index?login_hint=${Env.username}`
);
await validateReactOutlookTab(page, Env.displayName, true);
}
Expand Down
18 changes: 18 additions & 0 deletions packages/tests/src/ui-test/localdebug/localdebugContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ export class LocalDebugTestContext extends TestContext {
return result;
}

public async getM365AppId(): Promise<string> {
const userDataFile = path.join(
TestFilePath.configurationFolder,
`.env.local`
);
const configFilePath = path.resolve(
this.testRootFolder,
this.appName,
userDataFile
);
const context = dotenvUtil.deserialize(
await fs.readFile(configFilePath, { encoding: "utf8" })
);
const result = context.obj.M365_APP_ID as string;
console.log(`M365 APP ID: ${result}`);
return result;
}

public async createProject(): Promise<void> {
if (this.needMigrate) {
await execCommand(this.testRootFolder, `set TEAMSFX_V3=false`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@ class ContactExporterTestCase extends CaseFactory {
sampledebugContext: SampledebugContext,
teamsAppId: string
): Promise<Page> {
return await reopenPage(
sampledebugContext.context!,
teamsAppId,
Env.username,
Env.password,
undefined,
true,
true
);
return await reopenPage(sampledebugContext.context!, teamsAppId);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ import { Page } from "playwright";
import { TemplateProject, LocalDebugTaskLabel } from "../../utils/constants";
import { validateNpm } from "../../utils/playwrightOperation";
import { CaseFactory } from "./sampleCaseFactory";
import { SampledebugContext } from "./sampledebugContext";

class NpmSearchTestCase extends CaseFactory {
override async onValidate(
page: Page,
options?: { npmName: string }
options?: { npmName: string; context: SampledebugContext }
): Promise<void> {
return await validateNpm(page, { npmName: options?.npmName });
return await validateNpm(page, {
npmName: options?.npmName,
appName: options?.context.appName.substring(0, 10) || "",
});
}

override async onCliValidate(
page: Page,
options?: { npmName: string }
options?: { npmName: string; context: SampledebugContext }
): Promise<void> {
return await validateNpm(page, { npmName: options?.npmName });
return await validateNpm(page, {
npmName: options?.npmName,
appName: options?.context.appName.substring(0, 10) || "",
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ import { Page } from "playwright";
import { TemplateProject } from "../../utils/constants";
import { validateNpm } from "../../utils/playwrightOperation";
import { CaseFactory } from "./sampleCaseFactory";
import { SampledebugContext } from "./sampledebugContext";

class NpmSearchTestCase extends CaseFactory {
override async onValidate(
page: Page,
options?: { npmName: string }
options?: { npmName: string; context: SampledebugContext }
): Promise<void> {
return await validateNpm(page, { npmName: options?.npmName });
}

override async onCliValidate(
page: Page,
options?: { npmName: string }
): Promise<void> {
return await validateNpm(page, { npmName: options?.npmName });
return await validateNpm(page, {
npmName: options?.npmName,
appName: options?.context.appName.substring(0, 10) || "",
});
}
}

Expand All @@ -32,5 +29,5 @@ new NpmSearchTestCase(
"[email protected]",
"dev",
[],
{ npmName: "axios", debug: "ttk" }
{ npmName: "axios" }
).test();
Loading

0 comments on commit a73012f

Please sign in to comment.