Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
taefi authored Jan 10, 2025
2 parents 31fe0c0 + f7b7546 commit 69a524e
Show file tree
Hide file tree
Showing 644 changed files with 70,204 additions and 44,497 deletions.
2 changes: 1 addition & 1 deletion .c8rc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"reporter": ["lcov"],
"report-dir": "./.coverage"
"report-dir": ".coverage"
}
6 changes: 3 additions & 3 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: npm
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: 'temurin'
cache: maven
- name: Cache node_modules
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-node_modules
with:
path: |
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defaults:

on:
push:
branches: [ main, '24.4', '2.5', '1.5', '1.4', '1.3' ]
branches: [ main, '24.6', '24.5', '24.4', '2.5', '1.5', '1.4' ]
paths-ignore:
- 'hilla-logo.svg'
- 'README.md'
Expand Down Expand Up @@ -207,9 +207,9 @@ jobs:
include:
- os: ubuntu-latest
it-modules: group-1
- os: windows-latest
- os: ubuntu-latest
it-modules: group-2
- os: windows-latest
- os: ubuntu-latest
it-modules: some
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -291,6 +291,8 @@ jobs:
TB_LICENSE=${{secrets.TB_LICENSE}}
mkdir -p ~/.vaadin/
echo '{"username":"'`echo $TB_LICENSE | cut -d / -f1`'","proKey":"'`echo $TB_LICENSE | cut -d / -f2`'"}' > ~/.vaadin/proKey
- name: publish plugin to Maven Local
run: ./packages/java/gradle-plugin/gradlew --info -p packages/java/gradle-plugin build publishToMavenLocal -x functionalTest
- name: Test gradle-plugin's functional tests
run: ./packages/java/gradle-plugin/gradlew --info -p packages/java/gradle-plugin functionalTest
- name: Gradle ITs
Expand Down
6 changes: 4 additions & 2 deletions .mocharc.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const { join } = require('node:path');
const {pathToFileURL} = require("node:url");
const isCI = !!process.env.CI;

const karmaMochaConfig = {
forbidOnly: isCI,
};

const root = pathToFileURL(`${__dirname}/`);

module.exports = {
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'tsx'],
import: join(__dirname, 'scripts/hooks.js'),
import: new URL('scripts/hooks.js', root),
exit: true,
karmaMochaConfig,
...karmaMochaConfig,
Expand Down
43 changes: 43 additions & 0 deletions karma-context.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<!--
This is the execution context.
Loaded within the iframe.
Reloaded before every execution run.
-->
<html>
<head>
<title>Foo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
</head>
<body>
<!-- The scripts need to be in the body DOM element, as some test running frameworks need the body
to have already been created so they can insert their magic into it. For example, if loaded
before body, Angular Scenario test framework fails to find the body and crashes and burns in
an epic manner. -->
<script src="context.js"></script>
<script type="text/javascript">
// Configure our Karma and set up bindings
%CLIENT_CONFIG%
window.__karma__.setupContext(window);

// All served files with the latest timestamps
%MAPPINGS%
</script>
<script type="module">
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
</script>
<!-- Dynamically replaced with <script> tags -->
%SCRIPTS%
<!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
This ensures all the tests will have been declared before karma tries to run them. -->
<script type="module">
window.__karma__.loaded();
</script>
<script nomodule>
window.__karma__.loaded();
</script>
</body>
</html>
45 changes: 45 additions & 0 deletions karma-debug.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!doctype html>
<!--
This file is almost the same as context.html - loads all source files,
but its purpose is to be loaded in the main frame (not within an iframe),
just for immediate execution, without reporting to Karma server.
-->
<html>
<head>
%X_UA_COMPATIBLE%
<title>Karma DEBUG RUNNER</title>
<link href="favicon.ico" rel="icon" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
</head>
<body>
<!-- The scripts need to be at the end of body, so that some test running frameworks
(Angular Scenario, for example) need the body to be loaded so that it can insert its magic
into it. If it is before body, then it fails to find the body and crashes and burns in an epic
manner. -->
<script src="context.js"></script>
<script src="debug.js"></script>
<script type="text/javascript">
// Configure our Karma
%CLIENT_CONFIG%

// All served files with the latest timestamps
%MAPPINGS%
</script>
<script type="module">
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
</script>
<!-- Dynamically replaced with <script> tags -->
%SCRIPTS%
<!-- Since %SCRIPTS% might include modules, the `loaded()` call needs to be in a module too.
This ensures all the tests will have been declared before karma tries to run them. -->
<script type="module">
window.__karma__.loaded();
</script>
<script nomodule>
window.__karma__.loaded();
</script>
</body>
</html>
51 changes: 40 additions & 11 deletions karma.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable import/unambiguous */
const { parseArgs } = require('node:util');
const { basename, join, resolve } = require('node:path');
const { basename } = require('node:path');
const { readFileSync } = require('node:fs');
const { readFile } = require('node:fs/promises');
const karmaChromeLauncher = require('karma-chrome-launcher');
Expand All @@ -12,16 +13,19 @@ const MagicString = require('magic-string');
const postcss = require('postcss');
const cssnanoPlugin = require('cssnano');
const { karmaMochaConfig } = require('./.mocharc.cjs');
const reactPlugin = require('@vitejs/plugin-react');
const { pathToFileURL, fileURLToPath } = require('node:url');

// The current package, one of the packages in the `packages` dir
const cwd = process.cwd();
const cwd = pathToFileURL(`${process.cwd()}/`);
const root = pathToFileURL(`${__dirname}/`);

function loadMockConfig() {
try {
const content = readFileSync(join(cwd, 'test/mocks/config.json'), 'utf8');
const content = readFileSync(new URL('test/mocks/config.json', cwd), 'utf8');
return JSON.parse(content);
} catch {
console.log(`No mock files found for ${basename(cwd)}. Skipping...`);
console.log(`No mock files found for ${basename(fileURLToPath(cwd))}. Skipping...`);
return {};
}
}
Expand All @@ -34,7 +38,7 @@ function loadRegisterJs() {
name: 'vite-hilla-register',
async transform(code) {
if (code.includes('__REGISTER__()') && !code.includes('function __REGISTER__')) {
const registerCode = await readFile(resolve(cwd, '../../../scripts/register.js'), 'utf8').then((c) =>
const registerCode = await readFile(new URL('scripts/register.js', root), 'utf8').then((c) =>
c.replace('export', ''),
);

Expand Down Expand Up @@ -101,11 +105,11 @@ const watch = !!_watch && !isCI;

module.exports = (config) => {
const mocks = loadMockConfig();
const tsconfig = JSON.parse(readFileSync(join(cwd, 'tsconfig.json'), 'utf8'));
const packageJson = JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf8'));
const tsconfig = JSON.parse(readFileSync(new URL('tsconfig.json', cwd), 'utf8'));
const packageJson = JSON.parse(readFileSync(new URL('package.json', cwd), 'utf8'));

config.set({
basePath: cwd,
basePath: fileURLToPath(cwd),

plugins: [karmaVite, karmaMocha, karmaChromeLauncher, karmaCoverage, karmaSpecReporter, karmaViewport],
middleware: ['vite'],
Expand All @@ -119,6 +123,10 @@ module.exports = (config) => {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-setuid-sandbox'],
},
ChromeNoSS: {
base: 'Chrome',
flags: ['-disable-search-engine-choice-screen'],
},
},

frameworks: ['mocha', 'vite', 'viewport'],
Expand Down Expand Up @@ -161,11 +169,31 @@ module.exports = (config) => {
useDefineForClassFields: false,
},
},
supported: {
decorators: false,
'top-level-await': true,
},
},
plugins: [loadRegisterJs(), constructCss()],
plugins: [
loadRegisterJs(),
constructCss(),
reactPlugin({
include: '**/*.tsx',
babel: {
plugins: [
[
'module:@preact/signals-react-transform',
{
mode: 'all',
},
],
],
},
}),
],
resolve: {
alias: Object.entries(mocks).map(([find, file]) => {
const replacement = join(cwd, `test/mocks/${file}`);
const replacement = fileURLToPath(new URL(`test/mocks/${file}`, cwd));

return {
customResolver(_, importer) {
Expand All @@ -186,7 +214,8 @@ module.exports = (config) => {
client: {
mocha: karmaMochaConfig,
},

customContextFile: fileURLToPath(new URL('karma-context.html', root)),
customDebugFile: fileURLToPath(new URL('karma-debug.html', root)),
// Viewport configuration
viewport: {
breakpoints: [
Expand Down
Loading

0 comments on commit 69a524e

Please sign in to comment.