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: min ui5 version as array #714

Merged
merged 4 commits into from
Jul 24, 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
9 changes: 9 additions & 0 deletions .changeset/unlucky-ants-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"vscode-ui5-language-assistant": patch
"@ui5-language-assistant/test-utils": patch
"@ui5-language-assistant/binding": patch
"@ui5-language-assistant/context": patch
"@ui5-language-assistant/fe": patch
---

fix: support `minUI5Version` as an array
2 changes: 1 addition & 1 deletion packages/binding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"lodash": "4.17.21"
},
"devDependencies": {
"@sap-ux/vocabularies-types": "0.7.4",
"@sap-ux/vocabularies-types": "0.10.14",
"@types/lodash": "4.14.168",
"@ui5-language-assistant/semantic-model-types": "4.0.10",
"@ui5-language-assistant/test-framework": "4.0.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@sap-ux/annotation-converter": "0.5.20",
"@sap-ux/edmx-parser": "0.5.13",
"@sap-ux/project-access": "1.9.1",
"@sap-ux/project-access": "1.25.5",
"@ui5-language-assistant/logger": "0.0.1",
"@ui5-language-assistant/logic-utils": "4.0.18",
"@ui5-language-assistant/settings": "4.0.9",
Expand All @@ -31,7 +31,7 @@
"vscode-uri": "2.1.2"
},
"devDependencies": {
"@sap-ux/vocabularies-types": "0.6.8",
"@sap-ux/vocabularies-types": "0.10.14",
"@types/js-yaml": "4.0.5",
"@types/lodash": "4.14.168",
"@types/node-fetch": "2.5.10",
Expand Down
15 changes: 13 additions & 2 deletions packages/context/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { getCustomViewId, getManifestDetails } from "./manifest";
import { getMinimumUI5Version } from "@sap-ux/project-access";
import {
getCustomViewId,
getManifestDetails,
getUI5Manifest,
} from "./manifest";
import { getServices } from "./services";
import { Context } from "./types";
import { getSemanticModel } from "./ui5-model";
Expand Down Expand Up @@ -37,11 +42,17 @@ export async function getContext(
): Promise<Context | Error> {
try {
const manifestDetails = await getManifestDetails(documentPath);
const manifest = await getUI5Manifest(manifestDetails.manifestPath);
let minUI5Version = manifestDetails.minUI5Version;
if (manifest) {
minUI5Version = getMinimumUI5Version(manifest);
}

const yamlDetails = await getYamlDetails(documentPath);
const ui5Model = await getSemanticModel(
modelCachePath,
yamlDetails.framework,
manifestDetails.minUI5Version
minUI5Version
);
const services = await getServices(documentPath);
const customViewId = await getCustomViewId(documentPath);
Expand Down
2 changes: 1 addition & 1 deletion packages/context/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Manifest } from "@sap-ux/project-access";
import { FetchResponse } from "@ui5-language-assistant/logic-utils";

export const DEFAULT_UI5_FRAMEWORK = "SAPUI5";
export const DEFAULT_UI5_VERSION = "1.71.61";
export const DEFAULT_UI5_VERSION = "1.71.69";
export const DEFAULT_UI5_VERSION_BASE = "1.71";
export const UI5_VERSION_S4_PLACEHOLDER = "${sap.ui5.dist.version}";
export const UI5_FRAMEWORK_CDN_BASE_URL = {
Expand Down
14 changes: 14 additions & 0 deletions packages/context/test/unit/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as services from "../../src/services";
import { UI5SemanticModel } from "@ui5-language-assistant/semantic-model-types";
import { getContext, isContext } from "../../src/api";
import type { Context } from "../../src/types";
import * as projectAccess from "@sap-ux/project-access";

describe("context", () => {
afterEach(() => {
Expand All @@ -13,6 +14,7 @@ describe("context", () => {

describe("getContext", () => {
it("get context", async () => {
// arrange
const getManifestDetailsStub = jest
.spyOn(manifest, "getManifestDetails")
.mockResolvedValue({
Expand All @@ -23,6 +25,14 @@ describe("context", () => {
flexEnabled: false,
minUI5Version: undefined,
});
const getManifestStub = jest
.spyOn(manifest, "getUI5Manifest")
.mockResolvedValue({
minUI5Version: ["2.0.0", "1.126.0"],
});
const getMinimumUI5VersionSub = jest
.spyOn(projectAccess, "getMinimumUI5Version")
.mockReturnValue("1.126.0");
const getCustomViewIdStub = jest
.spyOn(manifest, "getCustomViewId")
.mockResolvedValue("customViewId");
Expand All @@ -38,8 +48,12 @@ describe("context", () => {
const getServicesStub = jest
.spyOn(services, "getServices")
.mockResolvedValue({});
// act
const result = await getContext("path/to/xml/file");
// assert
expect(getManifestDetailsStub).toHaveBeenCalled();
expect(getManifestStub).toHaveBeenCalled();
expect(getMinimumUI5VersionSub).toHaveBeenCalled();
expect(getCustomViewIdStub).toHaveBeenCalled();
expect(getYamlDetailsStub).toHaveBeenCalled();
expect(getSemanticModelStub).toHaveBeenCalled();
Expand Down
2 changes: 1 addition & 1 deletion packages/context/test/unit/ui5-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { Response } from "node-fetch";
const GET_MODEL_TIMEOUT = 30000;
const FRAMEWORK = "SAPUI5";
const OPEN_FRAMEWORK = "OpenUI5";
const FALLBACK_VERSION = "1.71.61";
const FALLBACK_VERSION = "1.71.69";
const FALLBACK_VERSION_BASE = "1.71";
const UI5_VERSION_S4_PLACEHOLDER = "${sap.ui5.dist.version}";
const NO_CACHE_FOLDER = undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/fe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"lodash": "4.17.21"
},
"devDependencies": {
"@sap-ux/vocabularies-types": "0.6.8",
"@sap-ux/vocabularies-types": "0.10.14",
"@types/lodash": "4.14.168",
"@ui5-language-assistant/semantic-model-types": "4.0.10",
"@ui5-language-assistant/test-framework": "4.0.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/fe/test/unit/utils/metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
getRootElements,
} from "../../../src/utils";

const entityContainer: EntityContainer = {
const entityContainer = {
_type: "EntityContainer",
annotations: {},
fullyQualifiedName: "TravelService.EntityContainer",
name: "EntityContainer",
};
} as EntityContainer;
const bookingEntityType: EntityType = {
_type: "EntityType",
name: "Booking",
Expand Down
4 changes: 2 additions & 2 deletions packages/fe/test/unit/utils/path.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
} from "../../../src/utils";

describe("path utils (exotic cases to achieve full code coverage)", () => {
const entityContainer: EntityContainer = {
const entityContainer = {
_type: "EntityContainer",
annotations: {},
fullyQualifiedName: "TravelService.EntityContainer",
name: "EntityContainer",
};
} as EntityContainer;
const bookingEntityType: EntityType = {
_type: "EntityType",
name: "Booking",
Expand Down
Loading
Loading