Skip to content

Commit 4f9cda0

Browse files
authored
SDA-3937 FOUC fix (#1629)
* SDA-3937 FOUC fix * SDA-3937 FOUC fix for title bar on Windows * SDA-3937 FOUC fix for title bar on Windows * SDA-3937 FOUC fix for title bar on Windows
1 parent 7279351 commit 4f9cda0

17 files changed

+585
-285
lines changed

.vscode/launch.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@
7676
"outFiles": ["${workspaceFolder}/lib/**/*.js"]
7777
},
7878
{
79-
"name": "st2",
79+
"name": "st3",
8080
"type": "node",
8181
"request": "launch",
8282
"cwd": "${workspaceFolder}",
8383
"runtimeExecutable": "${workspaceFolder}/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron",
8484
"windows": {
8585
"runtimeExecutable": "${workspaceFolder}/node_modules/electron/dist/Electron.exe"
8686
},
87-
"args": [".", "--url=https://st2.symphony.com"],
87+
"args": [".", "--url=https://st3.symphony.com"],
8888
"env": {
8989
"ELECTRON_DEBUGGING": "true",
9090
"ELECTRON_DEV": "true"
@@ -94,7 +94,7 @@
9494
"outFiles": ["${workspaceFolder}/lib/**/*.js"]
9595
},
9696
{
97-
"name": "st2 (Build & Run)",
97+
"name": "st3 (Build & Run)",
9898
"type": "node",
9999
"request": "launch",
100100
"cwd": "${workspaceFolder}",
@@ -103,7 +103,7 @@
103103
"runtimeExecutable": "${workspaceFolder}/node_modules/electron/dist/Electron.exe"
104104
},
105105
"preLaunchTask": "build",
106-
"args": [".", "--url=https://st2.symphony.com"],
106+
"args": [".", "--url=https://st3.symphony.com"],
107107
"env": {
108108
"ELECTRON_DEBUGGING": "true",
109109
"ELECTRON_DEV": "true"

gulpfile.js

+51-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ const sourcemaps = require('gulp-sourcemaps');
55
const tsc = require('gulp-typescript');
66
const del = require('del');
77
const path = require('path');
8-
8+
const replace = require('gulp-replace');
9+
const template = require('gulp-template');
10+
const tap = require('gulp-tap');
11+
const rename = require('gulp-rename');
912
const tsProject = tsc.createProject('./tsconfig.json');
1013

1114
gulp.task('clean', function () {
@@ -35,6 +38,49 @@ gulp.task('less', function () {
3538
.pipe(gulp.dest(path.join(__dirname, 'lib/src')));
3639
});
3740

41+
const extractFileNameFromPath = (filePath) => {
42+
const basename = path.basename(filePath);
43+
const filename = basename.split('.');
44+
return filename[0];
45+
};
46+
47+
gulp.task('templates', () => {
48+
return (
49+
gulp
50+
.src('./lib/src/renderer/components/*.js', { base: './lib' })
51+
// tap into the stream to get the current file and compile
52+
// the template according to that
53+
.pipe(
54+
tap(function (file) {
55+
const jsFilename = extractFileNameFromPath(file.path);
56+
return gulp
57+
.src('./src/renderer/react-window.html')
58+
.pipe(
59+
template({
60+
sourcefile: file.path,
61+
}),
62+
)
63+
.pipe(
64+
replace(
65+
/(<link rel="stylesheet" href="*"[^>]*>)/g,
66+
function (_s, _match) {
67+
const cssFilePath = `lib/src/renderer/styles/${jsFilename}.css`;
68+
const doesFileExist = fs.existsSync(cssFilePath);
69+
if (doesFileExist) {
70+
const style = fs.readFileSync(cssFilePath, 'utf8');
71+
return '<style>\n' + style + '\n</style>';
72+
}
73+
return '';
74+
},
75+
),
76+
)
77+
.pipe(rename(`${jsFilename}.html`))
78+
.pipe(gulp.dest('./lib/src/renderer'));
79+
}),
80+
)
81+
);
82+
});
83+
3884
/**
3985
* Copy all assets to JS codebase
4086
*/
@@ -91,4 +137,7 @@ gulp.task('setExpiry', function (done) {
91137
});
92138
});
93139

94-
gulp.task('build', gulp.series('clean', 'compile', 'less', 'copy'));
140+
gulp.task(
141+
'build',
142+
gulp.series('clean', 'compile', 'less', 'templates', 'copy'),
143+
);

jest-config.json

+17-27
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
{
2-
"roots": [
3-
"<rootDir>/spec"
4-
],
2+
"roots": ["<rootDir>/spec"],
53
"transform": {
6-
"^.+\\.tsx?$": "ts-jest"
4+
"^.+\\.tsx?$": "ts-jest",
5+
"^.+\\.svg$": "<rootDir>/svgTransform.js"
76
},
87
"testRegex": "(test|spec)\\.tsx?$",
9-
"moduleFileExtensions": [
10-
"ts",
11-
"tsx",
12-
"js",
13-
"jsx",
14-
"json",
15-
"node"
16-
],
8+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
179
"verbose": true,
1810
"collectCoverage": true,
19-
"coverageReporters": [
20-
"text",
21-
"html"
22-
],
11+
"coverageReporters": ["text", "html"],
2312
"coverageDirectory": "dist/coverage",
2413
"collectCoverageFrom": [
2514
"src/**/*.{ts,tsx}",
@@ -28,17 +17,18 @@
2817
],
2918
"reporters": [
3019
"default",
31-
["./node_modules/jest-html-reporter", {
32-
"pageTitle": "Symphony Electron Test Result",
33-
"includeFailureMsg": true,
34-
"includeConsoleLog": true,
35-
"theme": "lightTheme",
36-
"sort": "status",
37-
"outputPath": "./dist/coverage/UnitTestsReport.html"
38-
}]
39-
],
40-
"setupFiles": [
41-
"./spec/setup/test-setup.js"
20+
[
21+
"./node_modules/jest-html-reporter",
22+
{
23+
"pageTitle": "Symphony Electron Test Result",
24+
"includeFailureMsg": true,
25+
"includeConsoleLog": true,
26+
"theme": "lightTheme",
27+
"sort": "status",
28+
"outputPath": "./dist/coverage/UnitTestsReport.html"
29+
}
30+
]
4231
],
32+
"setupFiles": ["./spec/setup/test-setup.js"],
4333
"snapshotSerializers": ["enzyme-to-json/serializer"]
4434
}

0 commit comments

Comments
 (0)