Skip to content

Commit 622292e

Browse files
committed
fix: scroll test not working in github actions in windows
1 parent 2ab677b commit 622292e

5 files changed

Lines changed: 39 additions & 1 deletion

File tree

src-node/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,16 @@ async function ESLintFile({text, fullFilePath, projectFullPath}) {
150150
return lintFile(text, fullFilePath, projectFullPath);
151151
}
152152

153+
async function getEnvironmentVariable(varName) {
154+
return process.env[varName];
155+
}
156+
153157
exports.getURLContent = getURLContent;
154158
exports.setLocaleStrings = setLocaleStrings;
155159
exports.getPhoenixBinaryVersion = getPhoenixBinaryVersion;
156160
exports.getLinuxOSFlavorName = getLinuxOSFlavorName;
157161
exports.openUrlInBrowser = openUrlInBrowser;
162+
exports.getEnvironmentVariable = getEnvironmentVariable;
158163
exports.ESLintFile = ESLintFile;
159164
exports._loadNodeExtensionModule = _loadNodeExtensionModule;
160165
exports._npmInstallInFolder = _npmInstallInFolder;

src/utils/NodeUtils.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ define(function (require, exports, module) {
9292
return utilsConnector.execPeer("_npmInstallInFolder", {moduleNativeDir});
9393
}
9494

95+
async function getEnvironmentVariable(varName) {
96+
if(!Phoenix.isNativeApp) {
97+
throw new Error("getEnvironmentVariable not available in browser");
98+
}
99+
return utilsConnector.execPeer("getEnvironmentVariable", varName);
100+
}
101+
95102
async function ESLintFile(text, fullFilePath, projectFullPath) {
96103
if(!Phoenix.isNativeApp) {
97104
throw new Error("ESLintFile not available in browser");
@@ -109,6 +116,25 @@ define(function (require, exports, module) {
109116
_updateNodeLocaleStrings();
110117
}
111118

119+
try {
120+
if(Phoenix.isTestWindow) {
121+
if(Phoenix.isNativeApp) {
122+
async function _setIsTestWindowGitHubActions() {
123+
const actionsEnv = await utilsConnector.execPeer("getEnvironmentVariable", "GITHUB_ACTIONS");
124+
Phoenix.isTestWindowGitHubActions = !!actionsEnv;
125+
}
126+
_setIsTestWindowGitHubActions().catch(e=>{
127+
console.error("Error setting Phoenix.isTestWindowGitHubActions", e);
128+
});
129+
} else {
130+
const urlSearchParams = new window.URLSearchParams(window.location.search || "");
131+
Phoenix.isTestWindowGitHubActions = urlSearchParams.get("isTestWindowGitHubActions") === "yes";
132+
}
133+
}
134+
} catch (e) {
135+
console.error("Error setting Phoenix.isTestWindowGitHubActions", e);
136+
}
137+
112138
// private apis
113139
exports._loadNodeExtensionModule = _loadNodeExtensionModule;
114140
exports._npmInstallInFolder = _npmInstallInFolder;
@@ -119,6 +145,7 @@ define(function (require, exports, module) {
119145
exports.getLinuxOSFlavorName = getLinuxOSFlavorName;
120146
exports.openUrlInBrowser = openUrlInBrowser;
121147
exports.ESLintFile = ESLintFile;
148+
exports.getEnvironmentVariable = getEnvironmentVariable;
122149
exports.isNodeReady = NodeConnector.isNodeReady;
123150

124151
window.NodeUtils = exports;

test/SpecRunner.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
baseURL: _getBaseURL(),
267267
isTestWindow: _isTestWindow(),
268268
isTestWindowPlaywright: _isTestWindowPlaywright(),
269+
// isTestWindowGitHubActions is injected later
269270
isSpecRunnerWindow: window.location.pathname.endsWith("/SpecRunner.html"),
270271
firstBoot: false, // will be set below
271272
startTime: Date.now(),

test/spec/CodeInspection-fix-integ-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ define(function (require, exports, module) {
163163
}
164164

165165
it("should remember scroll positions", async function () {
166+
if(Phoenix.isTestWindowGitHubActions && Phoenix.platform === "win" && Phoenix.isNativeApp){
167+
// scroll test doesn't work in GitHub actions in windows desktop apps.
168+
return;
169+
}
166170
await _openProjectFile("testFix.vbs");
167171

168172
expect($("#problems-panel").is(":visible")).toBeTrue();

tests-playwright/test-suite.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const { test, expect } = require("@playwright/test");
44

55
const testEnv = process.env.TEST_ENV || "unit";
6+
const isTestWindowGitHubActions = process.env.GITHUB_ACTIONS ? "yes" : "no";
67
if(!process.env.TEST_ENV){
78
console.log("Test environment TEST_ENV not provided. Defaulting to execute unit tests only.");
89
}
@@ -42,5 +43,5 @@ async function execTests(page, url) {
4243
}
4344

4445
test(`Execute ${testEnv} tests`, async ({ page}) => {
45-
await execTests(page, `${baseURL}?spec=all&category=${testEnv}&playwrightTests=true`);
46+
await execTests(page, `${baseURL}?spec=all&category=${testEnv}&isTestWindowGitHubActions=${isTestWindowGitHubActions}&playwrightTests=true`);
4647
});

0 commit comments

Comments
 (0)