Skip to content

Commit

Permalink
fix: ut
Browse files Browse the repository at this point in the history
  • Loading branch information
anchenyi committed Sep 27, 2024
1 parent ca3549a commit c69040a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1506,5 +1506,77 @@ describe("teamsApp/createAppPackage", async () => {
chai.assert.isTrue(result.error instanceof InvalidFileOutsideOfTheDirectotryError);
}
});

it("zip same level dir", async () => {
const args: CreateAppPackageArgs = {
manifestPath:
"./tests/plugins/resource/appstudio/resources-multi-env/templates/appPackage/v3.manifest.template.json",
outputZipPath:
"./tests/plugins/resource/appstudio/resources-multi-env/build/appPackage/appPackage.dev.zip",
outputFolder: "./tests/plugins/resource/appstudio/resources-multi-env/build/appPackage",
};

const manifest = new TeamsAppManifest();
manifest.composeExtensions = [
{
composeExtensionType: "apiBased",
apiSpecificationFile: "resources/openai.yml",
commands: [
{
id: "GET /repairs",
apiResponseRenderingTemplateFile: "resources/repairs.json",
title: "fake",
},
],
botId: "",
},
];
manifest.icons = {
color: "resources/color.png",
outline: "resources/outline.png",
};
manifest.localizationInfo = {
defaultLanguageTag: "en",
additionalLanguages: [
{
languageTag: "de",
file: "de.json",
},
],
defaultLanguageFile: "de.json",
};
sinon.stub(manifestUtils, "getManifestV3").resolves(ok(manifest));

sinon.stub(fs, "chmod").callsFake(async () => {});
const writeFileStub = sinon.stub(fs, "writeFile").callsFake(async () => {});

const result = (await teamsAppDriver.execute(args, mockedDriverContext)).result;
chai.assert(result.isOk());
chai.assert(writeFileStub.calledOnce);
if (await fs.pathExists(args.outputZipPath)) {
const zip = new AdmZip(args.outputZipPath);

let openapiContent = "";

const entries = zip.getEntries();
for (const e of entries) {
const name = e.entryName;

if (name.endsWith("openai.yml")) {
const data = e.getData();
openapiContent = data.toString("utf8");
break;
}
}

chai.assert(
openapiContent != undefined &&
openapiContent.length > 0 &&
openapiContent.search(fakeUrl) >= 0 &&
openapiContent.search(openapiServerPlaceholder) < 0
);
await fs.remove(args.outputZipPath);
}
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.12/MicrosoftTeams.Localization.schema.json",
"name.short": "Name App",
"name.full": "Name App",
"description.short": "Description Short Deutsch",
"description.full": "Description Long Deutsch",
"staticTabs[0].name": "Home"
}

0 comments on commit c69040a

Please sign in to comment.