@internetarchive/collection-browser 2.12.1-alpha-webdev5427.7 → 2.12.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/.editorconfig +29 -29
- package/.husky/pre-commit +4 -4
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/app-root.d.ts +0 -1
- package/dist/src/app-root.js +2 -48
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.js +4 -13
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +1 -7
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +0 -1
- package/dist/src/collection-facets/more-facets-content.js +4 -19
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +3 -4
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets.d.ts +1 -3
- package/dist/src/collection-facets.js +7 -37
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +11 -16
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/expanded-date-picker.d.ts +0 -1
- package/dist/src/expanded-date-picker.js +1 -7
- package/dist/src/expanded-date-picker.js.map +1 -1
- package/dist/src/models.d.ts +5 -22
- package/dist/src/models.js +3 -64
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +3 -8
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/utils/facet-utils.js +2 -8
- package/dist/src/utils/facet-utils.js.map +1 -1
- package/dist/src/utils/local-date-from-utc.js +1 -1
- package/dist/src/utils/local-date-from-utc.js.map +1 -1
- package/dist/test/collection-facets.test.js +0 -27
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +10 -17
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +1 -1
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +3 -3
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/utils/local-date-from-utc.test.js +4 -4
- package/dist/test/utils/local-date-from-utc.test.js.map +1 -1
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +4 -4
- package/renovate.json +6 -6
- package/src/app-root.ts +2 -49
- package/src/collection-browser.ts +3 -16
- package/src/collection-facets/facet-row.ts +1 -8
- package/src/collection-facets/more-facets-content.ts +5 -21
- package/src/collection-facets/smart-facets/smart-facet-bar.ts +2 -2
- package/src/collection-facets.ts +8 -37
- package/src/data-source/collection-browser-data-source.ts +15 -27
- package/src/expanded-date-picker.ts +1 -5
- package/src/models.ts +10 -82
- package/src/restoration-state-handler.ts +1 -8
- package/src/utils/facet-utils.ts +3 -5
- package/src/utils/local-date-from-utc.ts +1 -1
- package/test/collection-facets.test.ts +0 -33
- package/test/restoration-state-handler.test.ts +10 -10
- package/test/tiles/grid/item-tile.test.ts +1 -1
- package/test/tiles/list/tile-list-compact.test.ts +1 -1
- package/test/tiles/list/tile-list.test.ts +3 -3
- package/test/utils/local-date-from-utc.test.ts +4 -4
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -687,39 +687,27 @@ export class CollectionBrowserDataSource
|
|
|
687
687
|
get filterMap(): FilterMap {
|
|
688
688
|
const builder = new FilterMapBuilder();
|
|
689
689
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
maxSelectedDate,
|
|
693
|
-
selectedFacets,
|
|
694
|
-
selectedTitleFilter,
|
|
695
|
-
selectedCreatorFilter,
|
|
696
|
-
} = this.host;
|
|
697
|
-
|
|
698
|
-
// Add the date range, if applicable.
|
|
699
|
-
// If the min/max are just years, filter on `year` alone. If months/days are included, use `date` instead.
|
|
700
|
-
const dateRangeField =
|
|
701
|
-
minSelectedDate?.includes('-') || maxSelectedDate?.includes('-')
|
|
702
|
-
? 'date'
|
|
703
|
-
: 'year';
|
|
704
|
-
|
|
705
|
-
if (minSelectedDate) {
|
|
690
|
+
// Add the date range, if applicable
|
|
691
|
+
if (this.host.minSelectedDate) {
|
|
706
692
|
builder.addFilter(
|
|
707
|
-
|
|
708
|
-
minSelectedDate,
|
|
693
|
+
'year',
|
|
694
|
+
this.host.minSelectedDate,
|
|
709
695
|
FilterConstraint.GREATER_OR_EQUAL,
|
|
710
696
|
);
|
|
711
697
|
}
|
|
712
|
-
if (maxSelectedDate) {
|
|
698
|
+
if (this.host.maxSelectedDate) {
|
|
713
699
|
builder.addFilter(
|
|
714
|
-
|
|
715
|
-
maxSelectedDate,
|
|
700
|
+
'year',
|
|
701
|
+
this.host.maxSelectedDate,
|
|
716
702
|
FilterConstraint.LESS_OR_EQUAL,
|
|
717
703
|
);
|
|
718
704
|
}
|
|
719
705
|
|
|
720
706
|
// Add any selected facets
|
|
721
|
-
if (selectedFacets) {
|
|
722
|
-
for (const [facetName, facetValues] of Object.entries(
|
|
707
|
+
if (this.host.selectedFacets) {
|
|
708
|
+
for (const [facetName, facetValues] of Object.entries(
|
|
709
|
+
this.host.selectedFacets,
|
|
710
|
+
)) {
|
|
723
711
|
const { name, values } = this.prepareFacetForFetch(
|
|
724
712
|
facetName,
|
|
725
713
|
facetValues,
|
|
@@ -740,17 +728,17 @@ export class CollectionBrowserDataSource
|
|
|
740
728
|
}
|
|
741
729
|
|
|
742
730
|
// Add any letter filters
|
|
743
|
-
if (selectedTitleFilter) {
|
|
731
|
+
if (this.host.selectedTitleFilter) {
|
|
744
732
|
builder.addFilter(
|
|
745
733
|
'firstTitle',
|
|
746
|
-
selectedTitleFilter,
|
|
734
|
+
this.host.selectedTitleFilter,
|
|
747
735
|
FilterConstraint.INCLUDE,
|
|
748
736
|
);
|
|
749
737
|
}
|
|
750
|
-
if (selectedCreatorFilter) {
|
|
738
|
+
if (this.host.selectedCreatorFilter) {
|
|
751
739
|
builder.addFilter(
|
|
752
740
|
'firstCreator',
|
|
753
|
-
selectedCreatorFilter,
|
|
741
|
+
this.host.selectedCreatorFilter,
|
|
754
742
|
FilterConstraint.INCLUDE,
|
|
755
743
|
);
|
|
756
744
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { css, html, LitElement, CSSResultGroup, TemplateResult } from 'lit';
|
|
2
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
-
import { msg } from '@lit/localize';
|
|
4
3
|
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
5
4
|
import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
|
|
6
5
|
import {
|
|
@@ -20,8 +19,6 @@ export class ExpandedDatePicker extends LitElement {
|
|
|
20
19
|
|
|
21
20
|
@property({ type: Array }) buckets?: number[];
|
|
22
21
|
|
|
23
|
-
@property({ type: String }) dateFormat: string = 'YYYY';
|
|
24
|
-
|
|
25
22
|
@property({ type: Object, attribute: false })
|
|
26
23
|
modalManager?: ModalManagerInterface;
|
|
27
24
|
|
|
@@ -37,7 +34,6 @@ export class ExpandedDatePicker extends LitElement {
|
|
|
37
34
|
.maxDate=${this.maxDate}
|
|
38
35
|
.minSelectedDate=${this.minSelectedDate ?? this.minDate}
|
|
39
36
|
.maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
|
|
40
|
-
.dateFormat=${this.dateFormat}
|
|
41
37
|
.updateDelay=${0}
|
|
42
38
|
updateWhileFocused
|
|
43
39
|
missingDataMessage="..."
|
|
@@ -51,7 +47,7 @@ export class ExpandedDatePicker extends LitElement {
|
|
|
51
47
|
slot="inputs-right-side"
|
|
52
48
|
@click=${this.applyBtnClicked}
|
|
53
49
|
>
|
|
54
|
-
|
|
50
|
+
Apply date range
|
|
55
51
|
</button>
|
|
56
52
|
</histogram-date-range>
|
|
57
53
|
</div>
|
package/src/models.ts
CHANGED
|
@@ -530,24 +530,18 @@ export type FacetOption =
|
|
|
530
530
|
| 'language'
|
|
531
531
|
| 'creator'
|
|
532
532
|
| 'collection'
|
|
533
|
-
| 'year'
|
|
534
|
-
// TV-specific facet options:
|
|
535
|
-
| 'program'
|
|
536
|
-
| 'person'
|
|
537
|
-
| 'sponsor';
|
|
533
|
+
| 'year';
|
|
538
534
|
|
|
539
535
|
export type SelectedFacetState = 'selected' | 'hidden';
|
|
540
536
|
|
|
541
537
|
export type FacetState = SelectedFacetState | 'none';
|
|
542
538
|
|
|
543
539
|
export interface FacetBucket {
|
|
540
|
+
// for some facets, we augment the key with a display value
|
|
541
|
+
displayText?: string;
|
|
544
542
|
key: string;
|
|
545
543
|
count: number;
|
|
546
544
|
state: FacetState;
|
|
547
|
-
// for some facets, we augment the key with a display value
|
|
548
|
-
displayText?: string;
|
|
549
|
-
// for TV channel facets, we add a parenthesized secondary name
|
|
550
|
-
extraNote?: string;
|
|
551
545
|
}
|
|
552
546
|
|
|
553
547
|
export interface FacetGroup {
|
|
@@ -577,11 +571,12 @@ export type FacetEventDetails = {
|
|
|
577
571
|
|
|
578
572
|
export type FacetValue = string;
|
|
579
573
|
|
|
580
|
-
export type SelectedFacets =
|
|
581
|
-
|
|
574
|
+
export type SelectedFacets = Record<
|
|
575
|
+
FacetOption,
|
|
576
|
+
Record<FacetValue, FacetBucket>
|
|
582
577
|
>;
|
|
583
578
|
|
|
584
|
-
export const getDefaultSelectedFacets = ():
|
|
579
|
+
export const getDefaultSelectedFacets = (): SelectedFacets => ({
|
|
585
580
|
subject: {},
|
|
586
581
|
lending: {},
|
|
587
582
|
mediatype: {},
|
|
@@ -589,15 +584,9 @@ export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
|
|
|
589
584
|
creator: {},
|
|
590
585
|
collection: {},
|
|
591
586
|
year: {},
|
|
592
|
-
program: {},
|
|
593
|
-
person: {},
|
|
594
|
-
sponsor: {},
|
|
595
587
|
});
|
|
596
588
|
|
|
597
|
-
|
|
598
|
-
* Facet display order when presenting results for all search types *except* TV (see below).
|
|
599
|
-
*/
|
|
600
|
-
export const defaultFacetDisplayOrder: FacetOption[] = [
|
|
589
|
+
export const facetDisplayOrder: FacetOption[] = [
|
|
601
590
|
'mediatype',
|
|
602
591
|
// 'lending', Commenting this out removes the lending facet from the sidebar for now
|
|
603
592
|
'year',
|
|
@@ -607,23 +596,6 @@ export const defaultFacetDisplayOrder: FacetOption[] = [
|
|
|
607
596
|
'language',
|
|
608
597
|
];
|
|
609
598
|
|
|
610
|
-
/**
|
|
611
|
-
* Specialized facet ordering when displaying TV search results
|
|
612
|
-
*/
|
|
613
|
-
export const tvFacetDisplayOrder: FacetOption[] = [
|
|
614
|
-
'program',
|
|
615
|
-
'creator',
|
|
616
|
-
'year',
|
|
617
|
-
'subject',
|
|
618
|
-
'collection',
|
|
619
|
-
'person',
|
|
620
|
-
'sponsor',
|
|
621
|
-
'language',
|
|
622
|
-
];
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
* Human-readable titles for each facet group.
|
|
626
|
-
*/
|
|
627
599
|
export const facetTitles: Record<FacetOption, string> = {
|
|
628
600
|
subject: 'Subject',
|
|
629
601
|
lending: 'Availability',
|
|
@@ -632,9 +604,6 @@ export const facetTitles: Record<FacetOption, string> = {
|
|
|
632
604
|
creator: 'Creator',
|
|
633
605
|
collection: 'Collection',
|
|
634
606
|
year: 'Year',
|
|
635
|
-
program: 'Program',
|
|
636
|
-
person: 'Person',
|
|
637
|
-
sponsor: 'Sponsor',
|
|
638
607
|
};
|
|
639
608
|
|
|
640
609
|
/**
|
|
@@ -647,10 +616,7 @@ export const defaultFacetSort: Record<FacetOption, AggregationSortType> = {
|
|
|
647
616
|
language: AggregationSortType.COUNT,
|
|
648
617
|
creator: AggregationSortType.COUNT,
|
|
649
618
|
collection: AggregationSortType.COUNT,
|
|
650
|
-
year: AggregationSortType.NUMERIC,
|
|
651
|
-
program: AggregationSortType.COUNT,
|
|
652
|
-
person: AggregationSortType.COUNT,
|
|
653
|
-
sponsor: AggregationSortType.COUNT,
|
|
619
|
+
year: AggregationSortType.NUMERIC,
|
|
654
620
|
};
|
|
655
621
|
|
|
656
622
|
/**
|
|
@@ -664,47 +630,9 @@ export const valueFacetSort: Record<FacetOption, AggregationSortType> = {
|
|
|
664
630
|
language: AggregationSortType.ALPHABETICAL,
|
|
665
631
|
creator: AggregationSortType.ALPHABETICAL,
|
|
666
632
|
collection: AggregationSortType.ALPHABETICAL,
|
|
667
|
-
year: AggregationSortType.NUMERIC,
|
|
668
|
-
program: AggregationSortType.ALPHABETICAL,
|
|
669
|
-
person: AggregationSortType.ALPHABETICAL,
|
|
670
|
-
sponsor: AggregationSortType.ALPHABETICAL,
|
|
633
|
+
year: AggregationSortType.NUMERIC,
|
|
671
634
|
};
|
|
672
635
|
|
|
673
|
-
/**
|
|
674
|
-
* Extra parenthesized labels to show next to certain TV channel facets
|
|
675
|
-
*
|
|
676
|
-
* TODO this is temporary for testing
|
|
677
|
-
*/
|
|
678
|
-
export const tvChannelFacetLabels: Record<string, string> = Object.fromEntries(
|
|
679
|
-
// prettier-ignore
|
|
680
|
-
Object.entries({
|
|
681
|
-
'Al Jazeera' : ['ALJAZAM', 'ALJAZ'],
|
|
682
|
-
'Bloomberg' : ['BLOOMBERG'],
|
|
683
|
-
'BBC' : ['BBC', 'BBC1', 'BBC2'],
|
|
684
|
-
'BBC America' : ['BBCAMERICA'],
|
|
685
|
-
'BBC News' : ['BBCNEWS'],
|
|
686
|
-
'GB News' : ['GBN'],
|
|
687
|
-
'BET' : ['BETW'],
|
|
688
|
-
'CNBC' : ['CNBC'],
|
|
689
|
-
'CNN' : ['CNNW', 'CNN'],
|
|
690
|
-
'Comedy Central' : ['COM', 'COMW'],
|
|
691
|
-
'CSPAN' : ['CSPAN', 'CSPAN2', 'CSPAN3'],
|
|
692
|
-
'Current' : ['CURRENT'],
|
|
693
|
-
'Deutsche Welle' : ['DW'],
|
|
694
|
-
'France 24' : ['FRANCE24'],
|
|
695
|
-
'FOX Business' : ['FBC'],
|
|
696
|
-
'FOX News' : ['FOXNEWSW', 'FOXNEWS'],
|
|
697
|
-
'LINKTV' : ['LINKTV'],
|
|
698
|
-
'MSNBC' : ['MSNBCW', 'MSNBC'],
|
|
699
|
-
'NHK World' : ['NHK'],
|
|
700
|
-
'RT' : ['RT'],
|
|
701
|
-
'Sky News' : ['SKY'],
|
|
702
|
-
}).reduce(
|
|
703
|
-
(acc, [label, channels]) => acc.concat(channels.map(ch => [ch, label])),
|
|
704
|
-
[] as [string, string][],
|
|
705
|
-
),
|
|
706
|
-
);
|
|
707
|
-
|
|
708
636
|
export type LendingFacetKey =
|
|
709
637
|
| 'is_lendable'
|
|
710
638
|
| 'is_borrowable'
|
|
@@ -185,16 +185,10 @@ export class RestorationStateHandler
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
const dateField =
|
|
189
|
-
state.minSelectedDate?.includes('-') ||
|
|
190
|
-
state.maxSelectedDate?.includes('-')
|
|
191
|
-
? 'date'
|
|
192
|
-
: 'year';
|
|
193
|
-
|
|
194
188
|
if (state.minSelectedDate && state.maxSelectedDate) {
|
|
195
189
|
newParams.append(
|
|
196
190
|
'and[]',
|
|
197
|
-
|
|
191
|
+
`year:[${state.minSelectedDate} TO ${state.maxSelectedDate}]`,
|
|
198
192
|
);
|
|
199
193
|
}
|
|
200
194
|
|
|
@@ -343,7 +337,6 @@ export class RestorationStateHandler
|
|
|
343
337
|
}
|
|
344
338
|
|
|
345
339
|
switch (field) {
|
|
346
|
-
case 'date':
|
|
347
340
|
case 'year': {
|
|
348
341
|
const [minDate, maxDate] = value.split(' TO ');
|
|
349
342
|
// we have two potential ways of filtering by date:
|
package/src/utils/facet-utils.ts
CHANGED
|
@@ -62,7 +62,7 @@ export function updateSelectedFacetBucket(
|
|
|
62
62
|
omitNoneState = false,
|
|
63
63
|
): SelectedFacets {
|
|
64
64
|
const defaultedSelectedFacets = selectedFacets ?? getDefaultSelectedFacets();
|
|
65
|
-
const newFacets
|
|
65
|
+
const newFacets = {
|
|
66
66
|
...defaultedSelectedFacets,
|
|
67
67
|
[facetType]: {
|
|
68
68
|
...defaultedSelectedFacets[facetType],
|
|
@@ -71,7 +71,7 @@ export function updateSelectedFacetBucket(
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
if (omitNoneState && bucket.state === 'none') {
|
|
74
|
-
delete newFacets[facetType]
|
|
74
|
+
delete newFacets[facetType][bucket.key];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return newFacets;
|
|
@@ -93,7 +93,6 @@ export function cloneSelectedFacets(
|
|
|
93
93
|
): SelectedFacets {
|
|
94
94
|
const cloneResult = getDefaultSelectedFacets();
|
|
95
95
|
forEachFacetBucket(selectedFacets, (facetType, bucketKey, bucket) => {
|
|
96
|
-
if (!cloneResult[facetType]) cloneResult[facetType] = {};
|
|
97
96
|
cloneResult[facetType][bucketKey] = bucket;
|
|
98
97
|
});
|
|
99
98
|
return cloneResult;
|
|
@@ -125,14 +124,13 @@ export function mergeSelectedFacets(
|
|
|
125
124
|
): SelectedFacets {
|
|
126
125
|
const mergeResult = cloneSelectedFacets(destination);
|
|
127
126
|
forEachFacetBucket(source, (facetType, bucketKey, bucket) => {
|
|
128
|
-
if (!mergeResult[facetType]) mergeResult[facetType] = {};
|
|
129
127
|
mergeResult[facetType][bucketKey] = bucket;
|
|
130
128
|
});
|
|
131
129
|
|
|
132
130
|
// Normalize any 'none' states on the result (from either source or destination)
|
|
133
131
|
forEachFacetBucket(mergeResult, (facetType, bucketKey, bucket) => {
|
|
134
132
|
if (bucket.state === 'none') {
|
|
135
|
-
delete mergeResult[facetType]
|
|
133
|
+
delete mergeResult[facetType][bucketKey];
|
|
136
134
|
}
|
|
137
135
|
});
|
|
138
136
|
|
|
@@ -11,5 +11,5 @@ export function localDateFromUTC(date: Date): Date {
|
|
|
11
11
|
*/
|
|
12
12
|
export function isFirstMillisecondOfUTCYear(date?: Date): boolean {
|
|
13
13
|
if (!date) return false;
|
|
14
|
-
return
|
|
14
|
+
return date.toISOString().endsWith('-01-01T00:00:00.000Z');
|
|
15
15
|
}
|
|
@@ -629,39 +629,6 @@ describe('Collection Facets', () => {
|
|
|
629
629
|
expect(facetRows?.[7]?.bucket?.key).to.equal('collection');
|
|
630
630
|
});
|
|
631
631
|
|
|
632
|
-
it('uses specified facet display order', async () => {
|
|
633
|
-
const el = await fixture<CollectionFacets>(
|
|
634
|
-
html`<collection-facets
|
|
635
|
-
.facetDisplayOrder=${['language', 'creator'] as FacetOption[]}
|
|
636
|
-
></collection-facets>`,
|
|
637
|
-
);
|
|
638
|
-
|
|
639
|
-
const aggs: Record<string, Aggregation> = {
|
|
640
|
-
mediatype: new Aggregation({
|
|
641
|
-
buckets: [{ key: 'texts', doc_count: 5 }],
|
|
642
|
-
}),
|
|
643
|
-
collection: new Aggregation({
|
|
644
|
-
buckets: [{ key: 'foo', doc_count: 10 }],
|
|
645
|
-
}),
|
|
646
|
-
creator: new Aggregation({
|
|
647
|
-
buckets: [{ key: 'bar', doc_count: 15 }],
|
|
648
|
-
}),
|
|
649
|
-
language: new Aggregation({
|
|
650
|
-
buckets: [{ key: 'baz', doc_count: 20 }],
|
|
651
|
-
}),
|
|
652
|
-
};
|
|
653
|
-
|
|
654
|
-
el.aggregations = aggs;
|
|
655
|
-
await el.updateComplete;
|
|
656
|
-
|
|
657
|
-
const facetHeaders = el.shadowRoot?.querySelectorAll('.facet-group-header');
|
|
658
|
-
|
|
659
|
-
// The only two facet groups should be Language and Creator (in that order)
|
|
660
|
-
expect(facetHeaders?.length).to.equal(2);
|
|
661
|
-
expect(facetHeaders?.[0].textContent).to.contain('Language');
|
|
662
|
-
expect(facetHeaders?.[1].textContent).to.contain('Creator');
|
|
663
|
-
});
|
|
664
|
-
|
|
665
632
|
describe('More Facets', () => {
|
|
666
633
|
it('Does not render < allowedFacetCount', async () => {
|
|
667
634
|
const el = await fixture<CollectionFacets>(
|
|
@@ -100,7 +100,7 @@ describe('Restoration state handler', () => {
|
|
|
100
100
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
101
101
|
|
|
102
102
|
const restorationState = handler.getRestorationState();
|
|
103
|
-
expect(restorationState.selectedFacets.year
|
|
103
|
+
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
104
104
|
'selected',
|
|
105
105
|
);
|
|
106
106
|
});
|
|
@@ -160,7 +160,7 @@ describe('Restoration state handler', () => {
|
|
|
160
160
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
161
161
|
|
|
162
162
|
const restorationState = handler.getRestorationState();
|
|
163
|
-
expect(restorationState.selectedFacets.subject
|
|
163
|
+
expect(restorationState.selectedFacets.subject.foo.state).to.equal(
|
|
164
164
|
'selected',
|
|
165
165
|
);
|
|
166
166
|
});
|
|
@@ -173,7 +173,7 @@ describe('Restoration state handler', () => {
|
|
|
173
173
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
174
174
|
|
|
175
175
|
const restorationState = handler.getRestorationState();
|
|
176
|
-
expect(restorationState.selectedFacets.year
|
|
176
|
+
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
177
177
|
'hidden',
|
|
178
178
|
);
|
|
179
179
|
});
|
|
@@ -188,17 +188,17 @@ describe('Restoration state handler', () => {
|
|
|
188
188
|
|
|
189
189
|
const restorationState = handler.getRestorationState();
|
|
190
190
|
|
|
191
|
-
expect(restorationState.selectedFacets.collection
|
|
191
|
+
expect(restorationState.selectedFacets.collection.foo.state).to.equal(
|
|
192
192
|
'selected',
|
|
193
193
|
);
|
|
194
|
-
expect(restorationState.selectedFacets.collection
|
|
194
|
+
expect(restorationState.selectedFacets.collection.bar.state).to.equal(
|
|
195
195
|
'selected',
|
|
196
196
|
);
|
|
197
197
|
|
|
198
|
-
expect(restorationState.selectedFacets.collection
|
|
198
|
+
expect(restorationState.selectedFacets.collection.baz.state).to.equal(
|
|
199
199
|
'hidden',
|
|
200
200
|
);
|
|
201
|
-
expect(restorationState.selectedFacets.collection
|
|
201
|
+
expect(restorationState.selectedFacets.collection.boop.state).to.equal(
|
|
202
202
|
'hidden',
|
|
203
203
|
);
|
|
204
204
|
});
|
|
@@ -211,7 +211,7 @@ describe('Restoration state handler', () => {
|
|
|
211
211
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
212
212
|
|
|
213
213
|
const restorationState = handler.getRestorationState();
|
|
214
|
-
expect(restorationState.selectedFacets.collection
|
|
214
|
+
expect(restorationState.selectedFacets.collection.foo.state).to.equal(
|
|
215
215
|
'hidden',
|
|
216
216
|
);
|
|
217
217
|
});
|
|
@@ -224,7 +224,7 @@ describe('Restoration state handler', () => {
|
|
|
224
224
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
225
225
|
|
|
226
226
|
const restorationState = handler.getRestorationState();
|
|
227
|
-
expect(restorationState.selectedFacets.subject
|
|
227
|
+
expect(restorationState.selectedFacets.subject.foo.state).to.equal(
|
|
228
228
|
'selected',
|
|
229
229
|
);
|
|
230
230
|
});
|
|
@@ -237,7 +237,7 @@ describe('Restoration state handler', () => {
|
|
|
237
237
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
238
238
|
|
|
239
239
|
const restorationState = handler.getRestorationState();
|
|
240
|
-
expect(restorationState.selectedFacets.year
|
|
240
|
+
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
241
241
|
'hidden',
|
|
242
242
|
);
|
|
243
243
|
});
|
|
@@ -247,7 +247,7 @@ describe('Item Tile', () => {
|
|
|
247
247
|
|
|
248
248
|
it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
|
|
249
249
|
const model: Partial<TileModel> = {
|
|
250
|
-
datePublished: new Date(2012
|
|
250
|
+
datePublished: new Date('2012-01-01T00:00:00Z'),
|
|
251
251
|
};
|
|
252
252
|
|
|
253
253
|
const el = await fixture<ItemTile>(html`
|
|
@@ -161,7 +161,7 @@ describe('List Tile Compact', () => {
|
|
|
161
161
|
|
|
162
162
|
it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
|
|
163
163
|
const model: Partial<TileModel> = {
|
|
164
|
-
datePublished: new Date(2012
|
|
164
|
+
datePublished: new Date('2012-01-01T00:00:00Z'),
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
const el = await fixture<TileListCompact>(html`
|
|
@@ -216,9 +216,9 @@ describe('List Tile', () => {
|
|
|
216
216
|
expect(dateRow?.textContent?.trim()).to.contain('Reviewed: Jan 02, 2013');
|
|
217
217
|
});
|
|
218
218
|
|
|
219
|
-
it('should only show the year for a date published of Jan 1 at midnight', async () => {
|
|
219
|
+
it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
|
|
220
220
|
const model: Partial<TileModel> = {
|
|
221
|
-
datePublished: new Date(2012
|
|
221
|
+
datePublished: new Date('2012-01-01T00:00:00Z'),
|
|
222
222
|
};
|
|
223
223
|
|
|
224
224
|
const el = await fixture<TileList>(html`
|
|
@@ -234,7 +234,7 @@ describe('List Tile', () => {
|
|
|
234
234
|
expect(dateRow?.textContent?.trim()).to.contain('Published: 2012');
|
|
235
235
|
});
|
|
236
236
|
|
|
237
|
-
it('should show full date added/archived/reviewed, even on Jan 1 at midnight', async () => {
|
|
237
|
+
it('should show full date added/archived/reviewed, even on Jan 1 at midnight UTC', async () => {
|
|
238
238
|
const model: Partial<TileModel> = {
|
|
239
239
|
dateAdded: new Date(2010, 0, 1, 0, 0, 0, 0),
|
|
240
240
|
dateArchived: new Date(2011, 0, 1, 0, 0, 0, 0),
|
|
@@ -16,18 +16,18 @@ describe('localDateFromUTC', () => {
|
|
|
16
16
|
|
|
17
17
|
describe('isFirstMillisecondOfUTCYear', () => {
|
|
18
18
|
it('returns true when date is exactly Jan 1 at midnight in UTC', async () => {
|
|
19
|
-
const midnightOnNewYearsDay = new Date(2010
|
|
19
|
+
const midnightOnNewYearsDay = new Date('2010-01-01T00:00:00Z');
|
|
20
20
|
expect(isFirstMillisecondOfUTCYear(midnightOnNewYearsDay)).to.be.true;
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('returns false when date is not exactly Jan 1 at midnight in UTC', async () => {
|
|
24
|
-
const oneMillisecondTooEarly = new Date(2009
|
|
24
|
+
const oneMillisecondTooEarly = new Date('2009-12-31T23:59:59.999Z');
|
|
25
25
|
expect(isFirstMillisecondOfUTCYear(oneMillisecondTooEarly)).to.be.false;
|
|
26
26
|
|
|
27
|
-
const oneMillisecondTooLate = new Date(2010
|
|
27
|
+
const oneMillisecondTooLate = new Date('2010-01-01T00:00:00.001Z');
|
|
28
28
|
expect(isFirstMillisecondOfUTCYear(oneMillisecondTooLate)).to.be.false;
|
|
29
29
|
|
|
30
|
-
const middleOfTheYear = new Date(2010
|
|
30
|
+
const middleOfTheYear = new Date('2010-06-01T00:00:00Z');
|
|
31
31
|
expect(isFirstMillisecondOfUTCYear(middleOfTheYear)).to.be.false;
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -1,30 +1,30 @@
|
|
|
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
|
-
nodeResolve: true,
|
|
8
|
-
open: '/',
|
|
9
|
-
watch: !hmr,
|
|
10
|
-
|
|
11
|
-
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
12
|
-
// esbuildTarget: 'auto'
|
|
13
|
-
|
|
14
|
-
/** Set appIndex to enable SPA routing */
|
|
15
|
-
// appIndex: 'demo/index.html',
|
|
16
|
-
|
|
17
|
-
/** Confgure bare import resolve plugin */
|
|
18
|
-
// nodeResolve: {
|
|
19
|
-
// exportConditions: ['browser', 'development']
|
|
20
|
-
// },
|
|
21
|
-
|
|
22
|
-
plugins: [
|
|
23
|
-
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
24
|
-
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
25
|
-
],
|
|
26
|
-
|
|
27
|
-
http2: true,
|
|
28
|
-
sslCert: './local.archive.org.cert',
|
|
29
|
-
sslKey: './local.archive.org.key',
|
|
30
|
-
});
|
|
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
|
+
nodeResolve: true,
|
|
8
|
+
open: '/',
|
|
9
|
+
watch: !hmr,
|
|
10
|
+
|
|
11
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
12
|
+
// esbuildTarget: 'auto'
|
|
13
|
+
|
|
14
|
+
/** Set appIndex to enable SPA routing */
|
|
15
|
+
// appIndex: 'demo/index.html',
|
|
16
|
+
|
|
17
|
+
/** Confgure bare import resolve plugin */
|
|
18
|
+
// nodeResolve: {
|
|
19
|
+
// exportConditions: ['browser', 'development']
|
|
20
|
+
// },
|
|
21
|
+
|
|
22
|
+
plugins: [
|
|
23
|
+
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
24
|
+
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
http2: true,
|
|
28
|
+
sslCert: './local.archive.org.cert',
|
|
29
|
+
sslKey: './local.archive.org.key',
|
|
30
|
+
});
|
|
@@ -1,41 +1,41 @@
|
|
|
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: 'dist/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
|
-
});
|
|
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: 'dist/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
|
+
});
|