niris-public-community-components 0.0.1
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/.eleventy.cjs +21 -0
- package/.eslintignore +6 -0
- package/.eslintrc.json +51 -0
- package/.prettierrc.json +7 -0
- package/CHANGELOG.md +98 -0
- package/LICENSE +28 -0
- package/README.md +93 -0
- package/README_DEV.md +154 -0
- package/dev/README.md +1 -0
- package/dev/index.html +22 -0
- package/dev/text-area-niris.html +30 -0
- package/docs/.nojekyll +0 -0
- package/docs/api/index.html +149 -0
- package/docs/docs.css +163 -0
- package/docs/examples/index.html +75 -0
- package/docs/examples/name-property/index.html +65 -0
- package/docs/images/example1.png +0 -0
- package/docs/images/example2.png +0 -0
- package/docs/index.html +75 -0
- package/docs/install/index.html +53 -0
- package/docs/prism-okaidia.css +123 -0
- package/docs-src/.eleventyignore +2 -0
- package/docs-src/.nojekyll +0 -0
- package/docs-src/_README.md +7 -0
- package/docs-src/_data/api.11tydata.js +16 -0
- package/docs-src/_includes/example.11ty.cjs +43 -0
- package/docs-src/_includes/footer.11ty.cjs +9 -0
- package/docs-src/_includes/header.11ty.cjs +7 -0
- package/docs-src/_includes/nav.11ty.cjs +11 -0
- package/docs-src/_includes/page.11ty.cjs +37 -0
- package/docs-src/_includes/relative-path.cjs +9 -0
- package/docs-src/api.11ty.cjs +127 -0
- package/docs-src/docs.css +163 -0
- package/docs-src/examples/index.md +34 -0
- package/docs-src/examples/name-property.md +15 -0
- package/docs-src/index.md +76 -0
- package/docs-src/install.md +32 -0
- package/docs-src/package.json +3 -0
- package/index.html +17 -0
- package/my-element.js +79 -0
- package/package.json +76 -0
- package/rollup.config.js +42 -0
- package/src/my-element.ts +68 -0
- package/src/test/my-element_test.ts +62 -0
- package/src/textarea-to-niris.ts +218 -0
- package/tsconfig.json +34 -0
- package/web-dev-server.config.js +25 -0
- package/web-test-runner.config.js +120 -0
package/rollup.config.js
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2018 Google LLC
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
+
*/
|
6
|
+
|
7
|
+
import summary from 'rollup-plugin-summary';
|
8
|
+
import {terser} from 'rollup-plugin-terser';
|
9
|
+
import resolve from '@rollup/plugin-node-resolve';
|
10
|
+
import replace from '@rollup/plugin-replace';
|
11
|
+
|
12
|
+
export default {
|
13
|
+
input: 'my-element.js',
|
14
|
+
output: {
|
15
|
+
file: 'my-element.bundled.js',
|
16
|
+
format: 'esm',
|
17
|
+
},
|
18
|
+
onwarn(warning) {
|
19
|
+
if (warning.code !== 'THIS_IS_UNDEFINED') {
|
20
|
+
console.error(`(!) ${warning.message}`);
|
21
|
+
}
|
22
|
+
},
|
23
|
+
plugins: [
|
24
|
+
replace({'Reflect.decorate': 'undefined'}),
|
25
|
+
resolve(),
|
26
|
+
/**
|
27
|
+
* This minification setup serves the static site generation.
|
28
|
+
* For bundling and minification, check the README.md file.
|
29
|
+
*/
|
30
|
+
terser({
|
31
|
+
ecma: 2021,
|
32
|
+
module: true,
|
33
|
+
warnings: true,
|
34
|
+
mangle: {
|
35
|
+
properties: {
|
36
|
+
regex: /^__/,
|
37
|
+
},
|
38
|
+
},
|
39
|
+
}),
|
40
|
+
summary(),
|
41
|
+
],
|
42
|
+
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2019 Google LLC
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
+
*/
|
6
|
+
|
7
|
+
import {LitElement, html, css} from 'lit';
|
8
|
+
import {customElement, property} from 'lit/decorators.js';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* An example element.
|
12
|
+
*
|
13
|
+
* @fires count-changed - Indicates when the count changes
|
14
|
+
* @slot - This element has a slot
|
15
|
+
* @csspart button - The button
|
16
|
+
*/
|
17
|
+
@customElement('my-element')
|
18
|
+
export class MyElement extends LitElement {
|
19
|
+
static override styles = css`
|
20
|
+
:host {
|
21
|
+
display: block;
|
22
|
+
border: solid 1px gray;
|
23
|
+
padding: 16px;
|
24
|
+
max-width: 800px;
|
25
|
+
}
|
26
|
+
`;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* The name to say "Hello" to.
|
30
|
+
*/
|
31
|
+
@property()
|
32
|
+
name = 'World';
|
33
|
+
|
34
|
+
/**
|
35
|
+
* The number of times the button has been clicked.
|
36
|
+
*/
|
37
|
+
@property({type: Number})
|
38
|
+
count = 0;
|
39
|
+
|
40
|
+
override render() {
|
41
|
+
return html`
|
42
|
+
<h1>${this.sayHello(this.name)}!</h1>
|
43
|
+
<button @click=${this._onClick} part="button">
|
44
|
+
Click Count: ${this.count}
|
45
|
+
</button>
|
46
|
+
<slot></slot>
|
47
|
+
`;
|
48
|
+
}
|
49
|
+
|
50
|
+
private _onClick() {
|
51
|
+
this.count++;
|
52
|
+
this.dispatchEvent(new CustomEvent('count-changed'));
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Formats a greeting
|
57
|
+
* @param name The name to say "Hello" to
|
58
|
+
*/
|
59
|
+
sayHello(name: string): string {
|
60
|
+
return `Hello, ${name}`;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
declare global {
|
65
|
+
interface HTMLElementTagNameMap {
|
66
|
+
'my-element': MyElement;
|
67
|
+
}
|
68
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2021 Google LLC
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
+
*/
|
6
|
+
|
7
|
+
import {MyElement} from '../my-element.js';
|
8
|
+
|
9
|
+
import {fixture, assert} from '@open-wc/testing';
|
10
|
+
import {html} from 'lit/static-html.js';
|
11
|
+
|
12
|
+
suite('my-element', () => {
|
13
|
+
test('is defined', () => {
|
14
|
+
const el = document.createElement('my-element');
|
15
|
+
assert.instanceOf(el, MyElement);
|
16
|
+
});
|
17
|
+
|
18
|
+
test('renders with default values', async () => {
|
19
|
+
const el = await fixture(html`<my-element></my-element>`);
|
20
|
+
assert.shadowDom.equal(
|
21
|
+
el,
|
22
|
+
`
|
23
|
+
<h1>Hello, World!</h1>
|
24
|
+
<button part="button">Click Count: 0</button>
|
25
|
+
<slot></slot>
|
26
|
+
`
|
27
|
+
);
|
28
|
+
});
|
29
|
+
|
30
|
+
test('renders with a set name', async () => {
|
31
|
+
const el = await fixture(html`<my-element name="Test"></my-element>`);
|
32
|
+
assert.shadowDom.equal(
|
33
|
+
el,
|
34
|
+
`
|
35
|
+
<h1>Hello, Test!</h1>
|
36
|
+
<button part="button">Click Count: 0</button>
|
37
|
+
<slot></slot>
|
38
|
+
`
|
39
|
+
);
|
40
|
+
});
|
41
|
+
|
42
|
+
test('handles a click', async () => {
|
43
|
+
const el = (await fixture(html`<my-element></my-element>`)) as MyElement;
|
44
|
+
const button = el.shadowRoot!.querySelector('button')!;
|
45
|
+
button.click();
|
46
|
+
await el.updateComplete;
|
47
|
+
assert.shadowDom.equal(
|
48
|
+
el,
|
49
|
+
`
|
50
|
+
<h1>Hello, World!</h1>
|
51
|
+
<button part="button">Click Count: 1</button>
|
52
|
+
<slot></slot>
|
53
|
+
`
|
54
|
+
);
|
55
|
+
});
|
56
|
+
|
57
|
+
test('styling applied', async () => {
|
58
|
+
const el = (await fixture(html`<my-element></my-element>`)) as MyElement;
|
59
|
+
await el.updateComplete;
|
60
|
+
assert.equal(getComputedStyle(el).paddingTop, '16px');
|
61
|
+
});
|
62
|
+
});
|
@@ -0,0 +1,218 @@
|
|
1
|
+
import {LitElement, html, css} from 'lit';
|
2
|
+
import {property} from 'lit/decorators.js';
|
3
|
+
|
4
|
+
export class TextareaToNiris extends LitElement {
|
5
|
+
@property({type: String}) formAction: any;
|
6
|
+
@property({type: String}) keywords: any;
|
7
|
+
|
8
|
+
constructor() {
|
9
|
+
super();
|
10
|
+
this.formAction = '';
|
11
|
+
this.keywords = '';
|
12
|
+
}
|
13
|
+
|
14
|
+
updateShownValue(event: Event) {
|
15
|
+
this.keywords = (event.target as HTMLInputElement)?.value;
|
16
|
+
}
|
17
|
+
|
18
|
+
closePopover(event: Event) {
|
19
|
+
event.preventDefault();
|
20
|
+
(this.shadowRoot?.getElementById('popover') as HTMLElement).hidePopover();
|
21
|
+
}
|
22
|
+
|
23
|
+
override render() {
|
24
|
+
return html`
|
25
|
+
<div id="popover-container">
|
26
|
+
<button id="button-popover" popovertarget="popover">
|
27
|
+
Atención en línea
|
28
|
+
</button>
|
29
|
+
|
30
|
+
<div popover id="popover">
|
31
|
+
<header>
|
32
|
+
<h2>Atención en línea Niris</h2>
|
33
|
+
</header>
|
34
|
+
<body>
|
35
|
+
<form action="${this.formAction}?keywords" =${this.keywords}>
|
36
|
+
<label for="niris-input"
|
37
|
+
>Información, Consultas, Quejas y Sugerencias:
|
38
|
+
</label>
|
39
|
+
<textarea
|
40
|
+
id="niris-input"
|
41
|
+
@change=${this.updateShownValue}
|
42
|
+
name="keywords"
|
43
|
+
required
|
44
|
+
minlength="4"
|
45
|
+
placeholder="Escribe tu consulta aquí"
|
46
|
+
></textarea>
|
47
|
+
<button type="submit">Enviar</button>
|
48
|
+
<button type="button" @click="${this.closePopover}">
|
49
|
+
Cerrar
|
50
|
+
</button>
|
51
|
+
</form>
|
52
|
+
</body>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
`;
|
56
|
+
}
|
57
|
+
|
58
|
+
static override styles = css`
|
59
|
+
:host {
|
60
|
+
--primary-color: #007bff;
|
61
|
+
--background-color: #d4d4d4;
|
62
|
+
--color: #fff;
|
63
|
+
--padding: 1rem 1rem;
|
64
|
+
--font-size: 1rem;
|
65
|
+
--border-radius: 0rem;
|
66
|
+
--font-weight: 500;
|
67
|
+
--font-family: 'Arial', sans-serif;
|
68
|
+
}
|
69
|
+
* {
|
70
|
+
font-family: 'Brush Script MT', cursive, sans-serif; /* This is fallback font for old browsers */
|
71
|
+
font-family: var(--font-family);
|
72
|
+
box-sizing: border-box;
|
73
|
+
}
|
74
|
+
|
75
|
+
button {
|
76
|
+
min-width: 120px;
|
77
|
+
background-color: var(--primary-color);
|
78
|
+
border: none;
|
79
|
+
color: white;
|
80
|
+
text-align: center;
|
81
|
+
text-decoration: none;
|
82
|
+
font-size: 16px;
|
83
|
+
cursor: pointer;
|
84
|
+
position: relative;
|
85
|
+
color: var(--color);
|
86
|
+
padding: var(--padding);
|
87
|
+
font-size: var(--font-size);
|
88
|
+
font-weight: var(--font-weight);
|
89
|
+
border-radius: var(--border-radius);
|
90
|
+
transition: 0.3s;
|
91
|
+
}
|
92
|
+
|
93
|
+
button:hover {
|
94
|
+
filter: brightness(120%);
|
95
|
+
}
|
96
|
+
|
97
|
+
button:focus-visible {
|
98
|
+
background-color: var(--primary-color);
|
99
|
+
outline: 3px solid var(--primary-color);
|
100
|
+
outline-offset: 2px;
|
101
|
+
}
|
102
|
+
|
103
|
+
#popover:popover-open {
|
104
|
+
display: flex;
|
105
|
+
flex-direction: column;
|
106
|
+
justify-content: center;
|
107
|
+
padding: 0;
|
108
|
+
border: 0;
|
109
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.24);
|
110
|
+
width: 60%;
|
111
|
+
border-radius: var(--border-radius);
|
112
|
+
animation: fadeIn 150ms ease-in-out;
|
113
|
+
}
|
114
|
+
|
115
|
+
header {
|
116
|
+
text-align: center;
|
117
|
+
box-sizing: border-box;
|
118
|
+
padding-left: 1rem;
|
119
|
+
margin-bottom: 2rem;
|
120
|
+
width: 100%;
|
121
|
+
border-bottom: 1px solid #d4d4d4;
|
122
|
+
background-color: #f6f7f7;
|
123
|
+
}
|
124
|
+
|
125
|
+
header h2 {
|
126
|
+
color: var(--primary-color);
|
127
|
+
filter: opacity(100%);
|
128
|
+
}
|
129
|
+
|
130
|
+
header h2::before {
|
131
|
+
filter: opacity(50%);
|
132
|
+
color: var(--primary-color);
|
133
|
+
filter: opacity(100%);
|
134
|
+
}
|
135
|
+
|
136
|
+
form {
|
137
|
+
margin: 0 auto;
|
138
|
+
width: 90%;
|
139
|
+
}
|
140
|
+
|
141
|
+
textarea {
|
142
|
+
resize: none;
|
143
|
+
border-radius: var(--border-radius);
|
144
|
+
height: 8rem;
|
145
|
+
border-width: 2px;
|
146
|
+
margin: 0.7rem 0;
|
147
|
+
--tw-border-opacity: 1;
|
148
|
+
border-color: rgb(209 213 219 / var(--tw-border-opacity));
|
149
|
+
width: 100%;
|
150
|
+
font-size: 0.875rem;
|
151
|
+
padding: 0.5rem;
|
152
|
+
}
|
153
|
+
|
154
|
+
textarea:focus,
|
155
|
+
select:focus {
|
156
|
+
outline: 2px solid transparent;
|
157
|
+
outline-offset: 2px;
|
158
|
+
--tw-ring-inset: var(--tw-empty, /*!*/ /*!*/);
|
159
|
+
--tw-ring-offset-width: 0px;
|
160
|
+
--tw-ring-offset-color: #fff;
|
161
|
+
--tw-ring-color: var(--primary-color);
|
162
|
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0
|
163
|
+
var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
164
|
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0
|
165
|
+
calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
166
|
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow),
|
167
|
+
var(--tw-shadow);
|
168
|
+
border-color: var(--primary-color);
|
169
|
+
}
|
170
|
+
form button {
|
171
|
+
float: left;
|
172
|
+
margin: 1rem auto;
|
173
|
+
}
|
174
|
+
|
175
|
+
form button:last-child {
|
176
|
+
background-color: transparent;
|
177
|
+
margin-left: 1rem;
|
178
|
+
border: inset 2px solid var(--primary-color);
|
179
|
+
box-shadow: 0 0 0 1px var(--primary-color),
|
180
|
+
inset 0 0 0 2px var(--primary-color);
|
181
|
+
color: var(--primary-color);
|
182
|
+
}
|
183
|
+
form button:last-child:hover {
|
184
|
+
background-color: var(--primary-color);
|
185
|
+
color: white;
|
186
|
+
filter: none;
|
187
|
+
}
|
188
|
+
#popover::backdrop {
|
189
|
+
background-color: rgba(#c6c8ce 0.3);
|
190
|
+
backdrop-filter: blur(2px);
|
191
|
+
}
|
192
|
+
|
193
|
+
@keyframes fadeIn {
|
194
|
+
0% {
|
195
|
+
scale: 0.8;
|
196
|
+
opacity: 0;
|
197
|
+
}
|
198
|
+
100% {
|
199
|
+
scale: 1;
|
200
|
+
opacity: 1;
|
201
|
+
}
|
202
|
+
}
|
203
|
+
|
204
|
+
@media (max-width: 1024px) {
|
205
|
+
#popover:popover-open {
|
206
|
+
width: 90%;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
@media (min-width: 1024px) {
|
211
|
+
#popover:popover-open {
|
212
|
+
width: 60%;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
`;
|
216
|
+
}
|
217
|
+
|
218
|
+
customElements.define('textarea-to-niris', TextareaToNiris);
|
package/tsconfig.json
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "es2021",
|
4
|
+
"module": "es2020",
|
5
|
+
"lib": ["es2021", "DOM", "DOM.Iterable"],
|
6
|
+
"declaration": true,
|
7
|
+
"declarationMap": true,
|
8
|
+
"sourceMap": true,
|
9
|
+
"inlineSources": true,
|
10
|
+
"outDir": "./",
|
11
|
+
"rootDir": "./src",
|
12
|
+
"strict": true,
|
13
|
+
"noUnusedLocals": true,
|
14
|
+
"noUnusedParameters": true,
|
15
|
+
"noImplicitReturns": true,
|
16
|
+
"noFallthroughCasesInSwitch": true,
|
17
|
+
"noImplicitAny": true,
|
18
|
+
"noImplicitThis": true,
|
19
|
+
"moduleResolution": "node",
|
20
|
+
"allowSyntheticDefaultImports": true,
|
21
|
+
"experimentalDecorators": true,
|
22
|
+
"forceConsistentCasingInFileNames": true,
|
23
|
+
"noImplicitOverride": true,
|
24
|
+
"plugins": [
|
25
|
+
{
|
26
|
+
"name": "ts-lit-plugin",
|
27
|
+
"strict": true
|
28
|
+
}
|
29
|
+
],
|
30
|
+
"types": ["mocha"]
|
31
|
+
},
|
32
|
+
"include": ["src/**/*.ts"],
|
33
|
+
"exclude": []
|
34
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2021 Google LLC
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
+
*/
|
6
|
+
|
7
|
+
import {legacyPlugin} from '@web/dev-server-legacy';
|
8
|
+
|
9
|
+
const mode = process.env.MODE || 'dev';
|
10
|
+
if (!['dev', 'prod'].includes(mode)) {
|
11
|
+
throw new Error(`MODE must be "dev" or "prod", was "${mode}"`);
|
12
|
+
}
|
13
|
+
|
14
|
+
export default {
|
15
|
+
nodeResolve: {exportConditions: mode === 'dev' ? ['development'] : []},
|
16
|
+
preserveSymlinks: true,
|
17
|
+
plugins: [
|
18
|
+
legacyPlugin({
|
19
|
+
polyfills: {
|
20
|
+
// Manually imported in index.html file
|
21
|
+
webcomponents: false,
|
22
|
+
},
|
23
|
+
}),
|
24
|
+
],
|
25
|
+
};
|
@@ -0,0 +1,120 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2021 Google LLC
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
+
*/
|
6
|
+
|
7
|
+
import {legacyPlugin} from '@web/dev-server-legacy';
|
8
|
+
import {playwrightLauncher} from '@web/test-runner-playwright';
|
9
|
+
|
10
|
+
const mode = process.env.MODE || 'dev';
|
11
|
+
if (!['dev', 'prod'].includes(mode)) {
|
12
|
+
throw new Error(`MODE must be "dev" or "prod", was "${mode}"`);
|
13
|
+
}
|
14
|
+
|
15
|
+
// Uncomment for testing on Sauce Labs
|
16
|
+
// Must run `npm i --save-dev @web/test-runner-saucelabs` and set
|
17
|
+
// SAUCE_USERNAME and SAUCE_USERNAME environment variables
|
18
|
+
// ===========
|
19
|
+
// import {createSauceLabsLauncher} from '@web/test-runner-saucelabs';
|
20
|
+
// const sauceLabsLauncher = createSauceLabsLauncher(
|
21
|
+
// {
|
22
|
+
// user: process.env.SAUCE_USERNAME,
|
23
|
+
// key: process.env.SAUCE_USERNAME,
|
24
|
+
// },
|
25
|
+
// {
|
26
|
+
// 'sauce:options': {
|
27
|
+
// name: 'unit tests',
|
28
|
+
// build: `${process.env.GITHUB_REF ?? 'local'} build ${
|
29
|
+
// process.env.GITHUB_RUN_NUMBER ?? ''
|
30
|
+
// }`,
|
31
|
+
// },
|
32
|
+
// }
|
33
|
+
// );
|
34
|
+
|
35
|
+
// Uncomment for testing on BrowserStack
|
36
|
+
// Must run `npm i --save-dev @web/test-runner-browserstack` and set
|
37
|
+
// BROWSER_STACK_USERNAME and BROWSER_STACK_ACCESS_KEY environment variables
|
38
|
+
// ===========
|
39
|
+
// import {browserstackLauncher as createBrowserstackLauncher} from '@web/test-runner-browserstack';
|
40
|
+
// const browserstackLauncher = (config) => createBrowserstackLauncher({
|
41
|
+
// capabilities: {
|
42
|
+
// 'browserstack.user': process.env.BROWSER_STACK_USERNAME,
|
43
|
+
// 'browserstack.key': process.env.BROWSER_STACK_ACCESS_KEY,
|
44
|
+
// project: 'my-element',
|
45
|
+
// name: 'unit tests',
|
46
|
+
// build: `${process.env.GITHUB_REF ?? 'local'} build ${
|
47
|
+
// process.env.GITHUB_RUN_NUMBER ?? ''
|
48
|
+
// }`,
|
49
|
+
// ...config,
|
50
|
+
// }
|
51
|
+
// });
|
52
|
+
|
53
|
+
const browsers = {
|
54
|
+
// Local browser testing via playwright
|
55
|
+
// ===========
|
56
|
+
chromium: playwrightLauncher({product: 'chromium'}),
|
57
|
+
firefox: playwrightLauncher({product: 'firefox'}),
|
58
|
+
webkit: playwrightLauncher({product: 'webkit'}),
|
59
|
+
|
60
|
+
// Uncomment example launchers for running on Sauce Labs
|
61
|
+
// ===========
|
62
|
+
// chromium: sauceLabsLauncher({browserName: 'chrome', browserVersion: 'latest', platformName: 'Windows 10'}),
|
63
|
+
// firefox: sauceLabsLauncher({browserName: 'firefox', browserVersion: 'latest', platformName: 'Windows 10'}),
|
64
|
+
// safari: sauceLabsLauncher({browserName: 'safari', browserVersion: 'latest', platformName: 'macOS 10.15'}),
|
65
|
+
|
66
|
+
// Uncomment example launchers for running on Sauce Labs
|
67
|
+
// ===========
|
68
|
+
// chromium: browserstackLauncher({browserName: 'Chrome', os: 'Windows', os_version: '10'}),
|
69
|
+
// firefox: browserstackLauncher({browserName: 'Firefox', os: 'Windows', os_version: '10'}),
|
70
|
+
// safari: browserstackLauncher({browserName: 'Safari', browser_version: '14.0', os: 'OS X', os_version: 'Big Sur'}),
|
71
|
+
};
|
72
|
+
|
73
|
+
// Prepend BROWSERS=x,y to `npm run test` to run a subset of browsers
|
74
|
+
// e.g. `BROWSERS=chromium,firefox npm run test`
|
75
|
+
const noBrowser = (b) => {
|
76
|
+
throw new Error(`No browser configured named '${b}'; using defaults`);
|
77
|
+
};
|
78
|
+
let commandLineBrowsers;
|
79
|
+
try {
|
80
|
+
commandLineBrowsers = process.env.BROWSERS?.split(',').map(
|
81
|
+
(b) => browsers[b] ?? noBrowser(b)
|
82
|
+
);
|
83
|
+
} catch (e) {
|
84
|
+
console.warn(e);
|
85
|
+
}
|
86
|
+
|
87
|
+
// https://modern-web.dev/docs/test-runner/cli-and-configuration/
|
88
|
+
export default {
|
89
|
+
rootDir: '.',
|
90
|
+
files: ['./test/**/*_test.js'],
|
91
|
+
nodeResolve: {exportConditions: mode === 'dev' ? ['development'] : []},
|
92
|
+
preserveSymlinks: true,
|
93
|
+
browsers: commandLineBrowsers ?? Object.values(browsers),
|
94
|
+
testFramework: {
|
95
|
+
// https://mochajs.org/api/mocha
|
96
|
+
config: {
|
97
|
+
ui: 'tdd',
|
98
|
+
timeout: '60000',
|
99
|
+
},
|
100
|
+
},
|
101
|
+
plugins: [
|
102
|
+
// Detect browsers without modules (e.g. IE11) and transform to SystemJS
|
103
|
+
// (https://modern-web.dev/docs/dev-server/plugins/legacy/).
|
104
|
+
legacyPlugin({
|
105
|
+
polyfills: {
|
106
|
+
webcomponents: true,
|
107
|
+
// Inject lit's polyfill-support module into test files, which is required
|
108
|
+
// for interfacing with the webcomponents polyfills
|
109
|
+
custom: [
|
110
|
+
{
|
111
|
+
name: 'lit-polyfill-support',
|
112
|
+
path: 'node_modules/lit/polyfill-support.js',
|
113
|
+
test: "!('attachShadow' in Element.prototype) || !('getRootNode' in Element.prototype) || window.ShadyDOM && window.ShadyDOM.force",
|
114
|
+
module: false,
|
115
|
+
},
|
116
|
+
],
|
117
|
+
},
|
118
|
+
}),
|
119
|
+
],
|
120
|
+
};
|