Skip to content

Commit

Permalink
test: distinguish describe name & fix quota limited (#10338)
Browse files Browse the repository at this point in the history
* test: distinguish describe name

* test: fix quota limited

---------

Co-authored-by: v-ivanchen_microsoft <v-ivanchen@microsoft.com>
  • Loading branch information
ayachensiyuan and v-ivanchen_microsoft authored Nov 14, 2023
1 parent c28270f commit 2117a23
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 34 deletions.
30 changes: 20 additions & 10 deletions packages/tests/src/e2e/commonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,26 @@ export async function setProvisionParameterValue(
return fs.writeJSON(parametersFilePath, parameters, { spaces: 4 });
}

export async function setBotSkuNameToB1Bicep(
projectPath: string,
filePath = ""
) {
const azureParametersFilePathSuffix = filePath
? path.join(filePath)
: path.join("infra", "azure.parameters.json");
const azureParametersFilePath = path.resolve(
projectPath,
azureParametersFilePathSuffix
);
const ProvisionParameters = await fs.readJSON(azureParametersFilePath);
ProvisionParameters["parameters"]["provisionParameters"]["value"][
"botWebAppSKU"
] = "B1";
return fs.writeJSON(azureParametersFilePath, ProvisionParameters, {
spaces: 4,
});
}

export async function setSimpleAuthSkuNameToB1(projectPath: string) {
const envFilePath = path.resolve(projectPath, envFilePathSuffix);
const context = await fs.readJSON(envFilePath);
Expand Down Expand Up @@ -201,16 +221,6 @@ export async function setBotSkuNameToB1(projectPath: string) {
return fs.writeJSON(envFilePath, context, { spaces: 4 });
}

export async function setBotSkuNameToB1Bicep(
projectPath: string,
envName: string
): Promise<void> {
return setProvisionParameterValue(projectPath, envName, {
key: "webAppSKU",
value: "B1",
});
}

export async function setSkipAddingSqlUser(projectPath: string) {
const envFilePath = path.resolve(projectPath, envFilePathSuffix);
const context = await fs.readJSON(envFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { TemplateProjectFolder } from "../../utils/constants";
import { CaseFactory } from "./sampleCaseFactory";
import { Executor } from "../../utils/executor";
import { setBotSkuNameToB1Bicep } from "../commonUtils";

class ProactiveMessagingTestCase extends CaseFactory {
public override async onCreate(
Expand All @@ -24,6 +25,13 @@ class ProactiveMessagingTestCase extends CaseFactory {
);
}

override async onBeforeProvision(projectPath: string): Promise<void> {
await setBotSkuNameToB1Bicep(
projectPath,
"templates/azure/azure.parameters.dev.json"
);
}

override async onAfterCreate(projectPath: string): Promise<void> {
return Promise.resolve();
}
Expand Down
4 changes: 3 additions & 1 deletion packages/tests/src/e2e/samples/ProvisionShareNow.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import { TemplateProjectFolder } from "../../utils/constants";
import { CaseFactory } from "./sampleCaseFactory";
import * as path from "path";
import { editDotEnvFile } from "../commonUtils";
import { editDotEnvFile, setBotSkuNameToB1Bicep } from "../commonUtils";
import { getUuid } from "../../commonlib/utilities";

class ShareNowTestCase extends CaseFactory {
override async onBeforeProvision(projectPath: string): Promise<void> {
// fix quota issue
await setBotSkuNameToB1Bicep(projectPath);
const envFilePath = path.resolve(projectPath, "env", ".env.dev.user");
editDotEnvFile(envFilePath, "SQL_USER_NAME", "Abc123321");
editDotEnvFile(
Expand Down
2 changes: 1 addition & 1 deletion packages/tests/src/e2e/samples/sampleCaseFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export abstract class CaseFactory {
onBeforeProvision,
onCreate,
} = this;
describe("Sample Tests", function () {
describe(`Sample Tests: ${sampleName}`, function () {
const testFolder = getTestFolder();
const appName = getUniqueAppName();
const projectPath = path.resolve(testFolder, appName);
Expand Down
35 changes: 14 additions & 21 deletions packages/tests/src/ui-test/remotedebug/remotedebugContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import * as fs from "fs-extra";
import * as path from "path";
import * as os from "os";
import { TestContext } from "../testContext";
import {
CommandPaletteCommands,
Expand Down Expand Up @@ -110,14 +109,6 @@ export async function setSimpleAuthSkuNameToB1(projectPath: string) {
context[simpleAuthPluginName]["skuName"] = "B1";
return fs.writeJSON(envFilePath, context, { spaces: 4 });
}
export async function setBotSkuNameToB1(projectPath: string) {
const botPluginName = "fx-resource-bot";
const envFilePathSuffix = path.join(".fx", "env.default.json");
const envFilePath = path.resolve(projectPath, envFilePathSuffix);
const context = await fs.readJSON(envFilePath);
context[botPluginName]["skuName"] = "B1";
return fs.writeJSON(envFilePath, context, { spaces: 4 });
}

export async function setSkuNameToB1(projectPath: string) {
const parameters = "parameters";
Expand Down Expand Up @@ -159,20 +150,22 @@ export async function setSimpleAuthSkuNameToB1Bicep(

export async function setBotSkuNameToB1Bicep(
projectPath: string,
envName: string
filePath = ""
) {
const ConfigFolderName = "fx";
const InputConfigsFolderName = "configs";
const bicepParameterFile = path.join(
`.${ConfigFolderName}`,
InputConfigsFolderName,
`azure.parameters.${envName}.json`
const azureParametersFilePathSuffix = filePath
? path.join(filePath)
: path.join("infra", "azure.parameters.json");
const azureParametersFilePath = path.resolve(
projectPath,
azureParametersFilePathSuffix
);
const parametersFilePath = path.resolve(projectPath, bicepParameterFile);
const parameters = await fs.readJSON(parametersFilePath);
parameters["parameters"]["provisionParameters"]["value"]["botWebAppSKU"] =
"B1";
return fs.writeJSON(parametersFilePath, parameters, { spaces: 4 });
const ProvisionParameters = await fs.readJSON(azureParametersFilePath);
ProvisionParameters["parameters"]["provisionParameters"]["value"][
"botWebAppSKU"
] = "B1";
return fs.writeJSON(azureParametersFilePath, ProvisionParameters, {
spaces: 4,
});
}

export async function inputSqlUserName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { validateShareNow } from "../../utils/playwrightOperation";
import { CaseFactory } from "./sampleCaseFactory";
import { AzSqlHelper } from "../../utils/azureCliHelper";
import { SampledebugContext } from "./sampledebugContext";
import * as uuid from "uuid";
import { expect } from "chai";
import * as path from "path";
import { editDotEnvFile } from "../../utils/commonUtils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,26 @@ import { Page } from "playwright";
import { TemplateProject } from "../../utils/constants";
import { validateProactiveMessaging } from "../../utils/playwrightOperation";
import { CaseFactory } from "./sampleCaseFactory";
import { AzSqlHelper } from "../../utils/azureCliHelper";
import { SampledebugContext } from "./sampledebugContext";
import { setBotSkuNameToB1Bicep } from "../remotedebug/remotedebugContext";

class ProactiveMessagingTestCase extends CaseFactory {
override async onValidate(page: Page): Promise<void> {
return await validateProactiveMessaging(page);
}

override async onAfterCreate(
sampledebugContext: SampledebugContext,
env: "local" | "dev",
azSqlHelper?: AzSqlHelper | undefined
): Promise<void> {
// fix quota issue
await setBotSkuNameToB1Bicep(
sampledebugContext.projectPath,
"templates/azure/azure.parameters.dev.json"
);
}
}

new ProactiveMessagingTestCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as uuid from "uuid";
import * as fs from "fs";
import * as path from "path";
import { editDotEnvFile } from "../../utils/commonUtils";
import { setBotSkuNameToB1Bicep } from "../remotedebug/remotedebugContext";

class ShareNowTestCase extends CaseFactory {
public sqlUserName: string;
Expand Down Expand Up @@ -52,7 +53,11 @@ class ShareNowTestCase extends CaseFactory {
const password = this.sqlPassword;
editDotEnvFile(envFilePath, "SQL_USER_NAME", user);
editDotEnvFile(envFilePath, "SQL_PASSWORD", password);

// fix quota issue
await setBotSkuNameToB1Bicep(sampledebugContext.projectPath);
};

public override onBeforeBrowerStart = async (
sampledebugContext: SampledebugContext
): Promise<void> => {
Expand Down

0 comments on commit 2117a23

Please sign in to comment.