@internetarchive/ia-topnav 1.4.0 → 1.4.1-alpha-webdev8259.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.
@@ -9,35 +9,9 @@ import {
9
9
 
10
10
  import '../src/ia-topnav';
11
11
  import { IATopNav } from '../src/ia-topnav';
12
- import { SearchMenu } from '../src/search-menu';
13
12
  import { SignedOutDropdown } from '../src/signed-out-dropdown';
14
13
  import UserMenu from '../src/user-menu';
15
14
 
16
- // const container = (
17
- // {
18
- // username = '',
19
- // screenName = '',
20
- // config = {},
21
- // localLinks = true,
22
- // secondIdentitySlotMode = '',
23
- // }: {
24
- // username?: string;
25
- // screenName?: string;
26
- // config?: IATopNavConfig;
27
- // localLinks: boolean;
28
- // secondIdentitySlotMode?: IATopNavSecondIdentitySlotMode;
29
- // } = {
30
- // localLinks: true,
31
- // },
32
- // ) =>
33
- // html`<ia-topnav
34
- // .screenName=${screenName}
35
- // username=${username}
36
- // ?localLinks=${localLinks}
37
- // .config=${config}
38
- // .secondIdentitySlotMode=${secondIdentitySlotMode}
39
- // ></ia-topnav>`;
40
-
41
15
  const verifyClosed = (instance: IATopNav) => {
42
16
  expect(instance.mediaSliderOpen).to.be.false;
43
17
  expect(instance.selectedMenuOption).to.equal('');
@@ -53,25 +27,6 @@ afterEach(() => {
53
27
  });
54
28
 
55
29
  describe('<ia-topnav>', () => {
56
- it('assigns a value to "search in" from outside event', async () => {
57
- const el = await fixture<IATopNav>(html` <ia-topnav></ia-topnav>`);
58
- const query = 'atari';
59
- const searchMenu = el.shadowRoot?.querySelector(
60
- 'search-menu',
61
- ) as SearchMenu;
62
-
63
- const inputEvent = new InputEvent('input');
64
- Object.defineProperty(inputEvent, 'target', {
65
- value: { value: query },
66
- writable: false,
67
- });
68
-
69
- searchMenu?.searchInChanged(inputEvent);
70
- await el.updateComplete;
71
-
72
- expect(el.searchIn).to.equal(query);
73
- });
74
-
75
30
  it('dispatches an analyticsClick event when trackClick event fired', async () => {
76
31
  const el = await fixture<IATopNav>(html` <ia-topnav></ia-topnav>`);
77
32
  const clickEvent = new MouseEvent('click');
@@ -87,22 +42,6 @@ describe('<ia-topnav>', () => {
87
42
  expect(response).to.exist;
88
43
  });
89
44
 
90
- it('dispatches an analyticsSubmit event when trackSubmit event fired', async () => {
91
- const el = await fixture<IATopNav>(html` <ia-topnav></ia-topnav>`);
92
- const submitEvent = new Event('submit');
93
- const form = el.shadowRoot
94
- ?.querySelector('primary-nav')
95
- ?.shadowRoot?.querySelector('nav-search')
96
- ?.shadowRoot?.querySelector('form');
97
-
98
- form?.addEventListener('submit', (e) => e.preventDefault());
99
- (form?.querySelector('[name=query]') as HTMLInputElement).value = 'atari';
100
- setTimeout(() => form?.dispatchEvent(submitEvent));
101
- const response = await oneEvent(el, 'trackSubmit');
102
-
103
- expect(response).to.exist;
104
- });
105
-
106
45
  it('closes all menus when close-layer clicked', async () => {
107
46
  const el = await fixture<IATopNav>(html` <ia-topnav></ia-topnav>`);
108
47
 
@@ -190,17 +129,6 @@ describe('<ia-topnav>', () => {
190
129
  expect(el.selectedMenuOption).to.equal('');
191
130
  });
192
131
 
193
- it('toggles search menu tabindex when dropdown open', async () => {
194
- const el = await fixture<IATopNav>(html` <ia-topnav></ia-topnav>`);
195
-
196
- el.openMenu = 'search';
197
- await el.updateComplete;
198
-
199
- expect(
200
- el.shadowRoot?.querySelector('search-menu')?.getAttribute('tabindex'),
201
- ).to.equal('');
202
- });
203
-
204
132
  it('toggles user menu tabindex when dropdown open', async () => {
205
133
  const el = await fixture<IATopNav>(
206
134
  html` <ia-topnav username="shaneriley" ?localLinks=${false}></ia-topnav>`,
@@ -246,11 +174,6 @@ describe('<ia-topnav>', () => {
246
174
  screenName="shaneriley"
247
175
  ?localLinks=${false}
248
176
  ></ia-topnav>`,
249
- // container({
250
- // username: 'shaneriley',
251
- // screenName: 'shaneriley',
252
- // localLinks: false,
253
- // }),
254
177
  );
255
178
 
256
179
  (
@@ -282,7 +205,6 @@ describe('<ia-topnav>', () => {
282
205
  'primary-nav',
283
206
  'media-slider',
284
207
  'desktop-subnav',
285
- 'search-menu',
286
208
  ];
287
209
  componentSelectors.forEach((selector) => {
288
210
  const component = el.shadowRoot?.querySelector(selector) as unknown as {
@@ -313,6 +235,24 @@ describe('<ia-topnav>', () => {
313
235
  });
314
236
  });
315
237
 
238
+ describe('search slot', () => {
239
+ it('forwards custom-search slot to primary-nav', async () => {
240
+ const el = await fixture<IATopNav>(html`<ia-topnav></ia-topnav>`);
241
+ await el.updateComplete;
242
+
243
+ const primaryNav = el.shadowRoot?.querySelector('primary-nav');
244
+ const slot = primaryNav?.querySelector('slot[name="custom-search"]');
245
+ expect(slot).to.exist;
246
+ });
247
+
248
+ it('does not render search-menu', async () => {
249
+ const el = await fixture<IATopNav>(html`<ia-topnav></ia-topnav>`);
250
+ await el.updateComplete;
251
+
252
+ expect(el.shadowRoot?.querySelector('search-menu')).to.not.exist;
253
+ });
254
+ });
255
+
316
256
  describe('slot pass throughs', () => {
317
257
  describe('slot for <primary-nav>', () => {
318
258
  it('opens a slot with `secondIdentitySlotMode`', async () => {
@@ -327,15 +267,14 @@ describe('<ia-topnav>', () => {
327
267
 
328
268
  const slot = el.shadowRoot
329
269
  ?.querySelector('primary-nav')
330
- ?.querySelector('slot');
270
+ ?.querySelector('slot[name="opt-sec-logo"]');
331
271
  expect(slot).to.exist;
332
- expect(slot?.getAttribute('name')).to.equal('opt-sec-logo');
333
272
 
334
273
  el.secondIdentitySlotMode = '';
335
274
  await elementUpdated(el);
336
275
  const noSlot = el.shadowRoot
337
276
  ?.querySelector('primary-nav')
338
- ?.querySelector('slot');
277
+ ?.querySelector('slot[name="opt-sec-logo"]');
339
278
  expect(noSlot).to.not.exist;
340
279
  });
341
280
  });
@@ -50,7 +50,7 @@ describe('<primary-nav>', () => {
50
50
  expect(el.shadowRoot?.querySelector('login-button')).to.not.be.undefined;
51
51
  });
52
52
 
53
- it('does not render search menu toggle and search form if hideSearch true', async () => {
53
+ it('does not render search trigger or search slot if hideSearch true', async () => {
54
54
  const el = await fixture<PrimaryNav>(
55
55
  component({
56
56
  baseHost: 'archive.org',
@@ -61,7 +61,49 @@ describe('<primary-nav>', () => {
61
61
  );
62
62
 
63
63
  expect(el.shadowRoot?.querySelector('.search-trigger')).to.equal(null);
64
- expect(el.shadowRoot?.querySelector('nav-search')).to.equal(null);
64
+ expect(el.shadowRoot?.querySelector('.custom-search-container')).to.not
65
+ .exist;
66
+ });
67
+
68
+ it('renders custom-search slot container', async () => {
69
+ const el = await fixture<PrimaryNav>(
70
+ component({
71
+ baseHost: 'archive.org',
72
+ username: 'testuser',
73
+ screenName: 'testuser',
74
+ }),
75
+ );
76
+
77
+ expect(el.shadowRoot?.querySelector('.custom-search-container')).to.exist;
78
+
79
+ const slot = el.shadowRoot?.querySelector<HTMLSlotElement>(
80
+ 'slot[name="custom-search"]',
81
+ );
82
+ expect(slot).to.exist;
83
+ });
84
+
85
+ it('renders search trigger button for mobile toggle', async () => {
86
+ const el = await fixture<PrimaryNav>(
87
+ component({
88
+ baseHost: 'archive.org',
89
+ username: 'testuser',
90
+ screenName: 'testuser',
91
+ }),
92
+ );
93
+
94
+ expect(el.shadowRoot?.querySelector('.search-trigger')).to.exist;
95
+ });
96
+
97
+ it('does not render nav-search', async () => {
98
+ const el = await fixture<PrimaryNav>(
99
+ component({
100
+ baseHost: 'archive.org',
101
+ username: 'testuser',
102
+ screenName: 'testuser',
103
+ }),
104
+ );
105
+
106
+ expect(el.shadowRoot?.querySelector('nav-search')).to.not.exist;
65
107
  });
66
108
 
67
109
  it('opens a slot with `secondIdentitySlotMode`', async () => {
package/tsconfig.json CHANGED
@@ -1,31 +1,31 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "importHelpers": true,
13
- "outDir": "dist",
14
- "sourceMap": true,
15
- "inlineSources": true,
16
- "rootDir": "./",
17
- "declaration": true,
18
- "plugins": [
19
- {
20
- "name": "ts-lit-plugin"
21
- }
22
- ],
23
- "paths": {
24
- // workaround for: https://github.com/vitest-dev/vitest/issues/4567
25
- "rollup/parseAst": [
26
- "./node_modules/rollup/dist/parseAst"
27
- ]
28
- }
29
- },
30
- "include": ["**/*.ts"]
31
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2017", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "outDir": "dist",
14
+ "sourceMap": true,
15
+ "inlineSources": true,
16
+ "rootDir": "./",
17
+ "declaration": true,
18
+ "plugins": [
19
+ {
20
+ "name": "ts-lit-plugin"
21
+ }
22
+ ],
23
+ "paths": {
24
+ // workaround for: https://github.com/vitest-dev/vitest/issues/4567
25
+ "rollup/parseAst": [
26
+ "./node_modules/rollup/dist/parseAst"
27
+ ]
28
+ }
29
+ },
30
+ "include": ["**/*.ts"]
31
+ }
@@ -1,32 +1,32 @@
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: '/demo',
9
- watch: !hmr,
10
- sslCert: './ssl/server.crt',
11
- sslKey: './ssl/server.key',
12
- hostname: 'local.archive.org',
13
- http2: true,
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
- /** Configure bare import resolve plugin */
22
- // nodeResolve: {
23
- // exportConditions: ['browser', 'development']
24
- // },
25
-
26
- plugins: [
27
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
28
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
29
- ],
30
-
31
- // See documentation for all available options
32
- });
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: '/demo',
9
+ watch: !hmr,
10
+ sslCert: './ssl/server.crt',
11
+ sslKey: './ssl/server.key',
12
+ hostname: 'local.archive.org',
13
+ http2: true,
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
+ /** Configure bare import resolve plugin */
22
+ // nodeResolve: {
23
+ // exportConditions: ['browser', 'development']
24
+ // },
25
+
26
+ plugins: [
27
+ /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
28
+ // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
29
+ ],
30
+
31
+ // See documentation for all available options
32
+ });
@@ -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
+ });