@progressive-development/pd-order 0.1.124 → 0.1.125

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/package.json CHANGED
@@ -3,18 +3,24 @@
3
3
  "description": "Progressive Development Order Component",
4
4
  "author": "PD Progressive Development",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
- "version": "0.1.124",
7
- "main": "index.js",
8
- "module": "index.js",
6
+ "version": "0.1.125",
7
+ "exports": {
8
+ "./pd-order-contacts": "./dist/pd-order-contacts.js",
9
+ "./pd-order-summary": "./dist/pd-order-summary.js"
10
+ },
9
11
  "scripts": {
10
12
  "analyze": "cem analyze --litelement",
11
- "start": "web-dev-server",
12
- "lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.js\" --check --ignore-path .gitignore",
13
- "format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.js\" --write --ignore-path .gitignore",
14
- "test": "web-test-runner --coverage",
15
- "test:watch": "web-test-runner --watch",
16
- "storybook": "npm run analyze -- --exclude dist && web-dev-server -c .storybook/server.mjs",
17
- "storybook:build": "npm run analyze -- --exclude dist && build-storybook"
13
+ "dev": "vite",
14
+ "build": "vite build",
15
+ "preview": "vite preview",
16
+ "lint": "eslint --ext .js,.html . --ignore-path .gitignore && prettier \"**/*.{js,html}\" --check --ignore-path .gitignore",
17
+ "format": "eslint --ext .js,.html . --fix --ignore-path .gitignore && prettier \"**/*.{js,html}\" --write --ignore-path .gitignore",
18
+ "test": "vitest run --coverage",
19
+ "test:watch": "vitest --watch",
20
+ "localizeExtract": "lit-localize extract",
21
+ "localizeBuild": "lit-localize build",
22
+ "storybook": "storybook dev -p 6006",
23
+ "build-storybook": "storybook build"
18
24
  },
19
25
  "dependencies": {
20
26
  "@progressive-development/pd-calendar": "^0.2.21",
@@ -24,28 +30,32 @@
24
30
  "@progressive-development/pd-forms": "^0.2.16",
25
31
  "@progressive-development/pd-price": "^0.1.10",
26
32
  "@progressive-development/pd-shared-styles": "^0.1.1",
27
- "@progressive-development/pd-zip-check": "^0.1.59",
28
- "fecha": "^4.2.0",
29
- "lit": "^2.2.0"
33
+ "fecha": "^4.2.3",
34
+ "lit": "^2.8.0"
30
35
  },
31
36
  "devDependencies": {
32
37
  "@custom-elements-manifest/analyzer": "^0.4.17",
33
- "@open-wc/eslint-config": "^4.3.0",
34
- "@open-wc/testing": "next",
35
- "@web/dev-server": "^0.1.30",
36
- "@web/dev-server-storybook": "next",
37
- "@web/test-runner": "^0.13.27",
38
+ "@lit/localize-tools": "^0.7.2",
39
+ "@storybook/addon-essentials": "^7.6.4",
40
+ "@storybook/addon-links": "^7.6.4",
41
+ "@storybook/blocks": "^7.5.1",
42
+ "@storybook/web-components": "^7.5.1",
43
+ "@storybook/web-components-vite": "^7.6.4",
38
44
  "eslint": "^7.32.0",
39
- "eslint-config-prettier": "^8.4.0",
45
+ "eslint-config-prettier": "^8.10.0",
46
+ "eslint-plugin-storybook": "^0.6.15",
40
47
  "husky": "^4.3.8",
41
48
  "lint-staged": "^10.5.4",
42
- "prettier": "^2.5.1"
49
+ "prettier": "^2.8.8",
50
+ "storybook": "^7.6.4",
51
+ "vite": "^5.4.11"
43
52
  },
44
53
  "customElements": "custom-elements.json",
45
54
  "eslintConfig": {
46
55
  "extends": [
47
56
  "@open-wc",
48
- "prettier"
57
+ "prettier",
58
+ "plugin:storybook/recommended"
49
59
  ]
50
60
  },
51
61
  "prettier": {
@@ -9,10 +9,15 @@ export default {
9
9
  },
10
10
  };
11
11
 
12
- function Template({ summary, orderContact, billingContact }) {
12
+ function Template({ summary, orderContact, billingContact, withPayment, requiredFields }) {
13
13
  return html`
14
- <pd-order-contacts id="testOrderId" ?summary="${summary}" .orderContact="${orderContact}"
15
- .billingContact="${billingContact}"></pd-order-contacts>
14
+ <pd-order-contacts id="testOrderId"
15
+ ?summary="${summary}"
16
+ .orderContact="${orderContact}"
17
+ .billingContact="${billingContact}"
18
+ ?withPayment="${withPayment}"
19
+ .requiredFields=${requiredFields}
20
+ ></pd-order-contacts>
16
21
 
17
22
  <h2>Test Validation</h2>
18
23
  <button @click="${() => {
@@ -28,6 +33,29 @@ OrderContacts.args = {
28
33
  summary: false,
29
34
  };
30
35
 
36
+ export const OrderContactsRequiredFields = Template.bind({});
37
+ OrderContactsRequiredFields.args = {
38
+ summary: false,
39
+ requiredFields: [
40
+ "email",
41
+ "phone1",
42
+ "street",
43
+ "streetNr",
44
+ "firstName",
45
+ "lastName",
46
+ "companyName",
47
+ "zip",
48
+ "city",
49
+ ]
50
+ };
51
+
52
+ export const OrderContactsWithBilling = Template.bind({});
53
+ OrderContactsWithBilling.args = {
54
+ summary: false,
55
+ withPayment: true,
56
+
57
+ };
58
+
31
59
  export const OrderContactsView = Template.bind({});
32
60
  OrderContactsView.args = {
33
61
  summary: true,
@@ -62,8 +90,7 @@ OrderContactsPrepared.args = {
62
90
  streetNr: '34a',
63
91
  zip: '6041',
64
92
  city: 'Gent',
65
- phone1: '0221/9923443',
66
- mobil: '0175/9923443',
93
+ phone1: '+49123 123456',
67
94
  email: 'peter@muster.be'
68
95
  },
69
96
  billingContact: {
package/vite.config.js ADDED
@@ -0,0 +1,25 @@
1
+ import { defineConfig } from 'vite';
2
+ import { dependencies } from './package.json';
3
+
4
+ export default defineConfig({
5
+ build: {
6
+ lib: {
7
+ entry: {
8
+ 'pd-order-contacts': './pd-order-contacts.js',
9
+ 'pd-order-summary': './pd-order-summary.js',
10
+ },
11
+ formats: ['es'], // Nur ESModule, kein UMD
12
+ },
13
+ rollupOptions: {
14
+ external: Object.keys(dependencies), // Alle Abhängigkeiten aus package.json ausschließen
15
+ output: {
16
+ entryFileNames: '[name].js', // Keine Hashes, klare Dateinamen
17
+ chunkFileNames: '[name]-chunk.js', // Benenne Chunks klar und konsistent
18
+ globals: {
19
+ lit: 'Lit',
20
+ },
21
+ },
22
+ },
23
+ minify: false, // Keine Minifizierung
24
+ },
25
+ });
package/index.js DELETED
@@ -1 +0,0 @@
1
- export { PdOrder } from './src/PdOrder.js';
package/pd-booking.js DELETED
@@ -1,3 +0,0 @@
1
- import { PdBooking } from './src/PdBooking.js';
2
-
3
- window.customElements.define('pd-booking', PdBooking);
package/src/PdBooking.js DELETED
@@ -1,537 +0,0 @@
1
- /* eslint-disable lit-a11y/anchor-is-valid */
2
- /* eslint-disable lit-a11y/click-events-have-key-events */
3
- /**
4
- * @license
5
- * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
6
- */
7
-
8
- import { LitElement, html, css } from 'lit';
9
-
10
- import {PdBookDatePopup} from '@progressive-development/pd-dialog/pd-book-date-popup.js';
11
-
12
- import '@progressive-development/pd-calendar/pd-calendar.js';
13
- import '@progressive-development/pd-zip-check/pd-zip-check.js';
14
-
15
- import { PDFontStyles } from '@progressive-development/pd-shared-styles';
16
-
17
- export class PdBooking extends LitElement {
18
- /**
19
- * Fired when free date clicked => At the moment only for freeDates
20
- * @event book-date
21
- */
22
-
23
- /**
24
- * Fired when date or ZIP should edited by the user
25
- * @event edit-selection
26
- */
27
-
28
- static get properties() {
29
- return {
30
- // custTok: {type: String},
31
- // contractKey: {type: String},
32
- // item: {type: String},
33
- product: { type: Object },
34
- zipGroups: { type: Array },
35
- userData: { type: Object },
36
- editDate: { type: Object },
37
- // TODO: API Call object => Mixin
38
- productInfoRequest: { type: Object },
39
- _zipRequired: { type: Boolean },
40
- _validated: { type: Boolean },
41
- _zipInput: { type: String },
42
- _statusMsg: { type: String },
43
- _freeUnits: { type: Object },
44
- _selectedDate: { type: String },
45
- };
46
- }
47
-
48
- static get styles() {
49
- return [
50
- PDFontStyles,
51
- css`
52
- :host {
53
- display: block;
54
- }
55
-
56
- p {
57
- color: var(--pd-default-font-content-col);
58
- font-size: var(--pd-default-font-content-size);
59
- font-family: var(--pd-default-font-content-family);
60
- max-width: 1000px;
61
- }
62
-
63
- a {
64
- cursor: pointer;
65
- font-family: var(--pd-default-font-link-family);
66
- font-size: var(--pd-default-font-link-size);
67
- color: var(--pd-default-font-link-col);
68
- }
69
-
70
- a:hover {
71
- color: var(--pd-default-font-link-col-hover);
72
- }
73
-
74
- `];
75
- }
76
-
77
- constructor() {
78
- super();
79
-
80
- // external attribut properties
81
- // this.custTok = '';
82
- // this.contractKey = '';
83
- // this.item = '';
84
- this.product = {};
85
- this.zipGroups = [];
86
- this.productInfoRequest = undefined;
87
-
88
- // internal propertie
89
- this._zipRequired = false;
90
- this._validated = false;
91
- this._zipInput = '';
92
- this._statusMsg = '';
93
-
94
- this._freeUnits = {};
95
- this._cheapestWeekDays = [];
96
- this._selectedDate = '';
97
- }
98
-
99
- connectedCallback() {
100
- super.connectedCallback();
101
-
102
- // hard coded configuration at the moment, ref init function?
103
- this._validated = true;
104
- this._zipRequired = true;
105
- this._statusMsg = '';
106
-
107
- /*
108
- // init settings for customer
109
- if (this.custTok) {
110
-
111
- // fetch customer data
112
- this._statusMsg = 'Load content...';
113
- this._getCustomerConfiguration(this.custTok)
114
- .then (customerConf => {
115
-
116
- if (customerConf) {
117
-
118
- // setup specific configuration, at the moment only zip required
119
- console.log(customerConf);
120
- this._validated = true;
121
- this._zipRequired = customerConf.result.zipRequired;
122
- this._statusMsg = '';
123
-
124
- } else {
125
- this._statusMsg = "No result found for configured customer!";
126
- }
127
-
128
- }).catch(error => {
129
- switch (error.message) {
130
- case INVALID_TOK:
131
- this._statusMsg = "Invalid customer token configured!";
132
- break;
133
- default:
134
- this._statusMsg = "Fehler bei der Abfrage aufgetreten: " + error.message;
135
- }
136
- });
137
-
138
- } else {
139
- this._statusMsg = "Missing customer token!";
140
- }
141
- */
142
- }
143
-
144
- updated(changePros) {
145
- if (changePros.has('userData') && this.userData) {
146
- this._zipInput = this.userData.zip;
147
- let refDate;
148
- if (this.editDate) {
149
- refDate = new Date(this.editDate.getFullYear(), this.editDate.getMonth(), 1).getTime();
150
- }
151
- this._callService(this._zipInput, refDate);
152
- }
153
- }
154
-
155
- render() {
156
- // customer is initialied, load content
157
- if (this._validated) {
158
- // check if selection already done
159
- if (this._selectedDate && this._selectedDate !== '') {
160
- return this._renderSelection();
161
- // check if zip is required and not set at the moment
162
- }
163
-
164
- if (this._zipRequired && this._zipInput === '') {
165
- // Show ZIP input
166
- return this._renderZIPInput();
167
- }
168
-
169
- // Show Content
170
- return html` ${this._renderZIPResult()} ${this._renderCalendar()} `;
171
- }
172
-
173
- // customer request is going on, or there are errors during init call
174
- return html` <p>${this._statusMsg}</p> `;
175
- }
176
-
177
- _renderZIPInput() {
178
- return html`
179
- <pd-zip-check .zipGroups="${this.zipGroups}"
180
- @zip-selection="${e => {
181
- this._zipInput = e.detail.zip;
182
- this._callService(this._zipInput);
183
- }}"
184
- @edit-zip-selection="${() => {
185
- this._zipInput = undefined;
186
- }}">
187
- <div slot="description">
188
- <slot name="description"></slot>
189
- </div>
190
- </pd-zip-check>
191
- <p>${this._statusMsg}</p>
192
-
193
- <!--
194
- <div style="max-width: 700px; min-width: 300px;">
195
- .. hier dann elememte von oben ...
196
- </div>
197
- <squi-resize-content style="width: 500px;">
198
- <div slot="preview-content"><span class="popup-info">More informations about ZIP and price</span></div>
199
- <div slot="resize-content">
200
- <h3>Supported regions</h3>
201
- <p>
202
- We work in the region in and around Gent. On each weekday we are in the same ZIP region.
203
- Depending on your ZIP and the distance to that daily region the specific callout-fee for each weekday is calculated.
204
- </p>
205
- <table>
206
- <tr>
207
- <th style="text-align: left;">Region</th>
208
- <th style="text-align: left;">Cheapest Weekday</th>
209
- </tr>
210
- <tr>
211
- <td>Gent central</td>
212
- <td>Monday</td>
213
- </tr>
214
- <tr>
215
- <td>Gent North</td>
216
- <td>Tuesday</td>
217
- </tr>
218
- <tr>
219
- <td>Gent East</td>
220
- <td>Wednesday</td>
221
- </tr>
222
- <tr>
223
- <td>Gent South</td>
224
- <td>Thirsday</td>
225
- </tr>
226
- <tr>
227
- <td>Gent West</td>
228
- <td>Friday</td>
229
- </tr>
230
- </table>
231
- </div>
232
- </squi-resize-content>
233
- -->
234
-
235
- </div>
236
- `;
237
- }
238
-
239
- _renderZIPResult() {
240
- return html`
241
- <slot name="titel"></slot>
242
- <p>
243
- Uw postcode:
244
- ${this._zipInput}${this.userData
245
- ? '.'
246
- : html`
247
- <a @click="${() => {
248
- this._zipInput = '';
249
- this._statusMsg = '';
250
- this.dispatchEvent(new CustomEvent('edit-zip-selection'));
251
- }}"
252
- >(bewerk).</a>
253
- `}
254
- Voor het voordeligste tarief, kies voor
255
- ${this._cheapestWeekDays && this._cheapestWeekDays.length > 0
256
- ? this._cheapestWeekDays[0].longName
257
- : '--'},
258
- wanneer een technieker in uw buurt is. Zo bespaart U op uw
259
- herstellingskosten. Deze dag is aangeduid in het groen.
260
- </p>
261
- `;
262
- }
263
-
264
- _renderSelection() {
265
- return html`
266
- <p>
267
- Selected date: ${this._selectedDate}
268
- <a @click="${this._editSelectedDate}">(edit)</a>
269
- </p>
270
- `;
271
- }
272
-
273
- _renderCalendar() {
274
- return html`
275
- <pd-calendar
276
- .refDate="${this.editDate}"
277
- .data="${this._freeUnits}"
278
- prevMonthConstraint="${this.editDate ? 1 : 0}"
279
- nextMonthConstraint="${this.editDate ? 1 : 2}"
280
- @change-month="${this._changeDate}"
281
- @select-date="${this._dateSelecetd}"
282
- >
283
- <p slot="calFooter">* excl. BTW</p>
284
- </pd-calendar>
285
- `;
286
- }
287
-
288
- static _renderPopupContent() {
289
- return html`
290
- <h3>Supported ZIPs</h3>
291
- On each weekday we are in the same ZIP region. Depending on your ZIP and
292
- the distance to that daily region the specific callout-fee for each
293
- weekday is calculated.
294
- <br /><br />
295
- Our supported ZIP regions with cheapest week day:
296
- <ul>
297
- <li>Mo - Gent center - from xyz to xcv</li>
298
- <li>Di - Gent north - from xyz to xcv</li>
299
- <li>Mi - Gent east - from xyz to xcv</li>
300
- <li>Do - Gent south - from xyz to xcv</li>
301
- <li>Fr - Gent west - from xyz to xcv</li>
302
- </ul>
303
- `;
304
- }
305
-
306
- _changeDate(e) {
307
- // load new data for selected startdate
308
- this._callService(this._zipInput, e.detail.newDate.getTime());
309
- }
310
-
311
- _dateSelecetd(e) {
312
- // Add order submit popup
313
- const popupEl = new PdBookDatePopup();
314
- popupEl.date = `${e.detail.dateKey}`;
315
- popupEl.price = this._freeUnits[e.detail.dateKey][0].price;
316
-
317
- popupEl.addEventListener('date-approval', () => {
318
- this._selectedDate = e.detail.dateKey;
319
- const { price } = this._freeUnits[e.detail.dateKey][0];
320
- this.dispatchEvent(
321
- new CustomEvent('book-date', {
322
- bubbles: true,
323
- composed: true,
324
- detail: {
325
- dateKey: e.detail.dateKey,
326
- date: e.detail.date,
327
- price,
328
- },
329
- })
330
- );
331
- this.shadowRoot.removeChild(popupEl);
332
- });
333
-
334
- popupEl.addEventListener('close-popup', () => {
335
- this.shadowRoot.removeChild(popupEl);
336
- });
337
-
338
- this.shadowRoot.appendChild(popupEl);
339
- }
340
-
341
- _editSelectedDate() {
342
- this._selectedDate = '';
343
- this.dispatchEvent(new CustomEvent('edit-selection', {
344
- bubbles: true,
345
- composed: true,
346
- }));
347
- }
348
-
349
- _callService(zip, dateParam) {
350
- // get freeBookingUnits
351
- // _getFreeBookingUnits(tok, contractKey, zip, item) {
352
- this._statusMsg = `Load free booking units for ZIP ${zip} ...`;
353
-
354
- // Load products and zip groups
355
- if (
356
- this.productInfoRequest &&
357
- typeof this.productInfoRequest === 'function'
358
- ) {
359
- this.productInfoRequest(dateParam || 'default', this.editDate ? true : undefined,
360
- this.userData ? this.userData.contractId : undefined)
361
- .then(result => {
362
- if (result.userData && result.userData.freeUnits) {
363
- this._freeUnits = this._transformResult(result.userData.freeUnits, result.nextMonth);
364
- }
365
- })
366
- .catch(error => {
367
- console.log('Result Error', error);
368
- });
369
- }
370
- }
371
-
372
- _transformResult(freeUnitsArray, nextMonth) {
373
- // get zip goup
374
- const selectedZipGroup = this.zipGroups.filter(group =>
375
- group.zips.includes(this._zipInput)
376
- )[0];
377
-
378
- const calcPrice = weekDay => {
379
- let callOutFee = 0;
380
- if (selectedZipGroup && weekDay) {
381
- callOutFee = selectedZipGroup.outFee[weekDay] || 0;
382
- }
383
- return this.userData && this.userData.free
384
- ? 0
385
- : this.product.price + callOutFee;
386
- };
387
-
388
- const extractCWD = zipGroup => {
389
- const cwds = [];
390
- if (zipGroup && zipGroup.outFee) {
391
- const feeVals = [];
392
- Object.keys(zipGroup.outFee).forEach(key =>
393
- feeVals.push(zipGroup.outFee[key])
394
- );
395
- const minFee = Math.min(...feeVals);
396
- Object.keys(zipGroup.outFee).forEach(key => {
397
- if (zipGroup.outFee[key] === minFee) {
398
- cwds.push({
399
- shortName: key,
400
- longName: PdBooking._transformKey(key),
401
- });
402
- }
403
- });
404
- }
405
- return cwds;
406
- };
407
-
408
- this._cheapestWeekDays = extractCWD(selectedZipGroup);
409
-
410
- const freeUnitObj = {};
411
- if (freeUnitsArray) {
412
- freeUnitsArray.forEach(unit => {
413
- const priceTmp = calcPrice(unit.dayOfW);
414
- freeUnitObj[unit.date] = [
415
- {
416
- info: `${priceTmp} €`,
417
- price: priceTmp,
418
- special: this._isCheapDay(unit.dayOfW),
419
- },
420
- ];
421
- });
422
- // set month selection
423
- freeUnitObj.monthSelection = nextMonth;
424
- }
425
- return freeUnitObj;
426
- }
427
-
428
- _isCheapDay(day) {
429
- return (
430
- this._cheapestWeekDays.filter(cwd => cwd.shortName === day)[0] !==
431
- undefined
432
- );
433
- }
434
-
435
- static _transformKey(keyParam) {
436
- switch (keyParam) {
437
- case 'MO':
438
- return 'maandag';
439
- case 'TU':
440
- return 'dinsdag';
441
- case 'WE':
442
- return 'woensdag';
443
- case 'TH':
444
- return 'dondersdag';
445
- case 'FR':
446
- return 'vrijdag';
447
- case 'SA':
448
- return 'zaterdag';
449
- case 'SU':
450
- return 'zondag';
451
- default:
452
- return '--';
453
- }
454
- }
455
-
456
- /*
457
- Old Implementation...
458
-
459
- this._getFreeBookingUnits(this.custTok, this.contractKey || 'default',
460
- zip, this.item || 'default', dateParam || 'default')
461
- .then(freeUnits => {
462
-
463
- console.log("My Units: ", freeUnits);
464
- this._zipInput = zip;
465
- // TODO Add new result => Avoid query for previously selected dates
466
- this._freeUnits = this._transformResult(freeUnits.result);
467
- this._cheapestWeekDays = freeUnits.cwds;
468
-
469
- }).catch(error => {
470
- switch (error.message) {
471
- case INVALID_ZIP_RANGE:
472
- this._statusMsg = "Sorry, the entered ZIP " + zip + " is out of our supported range!";
473
- break;
474
- case INVALID_PRICE_ITEM:
475
- this._statusMsg = "Price item not configured properly!";
476
- break;
477
- case INVALID_DATE:
478
- this._statusMsg = "Invalid date delivered!";
479
- break;
480
- default:
481
- this._statusMsg = "Fehler bei der Abfrage aufgetreten: " + error.message;
482
- }
483
- });
484
-
485
- _getFreeBookingUnits(tok, contractKey, zip, item, startDate) {
486
-
487
- console.log("Mein Startdate: ", startDate);
488
-
489
- return new Promise((resolve, reject) => {
490
- fetch(SERVER_URL + FREE_UNITS_URL + tok + '/' + contractKey + '/' + zip + '/' + item + '/' + startDate || 'default', {
491
- method: 'GET'
492
- })
493
- .then(response => {
494
- if (response.status >= 400) {
495
- throw new Error(response.status);
496
- }
497
- const contentType = response.headers.get('content-type');
498
- if (!contentType || !contentType.includes('application/json')) {
499
- throw new TypeError("Wrong content-type: " + contentType);
500
- }
501
- return response.json();
502
- })
503
- .then(data => {
504
- resolve(data);
505
- })
506
- .catch(error => {
507
- reject(error);
508
- });
509
- });
510
- }
511
-
512
- _getCustomerConfiguration(tok) {
513
-
514
- return new Promise((resolve, reject) => {
515
- fetch(SERVER_URL + INIT_URL + tok, {
516
- method: 'GET'
517
- })
518
- .then(response => {
519
- if (response.status >= 400) {
520
- throw new Error(response.status);
521
- }
522
- const contentType = response.headers.get('content-type');
523
- if (!contentType || !contentType.includes('application/json')) {
524
- throw new TypeError("Wrong content-type: " + contentType);
525
- }
526
- return response.json();
527
- })
528
- .then(data => {
529
- resolve(data);
530
- })
531
- .catch(error => {
532
- reject(error);
533
- });
534
- });
535
- }
536
- */
537
- }
@@ -1,32 +0,0 @@
1
- import { html } from 'lit';
2
- import { fixture, expect } from '@open-wc/testing';
3
-
4
- import '../pd-order.js';
5
-
6
- describe('PdOrder', () => {
7
- it('has a default title "Hey there" and counter 5', async () => {
8
- const el = await fixture(html`<pd-order></pd-order>`);
9
-
10
- expect(el.title).to.equal('Hey there');
11
- expect(el.counter).to.equal(5);
12
- });
13
-
14
- it('increases the counter on button click', async () => {
15
- const el = await fixture(html`<pd-order></pd-order>`);
16
- el.shadowRoot.querySelector('button').click();
17
-
18
- expect(el.counter).to.equal(6);
19
- });
20
-
21
- it('can override the title via attribute', async () => {
22
- const el = await fixture(html`<pd-order title="attribute title"></pd-order>`);
23
-
24
- expect(el.title).to.equal('attribute title');
25
- });
26
-
27
- it('passes the a11y audit', async () => {
28
- const el = await fixture(html`<pd-order></pd-order>`);
29
-
30
- await expect(el).shadowDom.to.be.accessible();
31
- });
32
- });
@@ -1,27 +0,0 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- open: '/demo/',
8
- /** Use regular watch mode if HMR is not enabled. */
9
- watch: !hmr,
10
- /** Resolve bare module imports */
11
- nodeResolve: {
12
- exportConditions: ['browser', 'development'],
13
- },
14
-
15
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
- // esbuildTarget: 'auto'
17
-
18
- /** Set appIndex to enable SPA routing */
19
- // appIndex: 'demo/index.html',
20
-
21
- plugins: [
22
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
23
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
24
- ],
25
-
26
- // See documentation for all available options
27
- });
@@ -1,41 +0,0 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
- files: 'test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
23
-
24
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
- // esbuildTarget: 'auto',
26
-
27
- /** Amount of browsers to run concurrently */
28
- // concurrentBrowsers: 2,
29
-
30
- /** Amount of test files per browser to test concurrently */
31
- // concurrency: 1,
32
-
33
- /** Browsers to run tests on */
34
- // browsers: [
35
- // playwrightLauncher({ product: 'chromium' }),
36
- // playwrightLauncher({ product: 'firefox' }),
37
- // playwrightLauncher({ product: 'webkit' }),
38
- // ],
39
-
40
- // See documentation for all available options
41
- });