@genesislcap/foundation-header 14.2.0 → 14.3.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"main.template.d.ts","sourceRoot":"","sources":["../../../src/main/main.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AA+CzC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,+BAwDvB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,UAAU,CAIpD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,UAAU,CAEpD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,UAAU,CAEjD,CAAC"}
1
+ {"version":3,"file":"main.template.d.ts","sourceRoot":"","sources":["../../../src/main/main.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAiEzC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,+BA8DvB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,UAAU,CAIpD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,UAAU,CAEpD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,UAAU,CAEjD,CAAC"}
@@ -4,21 +4,38 @@ const sideNavTemplate = html `
4
4
  position="left"
5
5
  ?closed=${(x) => !x.sideNavOpen}
6
6
  @closed=${(x) => x.toggleNavVisibility()}
7
+ data-test-id="side-nav"
7
8
  >
8
- <img slot="title" src=${(x) => x.logoSrc} class="logo" part="side-nav-logo" />
9
+ <img
10
+ slot="title"
11
+ src=${(x) => x.logoSrc}
12
+ class="logo"
13
+ part="side-nav-logo"
14
+ data-test-id="side-nav-logo"
15
+ />
9
16
  <slot name="menu-contents"></slot>
10
- <div slot="footer" class="logout-container" @click=${(x) => x.logout()}>
17
+ <div
18
+ slot="footer"
19
+ class="logout-container"
20
+ data-test-id="logout-button"
21
+ @click=${(x) => x.logout()}
22
+ >
11
23
  <zero-icon name="sign-out-alt"></zero-icon>
12
24
  Sign out
13
25
  </div>
14
26
  </zero-flyout>
15
27
  `;
16
28
  const defaultRouteButtonsTemplate = html `
17
- <zero-button appearance="neutral-grey" value="1" @click=${(x) => x.navigateTo('protected')}>
29
+ <zero-button
30
+ appearance="neutral-grey"
31
+ value="1"
32
+ @click=${(x) => x.navigateTo('protected')}
33
+ data-test-id="home-button"
34
+ >
18
35
  <zero-icon name="home"></zero-icon>
19
36
  Home
20
37
  </zero-button>
21
- <fast-option value="2" @click=${(x) => x.navigateTo('not-found')}>
38
+ <fast-option value="2" @click=${(x) => x.navigateTo('not-found')} data-test-id="profiles-button">
22
39
  <zero-icon name="users"></zero-icon>
23
40
  Profiles
24
41
  </fast-option>
@@ -31,6 +48,7 @@ const routeButtonsTemplate = html `
31
48
  slot="routes"
32
49
  value="${(x) => x.index}"
33
50
  @click=${(x, c) => c.parent.navigateTo(x.path)}
51
+ data-test-id="${(x) => x.testId}"
34
52
  >
35
53
  <zero-icon variant="${(x) => x.variant}" name="${(x) => x.icon}"></zero-icon>
36
54
  ${(x) => x.title}
@@ -53,21 +71,27 @@ const routeButtonsTemplate = html `
53
71
  */
54
72
  export const NavTemplate = html `
55
73
  ${when((x) => !x.hideSideBar, sideNavTemplate)}
56
- <div class="nav-listbox">
74
+ <div class="nav-listbox" data-test-id="nav-bar">
57
75
  <div class="nav-leftside">
58
76
  ${when((x) => !x.hideSideBar, html `
59
- <div class="bars-container" @click=${(x) => x.toggleNavVisibility()}>
77
+ <div
78
+ class="bars-container"
79
+ @click=${(x) => x.toggleNavVisibility()}
80
+ data-test-id="hamburger-menu"
81
+ >
60
82
  <zero-icon name="bars"></zero-icon>
61
83
  </div>
62
84
  `)}
63
- <div class="logo-container"><img src=${(x) => x.logoSrc} class="logo" part="logo" /></div>
64
- <slot name="routes">
85
+ <div class="logo-container">
86
+ <img src=${(x) => x.logoSrc} class="logo" part="logo" data-test-id="nav-bar-logo" />
87
+ </div>
88
+ <slot name="routes" data-test-id="route-buttons">
65
89
  ${(x) => (x.routeButtons ? routeButtonsTemplate : defaultRouteButtonsTemplate)}
66
90
  </slot>
67
91
  </div>
68
92
  <div class="nav-rightside">
69
93
  ${when((x) => x.showLuminanceToggleButton, html `
70
- <div class="icon-container">
94
+ <div class="icon-container" data-test-id="luminance-toggle-button">
71
95
  <zero-icon
72
96
  @click=${(x) => x.luminanceIconEvent()}
73
97
  variant="regular"
@@ -76,12 +100,12 @@ export const NavTemplate = html `
76
100
  </div>
77
101
  `)}
78
102
  ${when((x) => x.showMiscToggleButton, html `
79
- <div class="icon-container">
103
+ <div class="icon-container" data-test-id="misc-toggle-button">
80
104
  <zero-icon @click=${(x) => x.miscIconEvent()} name="th"></zero-icon>
81
105
  </div>
82
106
  `)}
83
107
  ${when((x) => x.showNotificationsButton, html `
84
- <div class="icon-container">
108
+ <div class="icon-container" data-test-id="notifications-button">
85
109
  <zero-icon
86
110
  variant="regular"
87
111
  @click=${(x) => x.notificationIconEvent()}
@@ -89,7 +113,7 @@ export const NavTemplate = html `
89
113
  ></zero-icon>
90
114
  </div>
91
115
  `)}
92
- <zero-button appearance="neutral-grey">
116
+ <zero-button appearance="neutral-grey" data-test-id="user-button">
93
117
  <zero-icon name="user-circle"></zero-icon>
94
118
  ${(x) => x.userName}
95
119
  </zero-button>
package/jsdom.setup.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@genesislcap/foundation-testing/jsdom';
package/package.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-header",
3
3
  "description": "Genesis Foundation Header",
4
- "version": "14.2.0",
4
+ "version": "14.3.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/esm/index.js",
7
- "types": "dist/dts/index.d.ts",
7
+ "types": "dist/foundation-header.d.ts",
8
8
  "config": {
9
9
  "PORT": 5010
10
10
  },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/foundation-header.d.ts",
14
+ "default": "./dist/esm/index.js"
15
+ },
16
+ "./e2e": {
17
+ "default": "./test/e2e/index.ts"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
11
21
  "scripts": {
12
22
  "api": "npm run api:extract && npm run api:document",
13
23
  "api:extract": "api-extractor run",
@@ -20,17 +30,30 @@
20
30
  "clean": "npm run clean:dist",
21
31
  "clean:dist": "node ../../../../build/clean dist tsconfig.build.tsbuildinfo",
22
32
  "copy-files": "copyfiles -u 1 src/**/*.{css,scss,ttf,png,svg} ./dist/esm",
23
- "dev": "npm run dev:webpack",
24
- "dev:webpack": "cross-env NODE_ENV=development webpack serve --open",
33
+ "dev": "npm run dev:webpack -- --open",
34
+ "dev:no-open": "npm run dev:webpack -- --no-open",
35
+ "dev:webpack": "cross-env NODE_ENV=development webpack serve",
25
36
  "dev:webpack:https": "npm run dev:webpack -- --https",
26
37
  "serve": "serve dist -p $npm_package_config_PORT",
27
- "test": "echo \"Error: no test specified\""
38
+ "test_": "npm run test:unit && npm run test:e2e",
39
+ "test:coverage": "c8 --include=src npm run test:unit",
40
+ "test:coverage:report": "npm run test:coverage && c8 report --reporter=text-lcov > coverage.lcov",
41
+ "test:coverage:report:nyc": "npm run test:unit:browser -- --cov && npx nyc report --reporter=html",
42
+ "test:e2e": "npx playwright test --config=./playwright.config.ts",
43
+ "test:e2e:debug": "npm run test:e2e -- --debug",
44
+ "test:e2e:ui": "npx playwright test --ui --config=./playwright.config.ts",
45
+ "test:unit": "npm run test:unit:node",
46
+ "test:unit:browser": "playwright-test \"./**/*.test.ts\" --runner uvu",
47
+ "test:unit:browser:watch": "npm run test:unit:browser -- -w -d",
48
+ "test:unit:node": "npm run test:unit:node:src && npm run test:unit:node:test",
49
+ "test:unit:node:src": "uvu -r tsm -r esm -r ./jsdom.setup.ts ./src \".*.test.ts\"",
50
+ "test:unit:node:test": "uvu -r tsm -r esm -r ./jsdom.setup.ts ./test/unit \".*.test.ts\"",
51
+ "test:unit:watch": "watchlist src test -- npm run test:unit"
28
52
  },
29
53
  "devDependencies": {
54
+ "@genesislcap/foundation-testing": "^14.3.0",
30
55
  "@microsoft/api-documenter": "^7.19.13",
31
56
  "@microsoft/api-extractor": "^7.31.1",
32
- "@module-federation/dashboard-plugin": "2.3.0",
33
- "@pixability-ui/federated-types": "^0.2.0",
34
57
  "@playwright/test": "^1.18.1",
35
58
  "c8": "^7.11.0",
36
59
  "camel-case": "^4.1.2",
@@ -41,9 +64,12 @@
41
64
  "cssnano": "^5.0.17",
42
65
  "esm": "^3.2.25",
43
66
  "file-loader": "^6.2.0",
67
+ "html-loader": "^3.1.0",
44
68
  "html-webpack-plugin": "^5.3.1",
45
69
  "jsdom": "^19.0.0",
70
+ "lighthouse": "^9.6.8",
46
71
  "mini-css-extract-plugin": "^2.5.3",
72
+ "playwright-lighthouse": "^2.2.2",
47
73
  "playwright-test": "^7.2.1",
48
74
  "portfinder-sync": "^0.0.2",
49
75
  "postcss": "^8.2.8",
@@ -66,10 +92,10 @@
66
92
  "webpack-merge": "^5.7.3"
67
93
  },
68
94
  "dependencies": {
69
- "@genesislcap/foundation-comms": "^14.2.0",
70
- "@genesislcap/foundation-events": "^14.2.0",
71
- "@genesislcap/foundation-utils": "^14.2.0",
72
- "@genesislcap/foundation-zero": "^14.2.0",
95
+ "@genesislcap/foundation-comms": "^14.3.0",
96
+ "@genesislcap/foundation-events": "^14.3.0",
97
+ "@genesislcap/foundation-utils": "^14.3.0",
98
+ "@genesislcap/foundation-zero": "^14.3.0",
73
99
  "@microsoft/fast-colors": "^5.1.4",
74
100
  "@microsoft/fast-components": "^2.21.3",
75
101
  "@microsoft/fast-element": "^1.7.0",
@@ -80,5 +106,5 @@
80
106
  "publishConfig": {
81
107
  "access": "public"
82
108
  },
83
- "gitHead": "183fc977ed1c952f92922c687c1a033095341bff"
109
+ "gitHead": "341eee9dfca9893a65c09af256a4f01358c6cb6d"
84
110
  }
@@ -0,0 +1,50 @@
1
+ import type { PlaywrightTestConfig } from '@playwright/test';
2
+
3
+ /**
4
+ * If this was an app level config, we might import each fixture from the mfs we're using to create a union
5
+ */
6
+ import type { TestFixture as HeaderFixture } from './test/e2e';
7
+
8
+ type Fixtures = HeaderFixture & {}; // < and several others if this was app level
9
+
10
+ const config: PlaywrightTestConfig<Fixtures> = {
11
+ testMatch: '**/*.e2e.ts',
12
+ globalSetup: '@genesislcap/foundation-testing/playwright', // returns teardown
13
+ /**
14
+ * We might create a discreet project per mf, or an entire config per mf, will know soon enough...
15
+ */
16
+ projects: [
17
+ {
18
+ name: 'Chrome Stable',
19
+ use: {
20
+ browserName: 'chromium',
21
+ channel: 'chrome',
22
+ ignoreHTTPSErrors: true,
23
+ /**
24
+ * We should be able to use these 'use' blocks at the App level to provide config data to our micro frontends.
25
+ * This might include what backend to run against, what username password combo to use etc.
26
+ *
27
+ * config: AppLevelPkgConfig;
28
+ */
29
+ // config: {
30
+ // API_HOST: 'wss://dev-foundation1/gwf/',
31
+ // DEFAULT_USER: 'Derek',
32
+ // DEFAULT_PASSWORD: 'Paul',
33
+ // PORT: 5030,
34
+ // },
35
+ },
36
+ },
37
+ ],
38
+ webServer: {
39
+ command: 'npm run dev:no-open',
40
+ url: 'http://localhost:5010/',
41
+ timeout: 120000,
42
+ reuseExistingServer: !process.env.CI,
43
+ },
44
+ use: {
45
+ baseURL: 'http://localhost:5010/',
46
+ },
47
+ // reporter: [['html', { open: 'never' }]],
48
+ };
49
+
50
+ export default config;
package/test/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Test
2
+
3
+ See [@genesislcap/foundation-testing](../foundation-testing/README.md) for more information.
@@ -0,0 +1,20 @@
1
+ import {
2
+ test as base,
3
+ TestFixture as BaseTestFixture,
4
+ WorkerFixture as BaseWorkerFixture,
5
+ } from '@genesislcap/foundation-testing/e2e';
6
+ import { HeaderPage } from './pages';
7
+
8
+ export type TestFixture = BaseTestFixture & {
9
+ headerPage: HeaderPage;
10
+ };
11
+
12
+ export type WorkerFixture = BaseWorkerFixture & {};
13
+
14
+ export const test = base.extend<TestFixture, WorkerFixture>({
15
+ headerPage: async ({ config, port, page }, use) => {
16
+ const headerPage = new HeaderPage(config, port, page);
17
+ await headerPage.goto();
18
+ await use(headerPage);
19
+ },
20
+ });
@@ -0,0 +1,11 @@
1
+ import { expect } from '@playwright/test';
2
+ import { test } from '../fixture';
3
+
4
+ test('Navigation logo is visible and redirects to the home page', async ({ headerPage, page }) => {
5
+ const logoVisible = await headerPage.navBarLogo.isVisible();
6
+ expect(logoVisible).toBe(true);
7
+
8
+ await headerPage.navBarLogo.click();
9
+ const currentUrl = page.url();
10
+ expect(currentUrl).toBe('http://localhost:5010/');
11
+ });
@@ -0,0 +1,2 @@
1
+ export * from './fixture';
2
+ export * from './pages';
@@ -0,0 +1,46 @@
1
+ import { PackageConfig, defaultAuditThresholds } from '@genesislcap/foundation-testing/e2e';
2
+ import type { Locator, Page } from '@playwright/test';
3
+ import { playAudit } from 'playwright-lighthouse';
4
+
5
+ export class HeaderPage {
6
+ config: PackageConfig;
7
+ port: number;
8
+ page: Page;
9
+ sideNav: Locator;
10
+ hamburgerMenu: Locator;
11
+ navBarLogo: Locator;
12
+ routeButtons: Locator;
13
+ luminanceToggleButton: Locator;
14
+ miscToggleButton: Locator;
15
+ notificationsButton: Locator;
16
+ userButton: Locator;
17
+
18
+ constructor(config: PackageConfig, port: number, page: Page) {
19
+ this.config = config;
20
+ this.port = port;
21
+ this.page = page;
22
+ /**
23
+ * Locate fields not guarded by conditionals upfront, and the remaining on-demand
24
+ */
25
+ this.sideNav = this.page.locator('data-test-id=side-nav');
26
+ this.hamburgerMenu = this.page.locator('data-test-id=hamburger-menu');
27
+ this.navBarLogo = this.page.locator('data-test-id=nav-bar-logo');
28
+ this.routeButtons = this.page.locator('data-test-id=route-buttons');
29
+ this.luminanceToggleButton = this.page.locator('data-test-id=luminance-toggle-button');
30
+ this.miscToggleButton = this.page.locator('data-test-id=misc-toggle-button');
31
+ this.notificationsButton = this.page.locator('data-test-id=notifications-button');
32
+ this.userButton = this.page.locator('data-test-id=user-button');
33
+ }
34
+
35
+ async goto() {
36
+ await this.page.goto('/');
37
+ }
38
+
39
+ async audit() {
40
+ await playAudit({
41
+ page: this.page,
42
+ port: this.port,
43
+ thresholds: defaultAuditThresholds, // TODO: this should be coming from foundation-testing/src/playwright/test.ts base config
44
+ });
45
+ }
46
+ }
@@ -0,0 +1 @@
1
+ export * from './header';
package/tsm.js ADDED
@@ -0,0 +1,3 @@
1
+ const config = require('@genesislcap/foundation-testing/tsm');
2
+
3
+ module.exports = config;