kempo-testing-framework 1.2.4 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +105 -105
- package/.github/workflows/publish-npm.yml +41 -0
- package/CONTRIBUTING.md +107 -107
- package/gui/components/Collapsible.js +54 -54
- package/gui/components/Icon.js +151 -151
- package/gui/components/Logs.js +73 -73
- package/gui/components/SettingCheckbox.js +42 -42
- package/gui/components/SettingNumber.js +77 -77
- package/gui/components/SettingSelect.js +67 -67
- package/gui/components/TestFramework.js +378 -378
- package/gui/components/TestSuite.js +181 -181
- package/gui/components/TestSummary.js +189 -189
- package/gui/components/Theme.js +40 -40
- package/gui/components/settingsStore.js +46 -46
- package/gui/icons/fail.svg +1 -1
- package/gui/icons/pass.svg +1 -1
- package/gui/icons/running.svg +1 -1
- package/gui/icons/settings.svg +1 -1
- package/package.json +5 -1
- package/src/browserTestServer.js +115 -115
- package/src/cli.js +198 -198
- package/src/gui.js +15 -2
- package/src/runBrowserTests.js +87 -87
- package/src/runTestFiles.js +94 -94
- package/src/runTests.js +83 -83
- package/src/utils/logLevels.js +7 -7
- package/test.html +30 -30
- package/tests/Counter.js +33 -33
- package/tests/cli-flags.node-test.js +54 -54
- package/tests/cli-help.node-test.js +61 -61
- package/tests/cli-loglevel.node-test.js +40 -40
- package/tests/collapsible.browser-test.js +49 -49
- package/tests/counter.browser-test.js +140 -140
- package/tests/example.node-test.js +103 -103
- package/tests/fibonacci.js +92 -92
- package/tests/fibonacci.test.js +285 -285
- package/tests/icon.browser-test.js +54 -54
- package/tests/logs.browser-test.js +47 -47
- package/tests/setting-checkbox.browser-test.js +48 -48
- package/tests/setting-number.browser-test.js +54 -54
- package/tests/setting-select.browser-test.js +47 -47
- package/tests/settings-store.browser-test.js +26 -26
- package/tests/src-browserTestServer.node-test.js +47 -47
- package/tests/src-cli.node-test.js +32 -32
- package/tests/src-findTests.node-test.js +41 -41
- package/tests/src-logLevels.node-test.js +29 -29
- package/tests/src-runBrowserTests.node-test.js +41 -41
- package/tests/src-runTestFiles.node-test.js +42 -42
- package/tests/src-runTests.node-test.js +56 -56
- package/tests/test-framework.browser-test.js +65 -65
- package/tests/test-summary.browser-test.js +78 -78
- package/tests/test.browser-test.js +56 -56
- package/tests/testfile.browser-test.js +60 -60
- package/tests/theme.browser-test.js +38 -38
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
# Code Contribution Guidelines
|
|
2
|
-
|
|
3
|
-
## Project Structure
|
|
4
|
-
|
|
5
|
-
- All code should be in the `src/` directory, with the exception of index.js.
|
|
6
|
-
- All utility function module files should be in the `src/utils/` directory.
|
|
7
|
-
|
|
8
|
-
### GUI
|
|
9
|
-
|
|
10
|
-
All files served by the GUI should be in the `gui/` directory, with the exception of scripts shared with the CLI, custom endpoints, and node_modules like kempo.css (which should have custom endpoints).
|
|
11
|
-
|
|
12
|
-
## Coding Style Guidelines
|
|
13
|
-
|
|
14
|
-
### Code Organization
|
|
15
|
-
Use multi-line comments to separate code into logical sections. Group related functionality together.
|
|
16
|
-
- Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
/*
|
|
20
|
-
Lifecycle Callbacks
|
|
21
|
-
*/
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Avoid single-use variables/functions
|
|
25
|
-
Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
|
|
26
|
-
- recursion
|
|
27
|
-
- scope encapsulation (IIFE)
|
|
28
|
-
- context changes
|
|
29
|
-
|
|
30
|
-
### Minimal Comments, Empty Lines, and Spacing
|
|
31
|
-
|
|
32
|
-
Use minimal comments. Assume readers understand the language. Some exceptions include:
|
|
33
|
-
- complex logic
|
|
34
|
-
- anti-patterns
|
|
35
|
-
- code organization
|
|
36
|
-
|
|
37
|
-
Do not put random empty lines within code; put them where they make sense for readability, for example:
|
|
38
|
-
- above and below definitions for functions and classes.
|
|
39
|
-
- to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
|
|
40
|
-
- above multi-line comments to indicate the comment belongs to the code below
|
|
41
|
-
|
|
42
|
-
No empty lines in css.
|
|
43
|
-
|
|
44
|
-
End each file with an empty line.
|
|
45
|
-
|
|
46
|
-
End each line with a `;` when possible, even if it is optional.
|
|
47
|
-
|
|
48
|
-
Avoid unnecessary spacing, for example:
|
|
49
|
-
- after the word `if`
|
|
50
|
-
- within parentheses for conditional statements
|
|
51
|
-
|
|
52
|
-
```javascript
|
|
53
|
-
let count = 1;
|
|
54
|
-
|
|
55
|
-
const incrementOdd = (n) => {
|
|
56
|
-
if(n % 2 !== 0){
|
|
57
|
-
return n++;
|
|
58
|
-
}
|
|
59
|
-
return n;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
count = incrementOdd(count);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Prefer Arrow Functions
|
|
66
|
-
Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
|
|
67
|
-
- For very basic logic, use implicit returns
|
|
68
|
-
- If there is a single parameter, omit the parentheses.
|
|
69
|
-
```javascript
|
|
70
|
-
const addOne = n => n + 1;
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Module Exports
|
|
74
|
-
- If a module has only one export, use the "default" export, not a named export.
|
|
75
|
-
- Do not declare the default export as a const or give it a name; just export the value.
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
export default (n) => n + 1;
|
|
79
|
-
```
|
|
80
|
-
- If a module has multiple exports, use named exports and do not use a "default" export.
|
|
81
|
-
|
|
82
|
-
### Code Reuse
|
|
83
|
-
Create utility functions for shared logic.
|
|
84
|
-
- If the shared logic is used in a single file, define a utility function in that file.
|
|
85
|
-
- If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
|
|
86
|
-
|
|
87
|
-
### Naming
|
|
88
|
-
Do not prefix identifiers with underscores.
|
|
89
|
-
- Never use leading underscores (`_`) for variable, property, method, or function names.
|
|
90
|
-
- Use clear, descriptive names without prefixes.
|
|
91
|
-
- When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
|
|
92
|
-
|
|
93
|
-
## Lit Components
|
|
94
|
-
|
|
95
|
-
### Component Architecture and Communication
|
|
96
|
-
|
|
97
|
-
- Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
|
|
98
|
-
- Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
|
|
99
|
-
|
|
100
|
-
- Wrap dependent GUI components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
|
|
101
|
-
|
|
102
|
-
- Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
|
|
103
|
-
|
|
104
|
-
- Queued status must show the `scheduled` icon. Running may apply `animation="spin"`.
|
|
105
|
-
|
|
1
|
+
# Code Contribution Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
4
|
+
|
|
5
|
+
- All code should be in the `src/` directory, with the exception of index.js.
|
|
6
|
+
- All utility function module files should be in the `src/utils/` directory.
|
|
7
|
+
|
|
8
|
+
### GUI
|
|
9
|
+
|
|
10
|
+
All files served by the GUI should be in the `gui/` directory, with the exception of scripts shared with the CLI, custom endpoints, and node_modules like kempo.css (which should have custom endpoints).
|
|
11
|
+
|
|
12
|
+
## Coding Style Guidelines
|
|
13
|
+
|
|
14
|
+
### Code Organization
|
|
15
|
+
Use multi-line comments to separate code into logical sections. Group related functionality together.
|
|
16
|
+
- Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
/*
|
|
20
|
+
Lifecycle Callbacks
|
|
21
|
+
*/
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Avoid single-use variables/functions
|
|
25
|
+
Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
|
|
26
|
+
- recursion
|
|
27
|
+
- scope encapsulation (IIFE)
|
|
28
|
+
- context changes
|
|
29
|
+
|
|
30
|
+
### Minimal Comments, Empty Lines, and Spacing
|
|
31
|
+
|
|
32
|
+
Use minimal comments. Assume readers understand the language. Some exceptions include:
|
|
33
|
+
- complex logic
|
|
34
|
+
- anti-patterns
|
|
35
|
+
- code organization
|
|
36
|
+
|
|
37
|
+
Do not put random empty lines within code; put them where they make sense for readability, for example:
|
|
38
|
+
- above and below definitions for functions and classes.
|
|
39
|
+
- to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
|
|
40
|
+
- above multi-line comments to indicate the comment belongs to the code below
|
|
41
|
+
|
|
42
|
+
No empty lines in css.
|
|
43
|
+
|
|
44
|
+
End each file with an empty line.
|
|
45
|
+
|
|
46
|
+
End each line with a `;` when possible, even if it is optional.
|
|
47
|
+
|
|
48
|
+
Avoid unnecessary spacing, for example:
|
|
49
|
+
- after the word `if`
|
|
50
|
+
- within parentheses for conditional statements
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
let count = 1;
|
|
54
|
+
|
|
55
|
+
const incrementOdd = (n) => {
|
|
56
|
+
if(n % 2 !== 0){
|
|
57
|
+
return n++;
|
|
58
|
+
}
|
|
59
|
+
return n;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
count = incrementOdd(count);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Prefer Arrow Functions
|
|
66
|
+
Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
|
|
67
|
+
- For very basic logic, use implicit returns
|
|
68
|
+
- If there is a single parameter, omit the parentheses.
|
|
69
|
+
```javascript
|
|
70
|
+
const addOne = n => n + 1;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Module Exports
|
|
74
|
+
- If a module has only one export, use the "default" export, not a named export.
|
|
75
|
+
- Do not declare the default export as a const or give it a name; just export the value.
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
export default (n) => n + 1;
|
|
79
|
+
```
|
|
80
|
+
- If a module has multiple exports, use named exports and do not use a "default" export.
|
|
81
|
+
|
|
82
|
+
### Code Reuse
|
|
83
|
+
Create utility functions for shared logic.
|
|
84
|
+
- If the shared logic is used in a single file, define a utility function in that file.
|
|
85
|
+
- If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
|
|
86
|
+
|
|
87
|
+
### Naming
|
|
88
|
+
Do not prefix identifiers with underscores.
|
|
89
|
+
- Never use leading underscores (`_`) for variable, property, method, or function names.
|
|
90
|
+
- Use clear, descriptive names without prefixes.
|
|
91
|
+
- When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
|
|
92
|
+
|
|
93
|
+
## Lit Components
|
|
94
|
+
|
|
95
|
+
### Component Architecture and Communication
|
|
96
|
+
|
|
97
|
+
- Use methods to cause actions; do not emit events to trigger logic. Events are for notifying that something already happened.
|
|
98
|
+
- Prefer `el.closest('ktf-test-framework')?.enqueueSuite({...})` over firing an `enqueue` event.
|
|
99
|
+
|
|
100
|
+
- Wrap dependent GUI components inside a parent `ktf-test-framework` element. Children find it via `closest('ktf-test-framework')` and call its methods. The framework can query its subtree to orchestrate children.
|
|
101
|
+
|
|
102
|
+
- Avoid `window` globals and global custom events for coordination. If broadcast is needed, scope events to the framework element; reserve window events for global, non-visual concerns (e.g., settings changes).
|
|
103
|
+
|
|
104
|
+
- Queued status must show the `scheduled` icon. Running may apply `animation="spin"`.
|
|
105
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
name: Publish Package to npmjs
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
id-token: write # enables npm provenance
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
# Setup Node and create an .npmrc that uses the token from NODE_AUTH_TOKEN
|
|
20
|
+
- uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: '20.x'
|
|
23
|
+
registry-url: 'https://registry.npmjs.org'
|
|
24
|
+
|
|
25
|
+
- run: npm ci
|
|
26
|
+
|
|
27
|
+
# Auto-increment patch version, commit, and push
|
|
28
|
+
- name: Bump patch version
|
|
29
|
+
run: |
|
|
30
|
+
git config --global user.name "github-actions"
|
|
31
|
+
git config --global user.email "github-actions@github.com"
|
|
32
|
+
npm version patch --no-git-tag-version
|
|
33
|
+
git add package.json package-lock.json || true
|
|
34
|
+
git commit -m "ci: bump patch version [skip ci]" || echo "No changes to commit"
|
|
35
|
+
git push origin HEAD:main || echo "No changes to push"
|
|
36
|
+
|
|
37
|
+
# If your package is public and scoped (e.g., @scope/name), keep --access public.
|
|
38
|
+
# For unscoped public packages, you can omit --access.
|
|
39
|
+
- run: npm publish --provenance --access public
|
|
40
|
+
env:
|
|
41
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
# Code Contribution Guidelines
|
|
2
|
-
|
|
3
|
-
## Project Structure
|
|
4
|
-
|
|
5
|
-
- All code should be in the `src/` directory, with the exception of index.js.
|
|
6
|
-
- All utility function module files should be in the `src/utils/` directory.
|
|
7
|
-
|
|
8
|
-
### GUI
|
|
9
|
-
|
|
10
|
-
All files served by the GUI should be in the `gui/` directory, with the exception of scripts shared with the CLI, custom endpoints, and node_modules like kempo.css (which should have custom endpoints).
|
|
11
|
-
|
|
12
|
-
## Coding Style Guidelines
|
|
13
|
-
|
|
14
|
-
### Code Organization
|
|
15
|
-
Use multi-line comments to separate code into logical sections. Group related functionality together.
|
|
16
|
-
- Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
/*
|
|
20
|
-
Lifecycle Callbacks
|
|
21
|
-
*/
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Avoid single-use variables/functions
|
|
25
|
-
Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
|
|
26
|
-
- recursion
|
|
27
|
-
- scope encapsulation (IIFE)
|
|
28
|
-
- context changes
|
|
29
|
-
|
|
30
|
-
### Minimal Comments, Empty Lines, and Spacing
|
|
31
|
-
|
|
32
|
-
Use minimal comments. Assume readers understand the language. Some exceptions include:
|
|
33
|
-
- complex logic
|
|
34
|
-
- anti-patterns
|
|
35
|
-
- code organization
|
|
36
|
-
|
|
37
|
-
Do not put random empty lines within code; put them where they make sense for readability, for example:
|
|
38
|
-
- above and below definitions for functions and classes.
|
|
39
|
-
- to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
|
|
40
|
-
- above multi-line comments to indicate the comment belongs to the code below
|
|
41
|
-
|
|
42
|
-
No empty lines in css.
|
|
43
|
-
|
|
44
|
-
End each file with an empty line.
|
|
45
|
-
|
|
46
|
-
End each line with a `;` when possible, even if it is optional.
|
|
47
|
-
|
|
48
|
-
Avoid unnecessary spacing, for example:
|
|
49
|
-
- after the word `if`
|
|
50
|
-
- within parentheses for conditional statements
|
|
51
|
-
|
|
52
|
-
```javascript
|
|
53
|
-
let count = 1;
|
|
54
|
-
|
|
55
|
-
const incrementOdd = (n) => {
|
|
56
|
-
if(n % 2 !== 0){
|
|
57
|
-
return n++;
|
|
58
|
-
}
|
|
59
|
-
return n;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
count = incrementOdd(count);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Prefer Arrow Functions
|
|
66
|
-
Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
|
|
67
|
-
- For very basic logic, use implicit returns
|
|
68
|
-
- If there is a single parameter, omit the parentheses.
|
|
69
|
-
```javascript
|
|
70
|
-
const addOne = n => n + 1;
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Module Exports
|
|
74
|
-
- If a module has only one export, use the "default" export, not a named export.
|
|
75
|
-
- Do not declare the default export as a const or give it a name; just export the value.
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
export default (n) => n + 1;
|
|
79
|
-
```
|
|
80
|
-
- If a module has multiple exports, use named exports and do not use a "default" export.
|
|
81
|
-
|
|
82
|
-
### Code Reuse
|
|
83
|
-
Create utility functions for shared logic.
|
|
84
|
-
- If the shared logic is used in a single file, define a utility function in that file.
|
|
85
|
-
- If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
|
|
86
|
-
|
|
87
|
-
### Naming
|
|
88
|
-
Do not prefix identifiers with underscores.
|
|
89
|
-
- Never use leading underscores (`_`) for variable, property, method, or function names.
|
|
90
|
-
- Use clear, descriptive names without prefixes.
|
|
91
|
-
- When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
|
|
92
|
-
|
|
93
|
-
## Lit Components
|
|
94
|
-
|
|
95
|
-
### Component Architecture and Communication
|
|
96
|
-
|
|
97
|
-
- Prefer direct method calls to trigger behavior. Do not dispatch custom events to make something happen. Use events only to inform that something already happened.
|
|
98
|
-
- Do: `this.closest('ktf-test-framework').enqueueTest({...});`
|
|
99
|
-
- Don’t: `this.closest('ktf-test-framework').dispatchEvent(new CustomEvent('enqueue', {...}))` to trigger logic.
|
|
100
|
-
|
|
101
|
-
- Containment-first design: place orchestrators (e.g., `ktf-test-framework`) as a parent that wraps all dependent components (summary, suites, tests). Children should locate the parent with `closest('ktf-test-framework')` and call its methods.
|
|
102
|
-
- Parents may query their own subtree (`this.querySelectorAll(...)`) to find children.
|
|
103
|
-
|
|
104
|
-
- Avoid window globals and window-scoped events for app logic. Scope cross-component events to the containing framework element when possible. Window events are reserved for process-wide concerns (e.g., settings store changes).
|
|
105
|
-
|
|
106
|
-
- Status and UI mapping: queued status should render the `scheduled` icon; running may use spin animation.
|
|
107
|
-
|
|
1
|
+
# Code Contribution Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure
|
|
4
|
+
|
|
5
|
+
- All code should be in the `src/` directory, with the exception of index.js.
|
|
6
|
+
- All utility function module files should be in the `src/utils/` directory.
|
|
7
|
+
|
|
8
|
+
### GUI
|
|
9
|
+
|
|
10
|
+
All files served by the GUI should be in the `gui/` directory, with the exception of scripts shared with the CLI, custom endpoints, and node_modules like kempo.css (which should have custom endpoints).
|
|
11
|
+
|
|
12
|
+
## Coding Style Guidelines
|
|
13
|
+
|
|
14
|
+
### Code Organization
|
|
15
|
+
Use multi-line comments to separate code into logical sections. Group related functionality together.
|
|
16
|
+
- Example: In Lit components, group lifecycle callbacks, event handlers, public methods, utility functions, and rendering logic separately.
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
/*
|
|
20
|
+
Lifecycle Callbacks
|
|
21
|
+
*/
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Avoid single-use variables/functions
|
|
25
|
+
Avoid defining a variable or function to only use it once; inline the logic where needed. Some exceptions include:
|
|
26
|
+
- recursion
|
|
27
|
+
- scope encapsulation (IIFE)
|
|
28
|
+
- context changes
|
|
29
|
+
|
|
30
|
+
### Minimal Comments, Empty Lines, and Spacing
|
|
31
|
+
|
|
32
|
+
Use minimal comments. Assume readers understand the language. Some exceptions include:
|
|
33
|
+
- complex logic
|
|
34
|
+
- anti-patterns
|
|
35
|
+
- code organization
|
|
36
|
+
|
|
37
|
+
Do not put random empty lines within code; put them where they make sense for readability, for example:
|
|
38
|
+
- above and below definitions for functions and classes.
|
|
39
|
+
- to help break up large sections of logic to be more readable. If there are 100 lines of code with no breaks, it gets hard to read.
|
|
40
|
+
- above multi-line comments to indicate the comment belongs to the code below
|
|
41
|
+
|
|
42
|
+
No empty lines in css.
|
|
43
|
+
|
|
44
|
+
End each file with an empty line.
|
|
45
|
+
|
|
46
|
+
End each line with a `;` when possible, even if it is optional.
|
|
47
|
+
|
|
48
|
+
Avoid unnecessary spacing, for example:
|
|
49
|
+
- after the word `if`
|
|
50
|
+
- within parentheses for conditional statements
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
let count = 1;
|
|
54
|
+
|
|
55
|
+
const incrementOdd = (n) => {
|
|
56
|
+
if(n % 2 !== 0){
|
|
57
|
+
return n++;
|
|
58
|
+
}
|
|
59
|
+
return n;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
count = incrementOdd(count);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Prefer Arrow Functions
|
|
66
|
+
Prefer the use of arrow functions when possible, especially for class methods to avoid binding. Use normal functions if needed for preserving the proper context.
|
|
67
|
+
- For very basic logic, use implicit returns
|
|
68
|
+
- If there is a single parameter, omit the parentheses.
|
|
69
|
+
```javascript
|
|
70
|
+
const addOne = n => n + 1;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Module Exports
|
|
74
|
+
- If a module has only one export, use the "default" export, not a named export.
|
|
75
|
+
- Do not declare the default export as a const or give it a name; just export the value.
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
export default (n) => n + 1;
|
|
79
|
+
```
|
|
80
|
+
- If a module has multiple exports, use named exports and do not use a "default" export.
|
|
81
|
+
|
|
82
|
+
### Code Reuse
|
|
83
|
+
Create utility functions for shared logic.
|
|
84
|
+
- If the shared logic is used in a single file, define a utility function in that file.
|
|
85
|
+
- If the shared logic is used in multiple files, create a utility function module file in `src/utils/`.
|
|
86
|
+
|
|
87
|
+
### Naming
|
|
88
|
+
Do not prefix identifiers with underscores.
|
|
89
|
+
- Never use leading underscores (`_`) for variable, property, method, or function names.
|
|
90
|
+
- Use clear, descriptive names without prefixes.
|
|
91
|
+
- When true privacy is needed inside classes, prefer native JavaScript private fields (e.g., `#myField`) instead of simulated privacy via underscores.
|
|
92
|
+
|
|
93
|
+
## Lit Components
|
|
94
|
+
|
|
95
|
+
### Component Architecture and Communication
|
|
96
|
+
|
|
97
|
+
- Prefer direct method calls to trigger behavior. Do not dispatch custom events to make something happen. Use events only to inform that something already happened.
|
|
98
|
+
- Do: `this.closest('ktf-test-framework').enqueueTest({...});`
|
|
99
|
+
- Don’t: `this.closest('ktf-test-framework').dispatchEvent(new CustomEvent('enqueue', {...}))` to trigger logic.
|
|
100
|
+
|
|
101
|
+
- Containment-first design: place orchestrators (e.g., `ktf-test-framework`) as a parent that wraps all dependent components (summary, suites, tests). Children should locate the parent with `closest('ktf-test-framework')` and call its methods.
|
|
102
|
+
- Parents may query their own subtree (`this.querySelectorAll(...)`) to find children.
|
|
103
|
+
|
|
104
|
+
- Avoid window globals and window-scoped events for app logic. Scope cross-component events to the containing framework element when possible. Window events are reserved for process-wide concerns (e.g., settings store changes).
|
|
105
|
+
|
|
106
|
+
- Status and UI mapping: queued status should render the `scheduled` icon; running may use spin animation.
|
|
107
|
+
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { LitElement, html, css } from '../lit-all.min.js';
|
|
2
|
-
|
|
3
|
-
window.customElements.define('ktf-collapsible', class extends LitElement {
|
|
4
|
-
/*
|
|
5
|
-
Properties
|
|
6
|
-
*/
|
|
7
|
-
static properties = {
|
|
8
|
-
opened: { type: Boolean, reflect: true }
|
|
9
|
-
}
|
|
10
|
-
constructor(){
|
|
11
|
-
super();
|
|
12
|
-
this.opened = false;
|
|
13
|
-
}
|
|
14
|
-
connectedCallback(){
|
|
15
|
-
super.connectedCallback();
|
|
16
|
-
if (this.hasAttribute('opened')) this.opened = true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/*
|
|
20
|
-
Event Handling
|
|
21
|
-
*/
|
|
22
|
-
toggle = () => {
|
|
23
|
-
this.opened = !this.opened;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
Rendering
|
|
28
|
-
*/
|
|
29
|
-
render(){
|
|
30
|
-
return html`
|
|
31
|
-
<link rel="stylesheet" href="/kempo.css">
|
|
32
|
-
<div class="header">
|
|
33
|
-
<div class="actions">
|
|
34
|
-
<slot name="actions"></slot>
|
|
35
|
-
</div>
|
|
36
|
-
<button class="no-btn p r title" @click=${this.toggle}>
|
|
37
|
-
<slot name="title">Show ${this.opened?'Less':'More'}</slot>
|
|
38
|
-
</button>
|
|
39
|
-
</div>
|
|
40
|
-
${this.opened?html`<div class="bt p pb0"><slot></slot></div>`:''}
|
|
41
|
-
`;
|
|
42
|
-
}
|
|
43
|
-
static styles = css`
|
|
44
|
-
:host {
|
|
45
|
-
display: block;
|
|
46
|
-
border: 1px solid var(--c_border, #cccccc);
|
|
47
|
-
border-radius: var(--radius, 0.25rem);
|
|
48
|
-
margin-bottom: var(--spacer, 1rem);
|
|
49
|
-
}
|
|
50
|
-
.header { display: flex; align-items: center; }
|
|
51
|
-
.title { flex: 1; text-align: left; }
|
|
52
|
-
.actions { display: inline-flex; align-items: center; gap: .5rem; }
|
|
53
|
-
`;
|
|
54
|
-
});
|
|
1
|
+
import { LitElement, html, css } from '../lit-all.min.js';
|
|
2
|
+
|
|
3
|
+
window.customElements.define('ktf-collapsible', class extends LitElement {
|
|
4
|
+
/*
|
|
5
|
+
Properties
|
|
6
|
+
*/
|
|
7
|
+
static properties = {
|
|
8
|
+
opened: { type: Boolean, reflect: true }
|
|
9
|
+
}
|
|
10
|
+
constructor(){
|
|
11
|
+
super();
|
|
12
|
+
this.opened = false;
|
|
13
|
+
}
|
|
14
|
+
connectedCallback(){
|
|
15
|
+
super.connectedCallback();
|
|
16
|
+
if (this.hasAttribute('opened')) this.opened = true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
Event Handling
|
|
21
|
+
*/
|
|
22
|
+
toggle = () => {
|
|
23
|
+
this.opened = !this.opened;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
Rendering
|
|
28
|
+
*/
|
|
29
|
+
render(){
|
|
30
|
+
return html`
|
|
31
|
+
<link rel="stylesheet" href="/kempo.css">
|
|
32
|
+
<div class="header">
|
|
33
|
+
<div class="actions">
|
|
34
|
+
<slot name="actions"></slot>
|
|
35
|
+
</div>
|
|
36
|
+
<button class="no-btn p r title" @click=${this.toggle}>
|
|
37
|
+
<slot name="title">Show ${this.opened?'Less':'More'}</slot>
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
${this.opened?html`<div class="bt p pb0"><slot></slot></div>`:''}
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
static styles = css`
|
|
44
|
+
:host {
|
|
45
|
+
display: block;
|
|
46
|
+
border: 1px solid var(--c_border, #cccccc);
|
|
47
|
+
border-radius: var(--radius, 0.25rem);
|
|
48
|
+
margin-bottom: var(--spacer, 1rem);
|
|
49
|
+
}
|
|
50
|
+
.header { display: flex; align-items: center; }
|
|
51
|
+
.title { flex: 1; text-align: left; }
|
|
52
|
+
.actions { display: inline-flex; align-items: center; gap: .5rem; }
|
|
53
|
+
`;
|
|
54
|
+
});
|