@internetarchive/collection-browser 2.10.1-alpha-webdev7090.14 → 2.10.1-alpha-webdev7090.15
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/dist/src/collection-browser.d.ts +1 -0
- package/dist/src/collection-browser.js +5 -1
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/test/collection-browser.test.js +6 -8
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/tile-stats.test.js +7 -8
- package/dist/test/tile-stats.test.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +3 -1
- package/test/collection-browser.test.ts +7 -12
- package/test/tile-stats.test.ts +9 -8
|
@@ -13,7 +13,7 @@ describe('Tile Stats', () => {
|
|
|
13
13
|
expect(statsRowCount).to.equal(4);
|
|
14
14
|
});
|
|
15
15
|
it('should render component with value', async () => {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
17
17
|
const el = await fixture(html `
|
|
18
18
|
<tile-stats
|
|
19
19
|
.mediatype=${'account'}
|
|
@@ -26,16 +26,15 @@ describe('Tile Stats', () => {
|
|
|
26
26
|
const statsRow = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#stats-row');
|
|
27
27
|
const mediatypeStat = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(0);
|
|
28
28
|
// get second column item in stats row
|
|
29
|
-
const itemStatCount = (_c = (_b = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(1)) === null || _b === void 0 ? void 0 : _b.querySelector('.status-text')) === null || _c === void 0 ? void 0 : _c.textContent;
|
|
29
|
+
const itemStatCount = (_d = (_c = (_b = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(1)) === null || _b === void 0 ? void 0 : _b.querySelector('.status-text')) === null || _c === void 0 ? void 0 : _c.textContent) === null || _d === void 0 ? void 0 : _d.trim();
|
|
30
30
|
// get third column item in stats row
|
|
31
|
-
const favoritesStatCount = (
|
|
31
|
+
const favoritesStatCount = (_g = (_f = (_e = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(2)) === null || _e === void 0 ? void 0 : _e.querySelector('.status-text')) === null || _f === void 0 ? void 0 : _f.textContent) === null || _g === void 0 ? void 0 : _g.trim();
|
|
32
32
|
// get fourth column item in stats row
|
|
33
|
-
const reviewsStatCount = (
|
|
33
|
+
const reviewsStatCount = (_k = (_j = (_h = statsRow === null || statsRow === void 0 ? void 0 : statsRow.children.item(3)) === null || _h === void 0 ? void 0 : _h.querySelector('.status-text')) === null || _j === void 0 ? void 0 : _j.textContent) === null || _k === void 0 ? void 0 : _k.trim();
|
|
34
34
|
expect(mediatypeStat).to.exist;
|
|
35
|
-
|
|
36
|
-
expect(
|
|
37
|
-
expect(
|
|
38
|
-
expect(reviewsStatCount).to.equalSnapshot(3);
|
|
35
|
+
expect(itemStatCount).to.match(/Uploads:\s+1/);
|
|
36
|
+
expect(favoritesStatCount).to.match(/Favorites:\s+2/);
|
|
37
|
+
expect(reviewsStatCount).to.match(/Reviews:\s+3/);
|
|
39
38
|
});
|
|
40
39
|
it('should render view count for non-account items', async () => {
|
|
41
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile-stats.test.js","sourceRoot":"","sources":["../../test/tile-stats.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,8BAA8B,CAAC;AAEtC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;;QAC/C,MAAM,EAAE,GAAG,MAAM,OAAO,CAAY,IAAI,CAAA,2BAA2B,CAAC,CAAC;QAErE,M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CAAC;QACxB,qCAAqC;QACrC,MAAM,kBAAkB,GAAG,MAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAC1C,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAC7B,WAAW,0CAAE,IAAI,EAAE,CAAC;QACxB,sCAAsC;QACtC,MAAM,gBAAgB,GAAG,MAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CACxC,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAC7B,WAAW,0CAAE,IAAI,EAAE,CAAC;QAExB,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC/B,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC/C,MAAM,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtD,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport type { TileStats } from '../src/tiles/grid/tile-stats';\n\nimport '../src/tiles/grid/tile-stats';\n\ndescribe('Tile Stats', () => {\n it('should render initial component', async () => {\n const el = await fixture<TileStats>(html`<tile-stats></tile-stats>`);\n\n const itemStats = el.shadowRoot?.querySelector('.item-stats');\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n const statsRowCount = statsRow?.childElementCount;\n\n expect(itemStats).to.exist;\n expect(statsRow).to.exist;\n expect(statsRowCount).to.equal(4);\n });\n\n it('should render component with value', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats\n .mediatype=${'account'}\n .itemCount=${1}\n .favCount=${2}\n .commentCount=${3}\n >\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const itemStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')?.textContent;\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')?.textContent;\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')?.textContent;\n\n expect(mediatypeStat).to.exist;\n\n // Snapshot testing - reference: https://open-wc.org/docs/testing/semantic-dom-diff/#snapshot-testing\n expect(itemStatCount).to.equalSnapshot(1);\n expect(favoritesStatCount).to.equalSnapshot(2);\n expect(reviewsStatCount).to.equalSnapshot(3);\n });\n\n it('should render view count for non-account items', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats\n .mediatype=${'texts'}\n .viewCount=${4}\n .favCount=${5}\n .commentCount=${6}\n >\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const viewStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n\n expect(mediatypeStat).to.exist;\n expect(viewStatCount).to.match(/Views:\\s+4/);\n expect(favoritesStatCount).to.match(/Favorites:\\s+5/);\n expect(reviewsStatCount).to.match(/Reviews:\\s+6/);\n });\n\n it('handles missing counts gracefully', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats .mediatype=${'texts'} .favCount=${5} .commentCount=${6}>\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const viewStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n\n expect(mediatypeStat).to.exist;\n expect(viewStatCount).to.match(/Views:\\s+0/);\n expect(favoritesStatCount).to.match(/Favorites:\\s+5/);\n expect(reviewsStatCount).to.match(/Reviews:\\s+6/);\n });\n\n it('handles missing counts gracefully for accounts', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats .mediatype=${'account'} .favCount=${5} .commentCount=${6}>\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const itemStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n\n expect(mediatypeStat).to.exist;\n expect(itemStatCount).to.match(/Uploads:\\s+0/);\n expect(favoritesStatCount).to.match(/Favorites:\\s+5/);\n expect(reviewsStatCount).to.match(/Reviews:\\s+6/);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"tile-stats.test.js","sourceRoot":"","sources":["../../test/tile-stats.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,8BAA8B,CAAC;AAEtC,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAA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MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CACrC,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAC7B,WAAW,0CAAE,IAAI,EAAE,CAAC;QACxB,qCAAqC;QACrC,MAAM,kBAAkB,GAAG,MAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAC1C,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAC7B,WAAW,0CAAE,IAAI,EAAE,CAAC;QACxB,sCAAsC;QACtC,MAAM,gBAAgB,GAAG,MAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CACxC,IAAI,CAAC,CAAC,CAAC,0CACN,aAAa,CAAC,cAAc,CAAC,0CAC7B,WAAW,0CAAE,IAAI,EAAE,CAAC;QAExB,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC/B,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC/C,MAAM,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtD,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport type { TileStats } from '../src/tiles/grid/tile-stats';\n\nimport '../src/tiles/grid/tile-stats';\n\ndescribe('Tile Stats', () => {\n it('should render initial component', async () => {\n const el = await fixture<TileStats>(html`<tile-stats></tile-stats>`);\n\n const itemStats = el.shadowRoot?.querySelector('.item-stats');\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n const statsRowCount = statsRow?.childElementCount;\n\n expect(itemStats).to.exist;\n expect(statsRow).to.exist;\n expect(statsRowCount).to.equal(4);\n });\n\n it('should render component with value', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats\n .mediatype=${'account'}\n .itemCount=${1}\n .favCount=${2}\n .commentCount=${3}\n >\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const itemStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n\n expect(mediatypeStat).to.exist;\n expect(itemStatCount).to.match(/Uploads:\\s+1/);\n expect(favoritesStatCount).to.match(/Favorites:\\s+2/);\n expect(reviewsStatCount).to.match(/Reviews:\\s+3/);\n });\n\n it('should render view count for non-account items', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats\n .mediatype=${'texts'}\n .viewCount=${4}\n .favCount=${5}\n .commentCount=${6}\n >\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const viewStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n\n expect(mediatypeStat).to.exist;\n expect(viewStatCount).to.match(/Views:\\s+4/);\n expect(favoritesStatCount).to.match(/Favorites:\\s+5/);\n expect(reviewsStatCount).to.match(/Reviews:\\s+6/);\n });\n\n it('handles missing counts gracefully', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats .mediatype=${'texts'} .favCount=${5} .commentCount=${6}>\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const viewStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n\n expect(mediatypeStat).to.exist;\n expect(viewStatCount).to.match(/Views:\\s+0/);\n expect(favoritesStatCount).to.match(/Favorites:\\s+5/);\n expect(reviewsStatCount).to.match(/Reviews:\\s+6/);\n });\n\n it('handles missing counts gracefully for accounts', async () => {\n const el = await fixture<TileStats>(html`\n <tile-stats .mediatype=${'account'} .favCount=${5} .commentCount=${6}>\n </tile-stats>\n `);\n\n const statsRow = el.shadowRoot?.querySelector('#stats-row');\n\n const mediatypeStat = statsRow?.children.item(0);\n // get second column item in stats row\n const itemStatCount = statsRow?.children\n .item(1)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get third column item in stats row\n const favoritesStatCount = statsRow?.children\n .item(2)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n // get fourth column item in stats row\n const reviewsStatCount = statsRow?.children\n .item(3)\n ?.querySelector('.status-text')\n ?.textContent?.trim();\n\n expect(mediatypeStat).to.exist;\n expect(itemStatCount).to.match(/Uploads:\\s+0/);\n expect(favoritesStatCount).to.match(/Favorites:\\s+5/);\n expect(reviewsStatCount).to.match(/Reviews:\\s+6/);\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "The Internet Archive Collection Browser.",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"author": "Internet Archive",
|
|
6
|
-
"version": "2.10.1-alpha-webdev7090.
|
|
6
|
+
"version": "2.10.1-alpha-webdev7090.15",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.js",
|
|
9
9
|
"scripts": {
|
|
@@ -250,6 +250,8 @@ export class CollectionBrowser
|
|
|
250
250
|
/** Whether to display a smart results carousel above the full results */
|
|
251
251
|
@property({ type: Boolean, reflect: true }) showSmartResults = false;
|
|
252
252
|
|
|
253
|
+
@property({ type: String }) resultsHeader?: string;
|
|
254
|
+
|
|
253
255
|
/**
|
|
254
256
|
* The maximum number of pages we will load when a privileged user clicks
|
|
255
257
|
* the "Manage" button on the search page. Limited to 15 pages.
|
|
@@ -693,7 +695,7 @@ export class CollectionBrowser
|
|
|
693
695
|
<section id="results">
|
|
694
696
|
${this.showSmartResults
|
|
695
697
|
? html`<h2 class="results-section-heading">
|
|
696
|
-
${msg('All results')}
|
|
698
|
+
${this.resultsHeader ?? msg('All results')}
|
|
697
699
|
</h2>`
|
|
698
700
|
: nothing}
|
|
699
701
|
<div id="cb-top-view">
|
|
@@ -360,7 +360,7 @@ describe('Collection Browser', () => {
|
|
|
360
360
|
|
|
361
361
|
el.baseQuery = 'collection:foo';
|
|
362
362
|
await el.updateComplete;
|
|
363
|
-
await
|
|
363
|
+
await el.initialSearchComplete;
|
|
364
364
|
|
|
365
365
|
expect(searchService.searchParams?.query).to.equal('collection:foo');
|
|
366
366
|
expect(searchService.searchType).to.equal(SearchType.FULLTEXT);
|
|
@@ -940,6 +940,7 @@ describe('Collection Browser', () => {
|
|
|
940
940
|
el.sortDirection = 'asc';
|
|
941
941
|
el.selectedCreatorFilter = 'X';
|
|
942
942
|
await el.updateComplete;
|
|
943
|
+
await el.initialSearchComplete;
|
|
943
944
|
await nextTick();
|
|
944
945
|
|
|
945
946
|
expect(searchService.searchParams?.query).to.equal('first-creator');
|
|
@@ -1005,7 +1006,7 @@ describe('Collection Browser', () => {
|
|
|
1005
1006
|
expect(el.maxSelectedDate).to.equal('2000');
|
|
1006
1007
|
});
|
|
1007
1008
|
|
|
1008
|
-
it('emits event when
|
|
1009
|
+
it('emits event when results start and end loading', async () => {
|
|
1009
1010
|
const spy = sinon.spy();
|
|
1010
1011
|
const searchService = new MockSearchService();
|
|
1011
1012
|
const el = await fixture<CollectionBrowser>(
|
|
@@ -1014,6 +1015,7 @@ describe('Collection Browser', () => {
|
|
|
1014
1015
|
@searchResultsLoadingChanged=${spy}
|
|
1015
1016
|
></collection-browser>`,
|
|
1016
1017
|
);
|
|
1018
|
+
spy.resetHistory();
|
|
1017
1019
|
|
|
1018
1020
|
el.baseQuery = 'collection:foo';
|
|
1019
1021
|
await el.updateComplete;
|
|
@@ -1040,17 +1042,10 @@ describe('Collection Browser', () => {
|
|
|
1040
1042
|
await el.updateComplete;
|
|
1041
1043
|
await aTimeout(50);
|
|
1042
1044
|
|
|
1043
|
-
const infiniteScroller = el.shadowRoot?.querySelector('infinite-scroller');
|
|
1044
|
-
expect(infiniteScroller).to.exist;
|
|
1045
|
-
|
|
1046
|
-
const firstResult =
|
|
1047
|
-
infiniteScroller!.shadowRoot?.querySelector('tile-dispatcher');
|
|
1048
|
-
expect(firstResult).to.exist;
|
|
1049
|
-
|
|
1050
1045
|
// Original href q param starts/ends with %22%22, but should be collapsed to %22 before render
|
|
1051
|
-
expect(
|
|
1052
|
-
|
|
1053
|
-
)
|
|
1046
|
+
expect(el.dataSource.getTileModelAt(0)?.href).to.equal(
|
|
1047
|
+
'/details/foo?q=%22quoted+query%22',
|
|
1048
|
+
);
|
|
1054
1049
|
});
|
|
1055
1050
|
|
|
1056
1051
|
it('sets default sort from collection metadata', async () => {
|
package/test/tile-stats.test.ts
CHANGED
|
@@ -34,22 +34,23 @@ describe('Tile Stats', () => {
|
|
|
34
34
|
// get second column item in stats row
|
|
35
35
|
const itemStatCount = statsRow?.children
|
|
36
36
|
.item(1)
|
|
37
|
-
?.querySelector('.status-text')
|
|
37
|
+
?.querySelector('.status-text')
|
|
38
|
+
?.textContent?.trim();
|
|
38
39
|
// get third column item in stats row
|
|
39
40
|
const favoritesStatCount = statsRow?.children
|
|
40
41
|
.item(2)
|
|
41
|
-
?.querySelector('.status-text')
|
|
42
|
+
?.querySelector('.status-text')
|
|
43
|
+
?.textContent?.trim();
|
|
42
44
|
// get fourth column item in stats row
|
|
43
45
|
const reviewsStatCount = statsRow?.children
|
|
44
46
|
.item(3)
|
|
45
|
-
?.querySelector('.status-text')
|
|
47
|
+
?.querySelector('.status-text')
|
|
48
|
+
?.textContent?.trim();
|
|
46
49
|
|
|
47
50
|
expect(mediatypeStat).to.exist;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
expect(
|
|
51
|
-
expect(favoritesStatCount).to.equalSnapshot(2);
|
|
52
|
-
expect(reviewsStatCount).to.equalSnapshot(3);
|
|
51
|
+
expect(itemStatCount).to.match(/Uploads:\s+1/);
|
|
52
|
+
expect(favoritesStatCount).to.match(/Favorites:\s+2/);
|
|
53
|
+
expect(reviewsStatCount).to.match(/Reviews:\s+3/);
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
it('should render view count for non-account items', async () => {
|