Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use latest ui5 version in case s4 placeholder #738

Merged
merged 3 commits into from
Dec 12, 2024
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
7 changes: 7 additions & 0 deletions .changeset/sweet-doors-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@ui5-language-assistant/context": patch
"vscode-ui5-language-assistant": patch
"@ui5-language-assistant/vscode-ui5-language-assistant-bas-ext": patch
---

fix: use latest ui5 version incase of s4 placeholder
5 changes: 3 additions & 2 deletions packages/context/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "./manifest";
import { finAdpdManifestPath } from "./adp-manifest";
import { getServices } from "./services";
import { Context } from "./types";
import { Context, UI5_VERSION_S4_PLACEHOLDER } from "./types";
import { getSemanticModel } from "./ui5-model";
import { getYamlDetails } from "./ui5-yaml";
import { getViewFiles } from "./utils/view-files";
Expand Down Expand Up @@ -51,7 +51,8 @@ export async function getContext(
let manifestPath = manifestDetails.manifestPath;
const manifest = await getUI5Manifest(manifestPath);
let minUI5Version = manifestDetails.minUI5Version;
if (manifest) {
// if minUi5Version is not S4 placeholder, get it from manifest
if (minUI5Version !== UI5_VERSION_S4_PLACEHOLDER && manifest) {
minUI5Version = getMinimumUI5Version(manifest);
}

Expand Down
84 changes: 82 additions & 2 deletions packages/context/test/unit/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as viewFiles from "../../src/utils/view-files";
import * as controlIds from "../../src/utils/control-ids";
import { UI5SemanticModel } from "@ui5-language-assistant/semantic-model-types";
import { getContext, isContext } from "../../src/api";
import type { Context } from "../../src/types";
import { UI5_VERSION_S4_PLACEHOLDER, type Context } from "../../src/types";
import * as projectAccess from "@sap-ux/project-access";
import { OPEN_FRAMEWORK } from "@ui5-language-assistant/constant";

Expand Down Expand Up @@ -69,7 +69,87 @@ describe("context", () => {
expect(getMinimumUI5VersionSub).toHaveBeenCalled();
expect(getCustomViewIdStub).toHaveBeenCalled();
expect(getYamlDetailsStub).toHaveBeenCalled();
expect(getSemanticModelStub).toHaveBeenCalled();
expect(getSemanticModelStub).toHaveBeenCalledWith(
undefined,
"OpenUI5",
"1.126.0"
);
expect(getServicesStub).toHaveBeenCalled();
expect(finAdpdManifestPathStub).toHaveBeenCalled();
expect(getViewFilesStub).toHaveBeenCalled();
expect(getControlIdsStub).toHaveBeenCalled();
expect(result).toContainAllKeys([
"services",
"manifestDetails",
"yamlDetails",
"customViewId",
"ui5Model",
"viewFiles",
"controlIds",
"documentPath",
]);
});
it("get context - when minUI5Version is '${sap.ui5.dist.version}'", async () => {
// arrange
const getManifestDetailsStub = jest
.spyOn(manifest, "getManifestDetails")
.mockResolvedValue({
appId: "",
manifestPath: "",
mainServicePath: "/",
customViews: {},
flexEnabled: false,
minUI5Version: UI5_VERSION_S4_PLACEHOLDER,
});
const getManifestStub = jest
.spyOn(manifest, "getUI5Manifest")
.mockResolvedValue({
minUI5Version: UI5_VERSION_S4_PLACEHOLDER,
});
const getMinimumUI5VersionSub = jest.spyOn(
projectAccess,
"getMinimumUI5Version"
);
const getCustomViewIdStub = jest
.spyOn(manifest, "getCustomViewId")
.mockResolvedValue("customViewId");
const getYamlDetailsStub = jest
.spyOn(ui5Yaml, "getYamlDetails")
.mockResolvedValue({
framework: OPEN_FRAMEWORK,
version: undefined,
});
const getSemanticModelStub = jest
.spyOn(ui5Model, "getSemanticModel")
.mockResolvedValue({} as UI5SemanticModel);
const getServicesStub = jest
.spyOn(services, "getServices")
.mockResolvedValue({});
const finAdpdManifestPathStub = jest
.spyOn(adpManifest, "finAdpdManifestPath")
.mockResolvedValue("/path/to/app/variant");
const getViewFilesStub = jest
.spyOn(viewFiles, "getViewFiles")
.mockResolvedValue({});
const getControlIdsStub = jest
.spyOn(controlIds, "getControlIds")
.mockReturnValue(new Map());
// act
const result = await getContext(
"path/to/xml/file",
"test-model-cache-path"
);
// assert
expect(getManifestDetailsStub).toHaveBeenCalled();
expect(getManifestStub).toHaveBeenCalled();
expect(getMinimumUI5VersionSub).not.toHaveBeenCalled();
expect(getCustomViewIdStub).toHaveBeenCalled();
expect(getYamlDetailsStub).toHaveBeenCalled();
expect(getSemanticModelStub).toHaveBeenCalledWith(
"test-model-cache-path",
"OpenUI5",
UI5_VERSION_S4_PLACEHOLDER
);
expect(getServicesStub).toHaveBeenCalled();
expect(finAdpdManifestPathStub).toHaveBeenCalled();
expect(getViewFilesStub).toHaveBeenCalled();
Expand Down
Loading