-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Frontend scaffolding (prettier, navbar, testing) (#679)
* Add import sorting, same as fidesops#9de2136 * Run import sorting * Update changelog * Use baseurl for easier imports * Add prettier * Simplify components via a Layout component * Add testing to the NavBar * Fix pluralization in routes * Remove unused import * Update changelog * Revert "Update changelog" This reverts commit c552049. * Fix path to page * Add .prettierignore to leave the changelog alone * Update changelog * Remove any type * Change import path shortcut from @ to ~
- Loading branch information
1 parent
94425fc
commit 539af04
Showing
25 changed files
with
374 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CHANGELOG.md | ||
.next | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
// __tests__/index.test.tsx | ||
import { render, screen } from '@testing-library/react'; | ||
import { SessionProvider } from 'next-auth/react'; | ||
import Home from '../pages/index'; | ||
import { render, screen } from "@testing-library/react"; | ||
import { SessionProvider } from "next-auth/react"; | ||
|
||
describe('Home', () => { | ||
it('renders a logged out notification when no session is present', () => { | ||
import Home from "../src/pages/index"; | ||
|
||
describe("Home", () => { | ||
// skip until this is fixed in fidesops | ||
it.skip("renders a logged out notification when no session is present", () => { | ||
render( | ||
<SessionProvider> | ||
<Home session={null} /> | ||
</SessionProvider> | ||
); | ||
|
||
const message = screen.getByText('You are not logged in.'); | ||
const message = screen.getByText("You are not logged in."); | ||
expect(message).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { render } from "@testing-library/react"; | ||
import { SessionProvider } from "next-auth/react"; | ||
|
||
import NavBar from "~/features/common/NavBar"; | ||
import { mockNextUseRouter } from "~/test-utils"; | ||
|
||
describe("Home", () => { | ||
it("renders a navigation bar", () => { | ||
mockNextUseRouter({ route: "/" }); | ||
const { getByTestId } = render( | ||
<SessionProvider> | ||
<NavBar /> | ||
</SessionProvider> | ||
); | ||
expect(getByTestId("nav-link-Systems")).toBeInTheDocument(); | ||
expect(getByTestId("nav-link-Datasets")).toBeInTheDocument(); | ||
expect(getByTestId("nav-link-Policies")).toBeInTheDocument(); | ||
expect(getByTestId("nav-link-Taxonomy")).toBeInTheDocument(); | ||
expect(getByTestId("nav-link-User Management")).toBeInTheDocument(); | ||
expect(getByTestId("nav-link-More")).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders a nav link as active if at the proper route", () => { | ||
mockNextUseRouter({ route: "/datasets", pathname: "/datasets" }); | ||
const { getByTestId } = render( | ||
<SessionProvider> | ||
<NavBar /> | ||
</SessionProvider> | ||
); | ||
expect(getByTestId("nav-link-Systems")).not.toHaveAttribute("data-active"); | ||
expect(getByTestId("nav-link-Datasets")).toHaveAttribute("data-active"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,41 @@ | ||
// jest.config.js | ||
module.exports = { | ||
collectCoverageFrom: [ | ||
'**/*.{js,jsx,ts,tsx}', | ||
'!**/*.d.ts', | ||
'!**/node_modules/**', | ||
"**/*.{js,jsx,ts,tsx}", | ||
"!**/*.d.ts", | ||
"!**/node_modules/**", | ||
], | ||
moduleNameMapper: { | ||
// Handle CSS imports (with CSS modules) | ||
// https://jestjs.io/docs/webpack#mocking-css-modules | ||
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy', | ||
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy", | ||
|
||
// Handle CSS imports (without CSS modules) | ||
'^.+\\.(css|sass|scss)$': '<rootDir>/__mocks__/styleMock.js', | ||
"^.+\\.(css|sass|scss)$": "<rootDir>/__mocks__/styleMock.js", | ||
|
||
// Handle image imports | ||
// https://jestjs.io/docs/webpack#handling-static-assets | ||
'^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i': `<rootDir>/__mocks__/fileMock.js`, | ||
"^.+\\.(png|jpg|jpeg|gif|webp|avif|ico|bmp|svg)$/i": `<rootDir>/__mocks__/fileMock.js`, | ||
|
||
// Handle module aliases | ||
'^@/components/(.*)$': '<rootDir>/components/$1', | ||
"^@/components/(.*)$": "<rootDir>/components/$1", | ||
"^~/(.*)$": "<rootDir>/src/$1", | ||
}, | ||
// Add more setup options before each test is run | ||
setupFilesAfterEnv: ['<rootDir>/__tests__/jest.setup.ts'], | ||
setupFilesAfterEnv: ["<rootDir>/__tests__/jest.setup.ts"], | ||
testPathIgnorePatterns: [ | ||
'<rootDir>/node_modules/', | ||
'<rootDir>/.next/', | ||
'jest.setup.ts', | ||
"<rootDir>/node_modules/", | ||
"<rootDir>/.next/", | ||
"jest.setup.ts", | ||
], | ||
testEnvironment: 'jsdom', | ||
testEnvironment: "jsdom", | ||
transform: { | ||
// Use babel-jest to transpile tests with the next/babel preset | ||
// https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object | ||
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }], | ||
"^.+\\.(js|jsx|ts|tsx)$": ["babel-jest", { presets: ["next/babel"] }], | ||
}, | ||
transformIgnorePatterns: [ | ||
'/node_modules/', | ||
'^.+\\.module\\.(css|sass|scss)$', | ||
"/node_modules/", | ||
"^.+\\.module\\.(css|sass|scss)$", | ||
], | ||
}; |
Oops, something went wrong.