Skip to content

Commit

Permalink
Upgrade salt and replace custom navigation item (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding authored Jul 23, 2024
1 parent 182a430 commit 8e96ed0
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 267 deletions.
11 changes: 11 additions & 0 deletions .changeset/fluffy-onions-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@jpmorganchase/mosaic-components': patch
'@jpmorganchase/mosaic-labs-components': patch
'@jpmorganchase/mosaic-content-editor-plugin': patch
'@jpmorganchase/mosaic-layouts': patch
'@jpmorganchase/mosaic-site': patch
'@jpmorganchase/mosaic-site-components': patch
'@jpmorganchase/mosaic-sitemap-component': patch
---

Updated Salt packages.
2 changes: 1 addition & 1 deletion packages/components-labs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"dependencies": {
"@jpmorganchase/mosaic-components": "^0.1.0-beta.82",
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.82",
"@salt-ds/core": "^1.32.0",
"@salt-ds/core": "^1.33.0",
"@vanilla-extract/css": "^1.6.0",
"@vanilla-extract/recipes": "^0.2.1",
"@vanilla-extract/sprinkles": "^1.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"dependencies": {
"@jpmorganchase/mosaic-store": "^0.1.0-beta.82",
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.82",
"@salt-ds/core": "^1.32.0",
"@salt-ds/lab": "1.0.0-alpha.49",
"@salt-ds/core": "^1.33.0",
"@salt-ds/lab": "1.0.0-alpha.50",
"@vanilla-extract/css": "^1.6.0",
"@vanilla-extract/sprinkles": "^1.3.0",
"@vanilla-extract/recipes": "^0.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/content-editor-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"dependencies": {
"@jpmorganchase/mosaic-components": "^0.1.0-beta.82",
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.82",
"@salt-ds/core": "^1.32.0",
"@salt-ds/core": "^1.33.0",
"@salt-ds/icons": "^1.12.1",
"@salt-ds/lab": "1.0.0-alpha.49",
"@salt-ds/lab": "1.0.0-alpha.50",
"@salt-ds/theme": "^1.19.0",
"@floating-ui/react": "^0.26.6",
"@lexical/code": "^0.11.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/layouts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@jpmorganchase/mosaic-site-components": "^0.1.0-beta.82",
"@jpmorganchase/mosaic-store": "^0.1.0-beta.82",
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.82",
"@salt-ds/core": "^1.32.0",
"@salt-ds/core": "^1.33.0",
"@vanilla-extract/css": "^1.6.0",
"@vanilla-extract/sprinkles": "^1.3.0",
"clsx": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/site-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"@jpmorganchase/mosaic-site-middleware": "^0.1.0-beta.82",
"@jpmorganchase/mosaic-store": "^0.1.0-beta.82",
"@jpmorganchase/mosaic-theme": "^0.1.0-beta.82",
"@salt-ds/core": "^1.32.0",
"@salt-ds/lab": "1.0.0-alpha.49",
"@salt-ds/core": "^1.33.0",
"@salt-ds/lab": "1.0.0-alpha.50",
"@types/mdast": "^3.0.0",
"@vanilla-extract/css": "^1.6.0",
"@vanilla-extract/recipes": "^0.2.1",
Expand Down
22 changes: 0 additions & 22 deletions packages/site-components/src/NavigationItem/ExpansionIcon.tsx

This file was deleted.

185 changes: 0 additions & 185 deletions packages/site-components/src/NavigationItem/NavigationItem.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/site-components/src/NavigationItem/index.ts

This file was deleted.

15 changes: 5 additions & 10 deletions packages/site-components/src/VerticalNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { MouseEventHandler, useState } from 'react';
import { StackLayout } from '@salt-ds/core';
import { NavigationItem, NavigationItemRenderProps } from './NavigationItem';
import { StackLayout, NavigationItem, NavigationItemProps } from '@salt-ds/core';
import { Link } from '@jpmorganchase/mosaic-components';
import { SidebarItem, SidebarNode } from '@jpmorganchase/mosaic-store';

Expand All @@ -13,15 +12,11 @@ export type VerticalNavigationProps = {
menu: SidebarItem[];
};

const renderItem: React.FC<NavigationItemRenderProps<HTMLButtonElement | HTMLAnchorElement>> = ({
href,
isParent,
elementProps
}) => {
if (isParent) {
return <button {...elementProps} />;
const renderItem: NavigationItemProps['render'] = ({ href, ...rest }) => {
if (href) {
return <Link variant="component" {...rest} href={href} />;
}
return <Link variant={'component'} {...elementProps} href={href} />;
return <button {...rest} />;
};

const renderNavigationItem = (
Expand Down
18 changes: 7 additions & 11 deletions packages/site-components/src/__tests__/VerticalNavigation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { render, screen, waitFor, within } from '@testing-library/react';
import userEvents from '@testing-library/user-event';
import { VerticalNavigation } from '../VerticalNavigation';

jest.mock('@salt-ds/core/dist-es/navigation-item/NavigationItem.css.js', () => {});

describe('GIVEN a VerticalNavigation', () => {
it('THEN it should render a link when a group contains < 2 pages and be active when on its subroute', () => {
const singlePageInGroupMenu = [
Expand Down Expand Up @@ -33,10 +31,8 @@ describe('GIVEN a VerticalNavigation', () => {
);
// assert
expect(screen.getByText('Group', { exact: true })).toBeVisible();
expect(screen.queryByRole('link', { name: 'change page' })).toHaveClass(
'saltNavigationItem-active'
);
expect(screen.queryByLabelText('expand')).not.toBeInTheDocument();
expect(screen.queryByRole('link', { name: 'Group' })).toHaveClass('saltNavigationItem-active');
expect(screen.queryByRole('link', { name: 'Option 1' })).not.toBeInTheDocument();
});

it('THEN it should render a group when it contains > 2 pages', () => {
Expand Down Expand Up @@ -73,7 +69,7 @@ describe('GIVEN a VerticalNavigation', () => {
);
// assert
expect(screen.getByText('Group', { exact: true })).toBeVisible();
expect(screen.queryByRole('button', { name: 'expand' })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Group' })).toBeInTheDocument();
const links = screen.getAllByRole('link');
expect(within(links[0]).getByText('Option 1')).toBeInTheDocument();
expect(within(links[1]).getByText('Option 2')).toBeInTheDocument();
Expand Down Expand Up @@ -113,7 +109,7 @@ describe('GIVEN a VerticalNavigation', () => {
);
// assert
expect(screen.getByText('Group', { exact: true })).toBeVisible();
expect(screen.queryByLabelText('expand')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Group' })).toBeInTheDocument();
const links = screen.getAllByRole('link');
expect(links.length).toEqual(2);
expect(within(links[0]).getByText('Option 1')).toBeInTheDocument();
Expand Down Expand Up @@ -154,9 +150,9 @@ describe('GIVEN a VerticalNavigation', () => {
);
// assert
expect(screen.getByText('Group', { exact: true })).toBeVisible();
expect(screen.queryByLabelText('expand')).toBeInTheDocument();
expect(screen.queryByRole('button', { name: 'Group' })).toBeInTheDocument();
expect(screen.queryByRole('link')).not.toBeInTheDocument();
await userEvents.click(screen.getByLabelText('expand'));
await userEvents.click(screen.getByRole('button', { name: 'Group' }));
// action - expand row
await waitFor(() => expect(screen.queryAllByRole('link').length).toEqual(2));
// assert
Expand All @@ -170,7 +166,7 @@ describe('GIVEN a VerticalNavigation', () => {
);
await waitFor(() => expect(screen.queryAllByRole('link').length).toEqual(2));
// action - collapse row
await userEvents.click(screen.getByLabelText('expand'));
await userEvents.click(screen.getByRole('button', { name: 'Group' }));
// assert
await waitFor(() => expect(screen.queryAllByRole('link').length).toEqual(0));
});
Expand Down
7 changes: 4 additions & 3 deletions packages/site/e2e/layout.detailOverview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ test.describe('GIVEN a page with the `DetailOverview` Layout', () => {

test('THEN there is a sidebar', async ({ page }) => {
await page.goto('/mosaic/test/layouts/detail-overview');
await expect(page.getByTestId('vertical-navigation')).toBeVisible();
await expect(page.getByLabel('change page')).toHaveCount(3);
const navigation = page.getByTestId('vertical-navigation');
await expect(navigation).toBeVisible();
await expect(navigation.locator(page.getByRole('link'))).toHaveCount(3);
await expect(page.getByText('Test', { exact: true })).toBeVisible();
await expect(page.getByLabel('expand')).toHaveCount(2);
await expect(navigation.locator(page.getByRole('button'))).toHaveCount(2);
await expect(page.getByText('Layouts', { exact: true })).toBeVisible();
await expect(page.getByText('Refs Test', { exact: true })).toBeVisible();
await expect(page.getByText('Aliases Test', { exact: true })).toBeVisible();
Expand Down
7 changes: 4 additions & 3 deletions packages/site/e2e/layout.detailTechnical.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ test.describe('GIVEN a page with the `DetailTechnical` Layout', () => {

test('THEN there is a sidebar', async ({ page }) => {
await page.goto('/mosaic/test/layouts/detail-technical');
await expect(page.getByTestId('vertical-navigation')).toBeVisible();
await expect(page.getByLabel('change page')).toHaveCount(3);
const navigation = page.getByTestId('vertical-navigation');
await expect(navigation).toBeVisible();
await expect(navigation.locator(page.getByRole('link'))).toHaveCount(3);
await expect(page.getByText('Test', { exact: true })).toBeVisible();
await expect(page.getByLabel('expand')).toHaveCount(2);
await expect(navigation.locator(page.getByRole('button'))).toHaveCount(2);
await expect(page.getByText('Layouts', { exact: true })).toBeVisible();
await expect(page.getByText('Refs Test', { exact: true })).toBeVisible();
await expect(page.getByText('Aliases Test', { exact: true })).toBeVisible();
Expand Down
Loading

0 comments on commit 8e96ed0

Please sign in to comment.