-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8331258
commit a7a0e0e
Showing
13 changed files
with
200 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default function vitestDefaults(opt?: { | ||
projectRoot?: string, | ||
dynamicData?: boolean, | ||
}): any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { execSync } from "child_process"; | ||
import { existsSync, readdirSync, readFileSync } from "fs"; | ||
import { basename, join, resolve } from "path"; | ||
import { fileURLToPath } from 'url'; | ||
import { defineConfig, } from "vitest/config"; | ||
|
||
const testUtils = resolve(join(fileURLToPath(new URL('.', import.meta.url)), './')); | ||
const serenityRoot = resolve(join(testUtils, "../../")); | ||
|
||
export default (opt) => { | ||
|
||
if ((opt?.dynamicData ?? true) && | ||
!existsSync(`${testUtils}/dynamic-data/Columns.Administration.Language.json`) && | ||
!existsSync(resolve(`./dynamic-data/Columns.Administration.Language.json`))) { | ||
if (resolve("./").indexOf('Serene.Web') >= 0 || !tryProject(`${serenityRoot}/..`, "StartSharp")) | ||
tryProject(`${serenityRoot}/serene`, "Serene"); | ||
} | ||
|
||
const provide = {}; | ||
if (opt?.dynamicData ?? true) { | ||
for (var folder of [join(testUtils, "dynamic-data"), join(opt?.projectRoot ?? resolve("./"), "dynamic-data")]) { | ||
if (existsSync(folder)) { | ||
for (var file of readdirSync(folder)) { | ||
if (file.endsWith(".json")) { | ||
provide["dynamic-data/" + basename(file)] = readFileSync(join(folder, file), "utf8"); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return defineConfig({ | ||
test: { | ||
environment: "jsdom", | ||
globals: true, | ||
alias: [ | ||
{ find: "@serenity-is/corelib", replacement: `${testUtils}/../corelib/dist/index.js` }, | ||
{ find: "jsx-dom/min/jsx-dev-runtime", replacement: "jsx-dom/jsx-runtime.js" }, | ||
{ find: "jsx-dom/jsx-dev-runtime", replacement: "jsx-dom/jsx-runtime.js" } | ||
], | ||
provide, | ||
setupFiles: [ | ||
"test-utils/vitest-setup.js" | ||
] | ||
} | ||
}); | ||
} | ||
|
||
function tryProject(root, name) { | ||
const target = "net8.0"; | ||
const folder = `${root}/src/${name}.Web`; | ||
const csproj = `${folder}/${name}.Web.csproj`; | ||
if (!existsSync(csproj)) | ||
return false; | ||
|
||
const debugDll = `${folder}/bin/Debug/${target}/${name}.Web.dll`; | ||
const releaseDll = `${folder}/bin/Release/${target}/${name}.Web.dll`; | ||
|
||
let debugExists = existsSync(debugDll); | ||
let releaseExists = !debugExists && existsSync(releaseDll); | ||
if (!debugExists && !releaseExists) | ||
execSync(`dotnet build ${csproj}`, { timeout: 60000 }); | ||
|
||
debugExists = existsSync(debugDll); | ||
releaseExists = !debugExists && existsSync(releaseDll); | ||
if (debugExists || releaseExists) | ||
execSync(`dotnet ${debugExists ? debugDll : releaseDll} dynamic-data`, { | ||
timeout: 60000, | ||
cwd: resolve(".").indexOf(name + ".Web") >= 0 ? resolve("./") : testUtils | ||
}); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
function addCSSEscape(window) { | ||
if ((!window.CSS || !window.CSS.escape)) { | ||
// https://drafts.csswg.org/cssom/#serialize-an-identifier | ||
var cssEscape = function (value) { | ||
if (arguments.length == 0) { | ||
throw new TypeError('`CSS.escape` requires an argument.'); | ||
} | ||
var string = String(value); | ||
var length = string.length; | ||
var index = -1; | ||
var codeUnit; | ||
var result = ''; | ||
var firstCodeUnit = string.charCodeAt(0); | ||
|
||
if ( | ||
// If the character is the first character and is a `-` (U+002D), and | ||
// there is no second character, […] | ||
length == 1 && | ||
firstCodeUnit == 0x002D | ||
) { | ||
return '\\' + string; | ||
} | ||
|
||
while (++index < length) { | ||
codeUnit = string.charCodeAt(index); | ||
// Note: there’s no need to special-case astral symbols, surrogate | ||
// pairs, or lone surrogates. | ||
|
||
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER | ||
// (U+FFFD). | ||
if (codeUnit == 0x0000) { | ||
result += '\uFFFD'; | ||
continue; | ||
} | ||
|
||
if ( | ||
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is | ||
// U+007F, […] | ||
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F || | ||
// If the character is the first character and is in the range [0-9] | ||
// (U+0030 to U+0039), […] | ||
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) || | ||
// If the character is the second character and is in the range [0-9] | ||
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […] | ||
( | ||
index == 1 && | ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 && | ||
firstCodeUnit == 0x002D | ||
) | ||
) { | ||
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point | ||
result += '\\' + codeUnit.toString(16) + ' '; | ||
continue; | ||
} | ||
|
||
// If the character is not handled by one of the above rules and is | ||
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or | ||
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to | ||
// U+005A), or [a-z] (U+0061 to U+007A), […] | ||
if ( | ||
codeUnit >= 0x0080 || | ||
codeUnit == 0x002D || | ||
codeUnit == 0x005F || | ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 || | ||
codeUnit >= 0x0041 && codeUnit <= 0x005A || | ||
codeUnit >= 0x0061 && codeUnit <= 0x007A | ||
) { | ||
// the character itself | ||
result += string.charAt(index); | ||
continue; | ||
} | ||
|
||
// Otherwise, the escaped character. | ||
// https://drafts.csswg.org/cssom/#escape-a-character | ||
result += '\\' + string.charAt(index); | ||
} | ||
return result; | ||
}; | ||
|
||
if (!window.CSS) { | ||
window.CSS = {}; | ||
} | ||
|
||
window.CSS.escape = cssEscape; | ||
} | ||
} | ||
|
||
addCSSEscape(window); | ||
|
||
export {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import vitestDefaults from "test-utils/vitest-defaults"; | ||
|
||
export default { | ||
...vitestDefaults({}) | ||
} |