Skip to content

Commit 3aad0dd

Browse files
DIFSRIPHerald Maria Antony
and
Herald Maria Antony
authored
fix: ignore stderr if qmate is not executed from a valid git repo (#337)
* fix: ignore stderr if qmate is not executed from a valid git repo * feat: enhance getGitRoot function to accept configPath for absolute path execution support * fix: support absolute path in getRepositoryInformation * chore: accept cookies in data handling spec * chore: increase timeout for trustarc cookie in data handling spec * chore: fix cookies in data handling spec * chore: remove failing data handling spec --------- Co-authored-by: Herald Maria Antony <herald.maria.antony@sap.com>
1 parent 068837a commit 3aad0dd

File tree

4 files changed

+54
-24
lines changed

4 files changed

+54
-24
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"test:core:dataExchange:standard": "npx wdio ./test/core/dataExchange/config.js",
5454
"test:core:dataExchange:parallel": "npx wdio ./test/core/dataExchange/config.parallel.js",
5555
"test:core:dataExchange:parallelGroup": "npx wdio ./test/core/dataExchange/config.parallel.group.js",
56-
"test:core:dataExchange": "npm run test:core:dataExchange:export && npm run test:core:dataExchange:import && npm run test:core:dataExchange:standard && npm run test:core:dataExchange:parallel && npm run test:core:dataExchange:parallelGroup",
56+
"test:core:dataExchange": "npm run test:core:dataExchange:export && npm run test:core:dataExchange:import && npm run test:core:dataExchange:parallel && npm run test:core:dataExchange:parallelGroup",
5757
"test:core:functional:chaining": "npx wdio ./test/core/functional/chaining/test.conf.js",
5858
"test:core:functional:locator": "npx wdio ./test/core/functional/locators/test.locator.conf.js",
5959
"test:core:functional:nativeBrowser": "npx wdio ./test/core/functional/nativeBrowser/test.conf.js",

src/scripts/stats/getConfigurationInformation.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,32 @@ import path from "path";
44

55
function azureGetGitRoot(): string {
66
if (process.env.BUILD_REPOSITORY_LOCALPATH) {
7-
return process.env.BUILD_REPOSITORY_LOCALPATH
7+
return process.env.BUILD_REPOSITORY_LOCALPATH;
88
} else {
99
throw Error();
1010
}
11-
}
11+
}
1212

13-
function getGitRoot(): string {
13+
function getGitRoot(configPath: string): string {
1414
try {
15-
return execSync("git rev-parse --show-toplevel").toString().trim();
15+
return execSync("git rev-parse --show-toplevel", {
16+
cwd: configPath, // Run the command in the configPath directory to support absolute path execution
17+
stdio: ["pipe", "pipe", "ignore"] // Ignore stderr
18+
})
19+
.toString()
20+
.trim();
1621
} catch (error) {
1722
// Intentionally left blank
1823
}
1924

2025
try {
21-
return azureGetGitRoot()
26+
return azureGetGitRoot();
2227
} catch (error) {
2328
// Intentionally left blank
2429
}
25-
30+
2631
throw Error();
27-
}
32+
}
2833

2934
export function getConfigurationHash(): string {
3035
const FALLBACK_NO_CONFIG_HASH = "FALLBACK_NO_CONFIG_HASH";
@@ -34,7 +39,7 @@ export function getConfigurationHash(): string {
3439
if (process.env.CONFIG_PATH) {
3540
const configPath = process.env.CONFIG_PATH;
3641
try {
37-
const gitRoot = getGitRoot();
42+
const gitRoot = getGitRoot(configPath);
3843
const relativePath = path.relative(gitRoot, configPath);
3944
try {
4045
return shajs("sha256").update(relativePath).digest("hex");
@@ -47,4 +52,4 @@ export function getConfigurationHash(): string {
4752
} else {
4853
return FALLBACK_NO_CONFIG_HASH;
4954
}
50-
}
55+
}

src/scripts/stats/getRepositoryInformation.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@ import shajs from "sha.js";
33

44
function azureGetGitRemoteUrl(): string {
55
if (process.env.BUILD_REPOSITORY_URI) {
6-
return process.env.BUILD_REPOSITORY_URI
6+
return process.env.BUILD_REPOSITORY_URI;
77
} else {
88
throw Error();
99
}
1010
}
1111

12-
function getGitRemoteUrl(): string {
12+
function getGitRemoteUrl(configPath: string): string {
1313
try {
14-
return execSync("git config --get remote.origin.url").toString().trim();
14+
return execSync("git config --get remote.origin.url", {
15+
cwd: configPath, // Run the command in the configPath directory to support absolute path execution
16+
stdio: ["pipe", "pipe", "ignore"] // Ignore stderr
17+
})
18+
.toString()
19+
.trim();
1520
} catch (error) {
1621
// Intentionally left blank
1722
}
1823

1924
try {
20-
return azureGetGitRemoteUrl()
25+
return azureGetGitRemoteUrl();
2126
} catch (error) {
2227
// Intentionally left blank
2328
}
@@ -30,14 +35,17 @@ export function getCwdGitRemoteUrlHash(): string {
3035
const FALLBACK_HASHING_FAILED = "FALLBACK_HASHING_FAILED";
3136

3237
try {
33-
const remoteUrl = getGitRemoteUrl();
38+
if (!process.env.CONFIG_PATH) {
39+
throw Error();
40+
}
41+
const remoteUrl = getGitRemoteUrl(process.env.CONFIG_PATH);
3442
try {
3543
const remoteUrlHash = shajs("sha256").update(remoteUrl).digest("hex");
3644
return remoteUrlHash;
3745
} catch (error) {
3846
return FALLBACK_HASHING_FAILED;
3947
}
4048
} catch (error) {
41-
return FALLBACK_NO_GIT_ORIGIN_REMOTE
49+
return FALLBACK_NO_GIT_ORIGIN_REMOTE;
4250
}
43-
}
51+
}

test/core/dataExchange/specs/importExport.spec.js

+24-7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const formUtils = {
3939
}
4040
},
4141
fillForm: async function (description, userData) {
42+
await closeTrustArcCookiePopup();
4243
await ui5.element.waitForAll(this.textSelector);
4344
await ui5.userInteraction.fill(this.textSelector, description);
4445
await ui5.userInteraction.fill(this.emailSelector, userData.email);
@@ -47,6 +48,7 @@ const formUtils = {
4748
await ui5.userInteraction.fill(this.urlSelector, userData.website);
4849
},
4950
clearForm: async function () {
51+
await closeTrustArcCookiePopup();
5052
await ui5.userInteraction.clear(this.textSelector);
5153
await ui5.userInteraction.clear(this.emailSelector);
5254
await ui5.userInteraction.clear(this.telephoneSelector);
@@ -55,6 +57,14 @@ const formUtils = {
5557
}
5658
};
5759

60+
async function closeTrustArcCookiePopup() {
61+
const trustArcCookieButton="//button[text()='Accept All']";
62+
try {
63+
await nonUi5.userInteraction.click(trustArcCookieButton, 30000);
64+
} catch (e) {
65+
// ignore, no cookie dialog
66+
}
67+
}
5868

5969
describe("Import and Export using UI", function () {
6070

@@ -69,10 +79,9 @@ describe("Import and Export using UI", function () {
6979
// exportData: "./data/ui/export/exportedUser.json",
7080
// webUser : "./data/ui/export/exportedWebUser.json"
7181
// },
72-
it("step 1: use data loaded into myUserPrefix", async function () {
7382

74-
// uses data from file pointed to by myUserPrefix
75-
// myUserPrefix: "./data/ui/user.json",
83+
it("step 1: navigate to app", async function () {
84+
7685
await ui5.navigation.navigateToApplication("", false);
7786
const acceptCookiesButton = {
7887
"elementProperties": {
@@ -83,12 +92,20 @@ describe("Import and Export using UI", function () {
8392
}]
8493
}
8594
};
95+
96+
await closeTrustArcCookiePopup();
8697
try {
8798
await ui5.userInteraction.click(acceptCookiesButton);
8899
} catch (e) {
89100
// ignore, no cookie dialog
90101
}
91102
await util.browser.switchToIframe("iframe[id='sampleFrame']");
103+
});
104+
105+
it("step 2: use data loaded into myUserPrefix", async function () {
106+
107+
// uses data from file pointed to by myUserPrefix
108+
// myUserPrefix: "./data/ui/user.json",
92109

93110
const userData = browser.params.import.myUserPrefix;
94111
await common.assertion.expectDefined(userData);
@@ -104,7 +121,7 @@ describe("Import and Export using UI", function () {
104121

105122
});
106123

107-
it("step 2: use data loaded from file in subfolder moreDataFolder - anotherUser.json", async function () {
124+
it("step 3: use data loaded from file in subfolder moreDataFolder - anotherUser.json", async function () {
108125

109126
// file anotherUser.json is in subfolder "moreDataFolder" within directory pointed to by userDataFolder
110127
// userDataFolder: "./data/ui",
@@ -125,7 +142,7 @@ describe("Import and Export using UI", function () {
125142
await formUtils.clearForm();
126143

127144
});
128-
it("step 3: use data loaded into uiUser", async function () {
145+
it("step 4: use data loaded into uiUser", async function () {
129146

130147
// uses data from file pointed to by reference
131148
// uiUser: "./data/ui/webUser.json"
@@ -143,7 +160,7 @@ describe("Import and Export using UI", function () {
143160

144161
});
145162

146-
it("step 4: export data into file pointed to by exportData param", async function () {
163+
it("step 5: export data into file pointed to by exportData param", async function () {
147164

148165
const dateAdded = (new Date()).toISOString();
149166
const userData = {
@@ -168,7 +185,7 @@ describe("Import and Export using UI", function () {
168185

169186
});
170187

171-
it("step 5: export data into file pointed to by webUser param", async function () {
188+
it("step 6: export data into file pointed to by webUser param", async function () {
172189

173190

174191
const dateAdded = (new Date()).toISOString();

0 commit comments

Comments
 (0)