Skip to content

Commit dfedd53

Browse files
committed
test: Resolve failing tests
1 parent 43c9b31 commit dfedd53

7 files changed

Lines changed: 33 additions & 17 deletions

File tree

src/tools/create_integration_card/create_integration_card.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface CreateIntegrationCardParams {
1515
folderPath: string;
1616
cardType: SupportedCardType;
1717
manifestVersion: string;
18-
destinations: Destination[];
18+
destinations?: Destination[];
1919
};
2020

2121
export async function createIntegrationCard({

src/tools/create_integration_card/schema.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ export const supportedCardTypes = [
1111

1212
export type SupportedCardType = typeof supportedCardTypes[number];
1313

14+
const destinationSchema = z.object({
15+
name: z.string().describe("Name of the destination."),
16+
defaultUrl: z.url().describe("Default URL of the destination."),
17+
});
18+
19+
export type Destination = z.infer<typeof destinationSchema>;
20+
1421
export const inputSchema = {
1522
basePath: z.string()
1623
.describe("Absolute base path for the creation."),
@@ -20,11 +27,7 @@ export const inputSchema = {
2027
cardType: z.enum(supportedCardTypes)
2128
.describe("Type of the Integration Card to create.")
2229
.default("List"),
23-
destinations: z.array(z.object({
24-
name: z.string().describe("Name of the destination."),
25-
defaultUrl: z.url().describe("Default URL of the destination."),
26-
})).describe("List of destinations to be included in the card configuration.")
27-
.default([]),
30+
destinations: z.array(destinationSchema)
31+
.describe("List of destinations to be included in the card configuration.")
32+
.optional(),
2833
};
29-
30-
export type Destination = z.infer<typeof inputSchema.destinations>[number];

test/expected/create_integration_card/common/test/App.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ sap.ui.define(["sap/ui/integration/Host"], async (Host) => {
77
const card = document.getElementById("card");
88
const applyChangesBtn = document.getElementById("applyChangesBtn");
99
const resetBtn = document.getElementById("resetBtn");
10+
const destinations = {
11+
Northwind: "https://services.odata.org/V4/Northwind/Northwind.svc/"
12+
};
1013
const host = new Host({
1114
resolveDestination: function(sDestinationName) {
12-
if (sDestinationName === "Northwind") {
13-
return "https://services.odata.org/V4/Northwind/Northwind.svc/";
15+
if (destinations[sDestinationName]) {
16+
return destinations[sDestinationName];
1417
}
1518

16-
throw new Error("Destination " + sDestinationName + " not found!");
19+
return Promise.reject("Destination " + sDestinationName + " not found!");
1720
},
1821
actions: [
1922
{
@@ -27,6 +30,15 @@ sap.ui.define(["sap/ui/integration/Host"], async (Host) => {
2730
]
2831
});
2932

33+
// Called by the Configuration Editor to show a list of available destinations
34+
host.getDestinations = function() {
35+
return Promise.resolve(Object.entries(destinations).map(([name, url]) => {
36+
return {
37+
name,
38+
};
39+
}));
40+
};
41+
3042
card.host = host.getId();
3143
card.manifest = "../card/manifest.json";
3244

test/expected/create_integration_card/common/test/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ body {
1717
flex-direction: column;
1818
}
1919

20+
.editor-section {
21+
--sapUiIntegrationEditorFormHeight: auto;
22+
}
23+
2024
.button-container {
2125
display: flex;
2226
justify-content: flex-end;

test/lib/tools/create_integration_card/create_integration_card.integration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ supportedCardTypes.forEach((cardType) => {
7777
folderPath,
7878
cardType,
7979
manifestVersion: "1.78.0",
80-
destinations: [],
8180
});
8281
// Normalize paths for snapshot consistency across OSes
8382
const normalizedResult = result.map((filePath) => filePath.replaceAll(path.sep, "/")).sort();

test/lib/tools/create_integration_card/create_integration_card.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ test("createIntegrationCard executes successfully", async (t) => {
110110
folderPath,
111111
cardType: "List",
112112
manifestVersion: "1.78.0",
113-
destinations: [],
113+
destinations: undefined,
114114
});
115115

116116
t.is(mkdirStub.callCount, 4);
@@ -135,6 +135,7 @@ test("createIntegrationCard executes successfully", async (t) => {
135135
t.deepEqual(templateVars, {
136136
cardType: "List",
137137
manifestVersion: "1.78.0",
138+
destinations: undefined,
138139
});
139140
});
140141

@@ -154,7 +155,6 @@ test("Target path already exists", async (t) => {
154155
folderPath,
155156
cardType: "List",
156157
manifestVersion: "1.78.0",
157-
destinations: [],
158158
});
159159
}, {
160160
message:
@@ -177,7 +177,6 @@ test("Error creating target directory", async (t) => {
177177
folderPath,
178178
cardType: "List",
179179
manifestVersion: "1.78.0",
180-
destinations: [],
181180
});
182181
}, {
183182
message:
@@ -201,7 +200,6 @@ test("Invalid manifest version", async (t) => {
201200
folderPath,
202201
cardType: "List",
203202
manifestVersion: invalidManifestVersion,
204-
destinations: [],
205203
});
206204
}, {
207205
message: "The provided manifest version is not valid!",
@@ -220,7 +218,6 @@ test("Error processing template file", async (t) => {
220218
folderPath,
221219
cardType: "List",
222220
manifestVersion: "1.78.0",
223-
destinations: [],
224221
});
225222
}, {
226223
message: `Failed to process template file 'card/manifest.json': ${errorMessage}`,

test/lib/tools/create_integration_card/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ test("create_integration_card tool returns success message on success", async (t
7878
folderPath: "/projects/mycards/mycard".replace(/\//g, path.sep),
7979
cardType: "List",
8080
manifestVersion: "1.78.0",
81+
destinations: undefined,
8182
}]);
8283

8384
const message = `Successfully created Integration Card ${params.cardFolderName} at ${params.basePath}\n` +

0 commit comments

Comments
 (0)