Skip to content

Commit

Permalink
Merge pull request #345 from nulib/deploy/staging
Browse files Browse the repository at this point in the history
Push to production
  • Loading branch information
adamjarling authored Jun 26, 2024
2 parents d41bac5 + 27cc9a3 commit 45afe36
Show file tree
Hide file tree
Showing 102 changed files with 24,987 additions and 1,472 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ jobs:

steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
uses: styfle/cancel-workflow-action@0.12.1

- name: Get files
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install dependencies
run: npm ci
run: npm ci --force

- name: Run tests
run: npm run test:ci
5 changes: 0 additions & 5 deletions .husky/pre-commit

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tabWidth": 2
}
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,22 @@ The API endpoint is an environment variable which is accessed in a local dev env

## Code Quality

The app uses ESLint with a plugin for TypeScript support.
### Prettier

There are no pre-commit hooks, however deploy CI will run a Prettier check on all files to ensure code quality. It's recommended to:

- Install the [Prettier VSCode extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
- Enable the "Format on Save" setting in VSCode
- Manually validate and/or fix, by running Prettier locally using the following commands:

```bash
npm run prettier:check # Check for formatting issues
npm run prettier:fix # Fix formatting issues
```

### ESLint

The app uses ESLint with a plugin for TypeScript support. Note currently with NextJS `v14`, this command won't run due to a dependency issue with ESLint `v9` support. Hopefully resolved by NextJS soon.

```bash
npm run lint
Expand Down
1 change: 1 addition & 0 deletions components/About/CollectionGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PhotoFeature, {
PhotoFeatureProps,
} from "@/components/Shared/PhotoFeature/PhotoFeature";

import { CollectionGridStyled } from "components/About/CollectionGridStyled";

interface Props {
Expand Down
4 changes: 2 additions & 2 deletions components/Clover/ViewerWrapper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("WorkViewerWrapper", () => {
isWorkRestricted={true}
manifestId="http://testing.com"
/>
</UserContext.Provider>
</UserContext.Provider>,
);

expect(await screen.findByText(readingRoomMessage)).toBeInTheDocument();
Expand All @@ -50,7 +50,7 @@ describe("WorkViewerWrapper", () => {
isWorkRestricted={false}
manifestId="http://testing.com"
/>
</UserContext.Provider>
</UserContext.Provider>,
);

let el;
Expand Down
2 changes: 1 addition & 1 deletion components/Clover/ViewerWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const CloverViewer = dynamic(
() => import("@samvera/clover-iiif/viewer"),
{
ssr: false,
}
},
);

interface WrapperProps {
Expand Down
2 changes: 1 addition & 1 deletion components/Collection/Tabs/Explore.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const topMetadata = [
describe("CollectionTabsExplore", () => {
it("renders the description", async () => {
render(
<CollectionTabsExplore collectionId="abc123" topMetadata={topMetadata} />
<CollectionTabsExplore collectionId="abc123" topMetadata={topMetadata} />,
);
expect(screen.getByTestId("explore-wrapper"));
});
Expand Down
2 changes: 1 addition & 1 deletion components/Collection/Tabs/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const CollectionTabsExplore: React.FC<CollectionTabsExploreProps> = ({
subject.value.map((subjectValue) => {
const str = `${url}/search?query=collection.id:"${collectionId}" AND ${subject.field}:"${subjectValue}"&collectionLabel=${subjectValue}&collectionSummary=${""}&as=iiif`;
return str;
})
}),
);
}, [collectionId, topMetadata]);

Expand Down
2 changes: 1 addition & 1 deletion components/Facets/Facet/GenericFacet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("Facet GenericFacet UI component", () => {
id: "genre",
label: "Genre",
}}
/>
/>,
);
}
it("renders facet title", async () => {
Expand Down
2 changes: 1 addition & 1 deletion components/Facets/Facet/GenericFacet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GenericFacet: React.FC<GenericFacetProps> = ({ facet }) => {
/* eslint-disable */
const debouncedHandler = React.useCallback(
debounce(handleFindChange, 200),
[]
[],
);
/* eslint-enable */

Expand Down
5 changes: 4 additions & 1 deletion components/Facets/Facet/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ const Option: React.FC<FacetOption> = ({ bucket, facet, index }) => {
*/
const facetObject = getFacetById(facet);
if (facetObject) {
filterDispatch({ facet: facetObject, type: "updateRecentFacet" });
filterDispatch({
facet: facetObject,
type: "updateRecentFacet",
});
}
} else {
/**
Expand Down
2 changes: 1 addition & 1 deletion components/Facets/Filter/GroupList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("FacetsGroupList component", () => {
}}
>
<FacetsGroupList />
</FilterProvider>
</FilterProvider>,
);
/**
* Looks like Radix puts this active state data attribute
Expand Down
4 changes: 2 additions & 2 deletions components/Facets/Filter/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("FilterModal component while `open`", () => {
<FilterModal q="joan" setIsModalOpen={() => false} />
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
</Dialog.Root>,
);

it("Has text rendering the search query param.", async () => {
Expand All @@ -81,7 +81,7 @@ describe("FilterModal component while `open`", () => {

const content = await screen.findByTestId("modal-content");
expect(content).toContainHTML(
`<em>Results for “<strong>joan</strong>”</em>`
`<em>Results for “<strong>joan</strong>”</em>`,
);
expect(singletonRouter).toMatchObject({
asPath: "/search?q=joan",
Expand Down
4 changes: 2 additions & 2 deletions components/Facets/Filter/Preview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("Submit component", () => {
it("renders the component with heading 3", () => {
renderHelper();
expect(screen.getByRole("heading", { level: 3 })).toHaveTextContent(
"Preview Results"
"Preview Results",
);
});

Expand All @@ -29,7 +29,7 @@ describe("Submit component", () => {
expect(links.length).toBe(2);
links.forEach((link, index) => {
expect(link.getAttribute("href")).toBe(
`/items/${sampleSearchShape[index].id}`
`/items/${sampleSearchShape[index].id}`,
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions components/Facets/UserFacets/UserFacets.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe("UserFacet UI component", () => {
<FilterProvider initialState={filterStateDefault}>
<UserFacets screen="search" urlFacets={{}} />
</FilterProvider>
</SearchProvider>
</SearchProvider>,
);
const userFacets = screen.queryByText(`facet-user-component`);

Expand Down Expand Up @@ -72,7 +72,7 @@ describe("UserFacet UI component", () => {
}}
/>
</FilterProvider>
</SearchProvider>
</SearchProvider>,
);
const userFacets = await screen.findByTestId(`facet-user-component`);
expect(userFacets).toBeInTheDocument();
Expand Down Expand Up @@ -101,7 +101,7 @@ describe("UserFacet UI component", () => {
}}
/>
</FilterProvider>
</SearchProvider>
</SearchProvider>,
);
const userFacets = screen.getByTestId(`facet-user-component`);
expect(userFacets).toBeInTheDocument();
Expand Down
2 changes: 1 addition & 1 deletion components/Facets/UserFacets/UserFacets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const FacetsCurrentUser: React.FC<FacetsCurrentUserProps> = ({
break;
default:
console.error(
`Screen value "${screen} is not valid on <FacetsCurrentUser>"`
`Screen value "${screen} is not valid on <FacetsCurrentUser>"`,
);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion components/Facets/UserFacets/Value.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("UserFacet UI component", () => {
handleRemoval={() => {
// nada
}}
/>
/>,
);

const value = screen.getByRole("button");
Expand Down
2 changes: 1 addition & 1 deletion components/Facets/WorkType/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const RadioGroup: React.FC<RadioGroupProps> = ({

const repositionHighlight = (
e: MouseEvent<HTMLButtonElement>,
option: string
option: string,
) => {
if (!option || !wrapperRef?.current) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SiteContentMessage = () => {
const [status, setStatus] = useSessionStorage("message_status", true);
const [timestamp, setTimestamp] = useSessionStorage(
"message_timestamp",
current
current,
);

const handleDismiss = () => {
Expand Down
6 changes: 3 additions & 3 deletions components/Grid/Item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ describe("GridItem component", () => {
render(<GridItem item={mockItem as SearchShape} />);

expect(screen.getByAltText(mockItem.title).getAttribute("src")).toContain(
mockItem.thumbnail
mockItem.thumbnail,
);
});

it("renders the full resolution image source is featured", () => {
render(<GridItem item={mockItem as SearchShape} isFeatured />);

expect(
screen.getByAltText(mockItem.title).getAttribute("src")
screen.getByAltText(mockItem.title).getAttribute("src"),
).not.toContain(mockItem.thumbnail);

expect(screen.getByAltText(mockItem.title).getAttribute("src")).toContain(
"https://iiif.stack.rdc-staging.library.northwestern.edu/iiif/2/b92874a0-72b7-4479-979e-38860c412a13/square/512,/0/default.jpg"
"https://iiif.stack.rdc-staging.library.northwestern.edu/iiif/2/b92874a0-72b7-4479-979e-38860c412a13/square/512,/0/default.jpg",
);
});
});
1 change: 1 addition & 0 deletions components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
HeaderStyled,
HeaderVariants,
} from "@/components/Header/Header.styled";

import HeaderLockup from "@/components/Header/Lockup";
import HeaderPrimary from "@/components/Header/Primary";
import HeaderSuper from "@/components/Header/Super";
Expand Down
2 changes: 1 addition & 1 deletion components/Header/Primary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const HeaderPrimary: React.FC = () => {
searchFixed: scrollPosition > 0,
type: "updateSearchFixed",
}),
[searchDispatch, scrollPosition]
[searchDispatch, scrollPosition],
);

const handleIsSearchActive = (status: boolean) => {
Expand Down
2 changes: 1 addition & 1 deletion components/Search/JumpTo.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("SearchJumpTo component", () => {
<div data-testid="page">
<span>Outside search form</span>
<SearchJumpTo isSearchActive={mockIsSearchActive} />
</div>
</div>,
);
const form = screen.getByTestId("search-jump-to-form");

Expand Down
17 changes: 10 additions & 7 deletions components/Search/JumpToList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ const mockSetShowJumpTo = jest.fn();
describe("SearchJumpToList component", () => {
it("renders search value in list items", () => {
render(
<SearchJumpToList searchValue="Dylan" setShowJumpTo={mockSetShowJumpTo} />
<SearchJumpToList
searchValue="Dylan"
setShowJumpTo={mockSetShowJumpTo}
/>,
);
expect(screen.getByTestId("jump-to-wrapper"));
expect(screen.getAllByText("Dylan")).toHaveLength(2);
});

it("renders Helper components in each JumpTo item", () => {
render(
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />,
);
const helpers = screen.getAllByTestId("helper");
expect(helpers[0]).toHaveTextContent(/in this collection/i);
Expand All @@ -37,7 +40,7 @@ describe("SearchJumpToList component", () => {

it.only("renders route query params in JumpTo items", async () => {
render(
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />,
);

await act(async () => {
Expand All @@ -48,19 +51,19 @@ describe("SearchJumpToList component", () => {
});

expect(
await screen.findByTestId("helper-anchor-collection")
await screen.findByTestId("helper-anchor-collection"),
).toHaveAttribute("href", `/search?collection=Best+Collection+Ever&q=foo`);

expect(screen.getByTestId("helper-anchor-all")).toHaveAttribute(
"href",
"/search?q=foo"
"/search?q=foo",
);
});

it("selects items correctly on arrow key presses", async () => {
const user = userEvent.setup();
render(
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />,
);
const listItems = await screen.findAllByRole("option");

Expand All @@ -86,7 +89,7 @@ describe("SearchJumpToList component", () => {
it("handles the Escape key press", async () => {
const user = userEvent.setup();
render(
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />
<SearchJumpToList searchValue="foo" setShowJumpTo={mockSetShowJumpTo} />,
);

await user.keyboard("{Escape}");
Expand Down
2 changes: 1 addition & 1 deletion components/Search/JumpToList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const SearchJumpToList: React.FC<SearchJumpToListProps> = ({
} catch (err) {
console.error(
"Error getting Collection title in JumpTo component",
err
err,
);
}
}
Expand Down
Loading

0 comments on commit 45afe36

Please sign in to comment.