From d44a12284223627e87493089a314c63bf5daf8b6 Mon Sep 17 00:00:00 2001
From: Adam Setch
Date: Fri, 24 Jan 2025 12:28:54 -0500
Subject: [PATCH 1/5] refactor: migrate to text inputs to primer
Signed-off-by: Adam Setch
---
.../components/fields/FieldInput.test.tsx | 27 -
src/renderer/components/fields/FieldInput.tsx | 57 -
.../__snapshots__/FieldInput.test.tsx.snap | 114 --
src/renderer/components/layout/Contents.tsx | 7 +-
src/renderer/components/layout/Page.test.tsx | 18 +-
src/renderer/components/layout/Page.tsx | 7 +-
.../__snapshots__/Contents.test.tsx.snap | 4 +-
.../layout/__snapshots__/Page.test.tsx.snap | 81 +-
src/renderer/components/primitives/Footer.tsx | 15 +-
src/renderer/components/primitives/Header.tsx | 40 +-
.../__snapshots__/Footer.test.tsx.snap | 68 +-
.../__snapshots__/Header.test.tsx.snap | 158 ++-
src/renderer/routes/Accounts.tsx | 11 +-
src/renderer/routes/Filters.tsx | 2 +-
.../routes/LoginWithOAuthApp.test.tsx | 16 +-
src/renderer/routes/LoginWithOAuthApp.tsx | 279 ++--
.../LoginWithPersonalAccessToken.test.tsx | 10 +-
.../routes/LoginWithPersonalAccessToken.tsx | 289 ++--
src/renderer/routes/Settings.tsx | 2 +-
.../__snapshots__/Accounts.test.tsx.snap | 612 ++++----
.../__snapshots__/Filters.test.tsx.snap | 208 +--
.../LoginWithOAuthApp.test.tsx.snap | 1264 ++++++++++-------
...LoginWithPersonalAccessToken.test.tsx.snap | 1082 ++++++++------
.../__snapshots__/Settings.test.tsx.snap | 324 ++---
src/renderer/utils/auth/utils.ts | 4 +
25 files changed, 2541 insertions(+), 2158 deletions(-)
delete mode 100644 src/renderer/components/fields/FieldInput.test.tsx
delete mode 100644 src/renderer/components/fields/FieldInput.tsx
delete mode 100644 src/renderer/components/fields/__snapshots__/FieldInput.test.tsx.snap
diff --git a/src/renderer/components/fields/FieldInput.test.tsx b/src/renderer/components/fields/FieldInput.test.tsx
deleted file mode 100644
index 0e2035a9a..000000000
--- a/src/renderer/components/fields/FieldInput.test.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { render } from '@testing-library/react';
-import { Form } from 'react-final-form';
-import { FieldInput, type IFieldInput } from './FieldInput';
-
-describe('renderer/components/fields/FieldInput.tsx', () => {
- const props: IFieldInput = {
- name: 'appearance',
- label: 'Appearance',
- placeholder: 'This is some placeholder text',
- helpText: 'This is some helper text',
- };
-
- it('should render', () => {
- const tree = render(
-
- )}
- />,
- );
- expect(tree).toMatchSnapshot();
- });
-});
diff --git a/src/renderer/components/fields/FieldInput.tsx b/src/renderer/components/fields/FieldInput.tsx
deleted file mode 100644
index c58207c8f..000000000
--- a/src/renderer/components/fields/FieldInput.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import type { FC, ReactNode } from 'react';
-import { Field } from 'react-final-form';
-import { cn } from '../../utils/cn';
-
-export interface IFieldInput {
- name: string;
- type?: string;
- label: string;
- placeholder?: string;
- helpText?: ReactNode | string;
- required?: boolean;
-}
-
-export const FieldInput: FC = ({
- label,
- name,
- placeholder,
- helpText,
- type = 'text',
- required = false,
-}) => {
- return (
-
- {({ input, meta: { touched, error } }) => (
-
-
-
-
-
- {helpText && (
-
{helpText}
- )}
-
- {touched && error && (
-
{error}
- )}
-
- )}
-
- );
-};
diff --git a/src/renderer/components/fields/__snapshots__/FieldInput.test.tsx.snap b/src/renderer/components/fields/__snapshots__/FieldInput.test.tsx.snap
deleted file mode 100644
index f2d15383f..000000000
--- a/src/renderer/components/fields/__snapshots__/FieldInput.test.tsx.snap
+++ /dev/null
@@ -1,114 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`renderer/components/fields/FieldInput.tsx should render 1`] = `
-{
- "asFragment": [Function],
- "baseElement":
-
- ,
- "container": ,
- "debug": [Function],
- "findAllByAltText": [Function],
- "findAllByDisplayValue": [Function],
- "findAllByLabelText": [Function],
- "findAllByPlaceholderText": [Function],
- "findAllByRole": [Function],
- "findAllByTestId": [Function],
- "findAllByText": [Function],
- "findAllByTitle": [Function],
- "findByAltText": [Function],
- "findByDisplayValue": [Function],
- "findByLabelText": [Function],
- "findByPlaceholderText": [Function],
- "findByRole": [Function],
- "findByTestId": [Function],
- "findByText": [Function],
- "findByTitle": [Function],
- "getAllByAltText": [Function],
- "getAllByDisplayValue": [Function],
- "getAllByLabelText": [Function],
- "getAllByPlaceholderText": [Function],
- "getAllByRole": [Function],
- "getAllByTestId": [Function],
- "getAllByText": [Function],
- "getAllByTitle": [Function],
- "getByAltText": [Function],
- "getByDisplayValue": [Function],
- "getByLabelText": [Function],
- "getByPlaceholderText": [Function],
- "getByRole": [Function],
- "getByTestId": [Function],
- "getByText": [Function],
- "getByTitle": [Function],
- "queryAllByAltText": [Function],
- "queryAllByDisplayValue": [Function],
- "queryAllByLabelText": [Function],
- "queryAllByPlaceholderText": [Function],
- "queryAllByRole": [Function],
- "queryAllByTestId": [Function],
- "queryAllByText": [Function],
- "queryAllByTitle": [Function],
- "queryByAltText": [Function],
- "queryByDisplayValue": [Function],
- "queryByLabelText": [Function],
- "queryByPlaceholderText": [Function],
- "queryByRole": [Function],
- "queryByTestId": [Function],
- "queryByText": [Function],
- "queryByTitle": [Function],
- "rerender": [Function],
- "unmount": [Function],
-}
-`;
diff --git a/src/renderer/components/layout/Contents.tsx b/src/renderer/components/layout/Contents.tsx
index d7d4a1e25..b50b08272 100644
--- a/src/renderer/components/layout/Contents.tsx
+++ b/src/renderer/components/layout/Contents.tsx
@@ -1,3 +1,4 @@
+import { Box } from '@primer/react';
import type { FC, ReactNode } from 'react';
interface IContents {
@@ -5,5 +6,9 @@ interface IContents {
}
export const Contents: FC = (props: IContents) => {
- return {props.children}
;
+ return (
+
+ {props.children}
+
+ );
};
diff --git a/src/renderer/components/layout/Page.test.tsx b/src/renderer/components/layout/Page.test.tsx
index 9c1727373..bf51c7ec6 100644
--- a/src/renderer/components/layout/Page.test.tsx
+++ b/src/renderer/components/layout/Page.test.tsx
@@ -2,22 +2,8 @@ import { render } from '@testing-library/react';
import { Page } from './Page';
describe('renderer/components/layout/Page.tsx', () => {
- it('should render itself & its children - full', () => {
- const tree = render(
-
- Test
- ,
- );
-
- expect(tree).toMatchSnapshot();
- });
-
- it('should render itself & its children - screen', () => {
- const tree = render(
-
- Test
- ,
- );
+ it('should render itself & its children', () => {
+ const tree = render(Test);
expect(tree).toMatchSnapshot();
});
diff --git a/src/renderer/components/layout/Page.tsx b/src/renderer/components/layout/Page.tsx
index 2d335f6bb..123ccdac0 100644
--- a/src/renderer/components/layout/Page.tsx
+++ b/src/renderer/components/layout/Page.tsx
@@ -1,16 +1,15 @@
+import { Box } from '@primer/react';
import type { FC, ReactNode } from 'react';
-import { cn } from '../../utils/cn';
interface IPage {
children: ReactNode;
id: string;
- type: 'h-full' | 'h-screen';
}
export const Page: FC = (props: IPage) => {
return (
-
+
{props.children}
-
+
);
};
diff --git a/src/renderer/components/layout/__snapshots__/Contents.test.tsx.snap b/src/renderer/components/layout/__snapshots__/Contents.test.tsx.snap
index 94a38f280..ef2f6fb2f 100644
--- a/src/renderer/components/layout/__snapshots__/Contents.test.tsx.snap
+++ b/src/renderer/components/layout/__snapshots__/Contents.test.tsx.snap
@@ -6,7 +6,7 @@ exports[`renderer/components/layout/Contents.tsx should render itself & its chil
"baseElement":
Test
@@ -14,7 +14,7 @@ exports[`renderer/components/layout/Contents.tsx should render itself & its chil
,
"container":
Test
diff --git a/src/renderer/components/layout/__snapshots__/Page.test.tsx.snap b/src/renderer/components/layout/__snapshots__/Page.test.tsx.snap
index 4fbafd1e1..2942df524 100644
--- a/src/renderer/components/layout/__snapshots__/Page.test.tsx.snap
+++ b/src/renderer/components/layout/__snapshots__/Page.test.tsx.snap
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`renderer/components/layout/Page.tsx should render itself & its children - full 1`] = `
+exports[`renderer/components/layout/Page.tsx should render itself & its children 1`] = `
{
"asFragment": [Function],
"baseElement":
Test
@@ -15,82 +15,7 @@ exports[`renderer/components/layout/Page.tsx should render itself & its children
,
"container":
,
- "debug": [Function],
- "findAllByAltText": [Function],
- "findAllByDisplayValue": [Function],
- "findAllByLabelText": [Function],
- "findAllByPlaceholderText": [Function],
- "findAllByRole": [Function],
- "findAllByTestId": [Function],
- "findAllByText": [Function],
- "findAllByTitle": [Function],
- "findByAltText": [Function],
- "findByDisplayValue": [Function],
- "findByLabelText": [Function],
- "findByPlaceholderText": [Function],
- "findByRole": [Function],
- "findByTestId": [Function],
- "findByText": [Function],
- "findByTitle": [Function],
- "getAllByAltText": [Function],
- "getAllByDisplayValue": [Function],
- "getAllByLabelText": [Function],
- "getAllByPlaceholderText": [Function],
- "getAllByRole": [Function],
- "getAllByTestId": [Function],
- "getAllByText": [Function],
- "getAllByTitle": [Function],
- "getByAltText": [Function],
- "getByDisplayValue": [Function],
- "getByLabelText": [Function],
- "getByPlaceholderText": [Function],
- "getByRole": [Function],
- "getByTestId": [Function],
- "getByText": [Function],
- "getByTitle": [Function],
- "queryAllByAltText": [Function],
- "queryAllByDisplayValue": [Function],
- "queryAllByLabelText": [Function],
- "queryAllByPlaceholderText": [Function],
- "queryAllByRole": [Function],
- "queryAllByTestId": [Function],
- "queryAllByText": [Function],
- "queryAllByTitle": [Function],
- "queryByAltText": [Function],
- "queryByDisplayValue": [Function],
- "queryByLabelText": [Function],
- "queryByPlaceholderText": [Function],
- "queryByRole": [Function],
- "queryByTestId": [Function],
- "queryByText": [Function],
- "queryByTitle": [Function],
- "rerender": [Function],
- "unmount": [Function],
-}
-`;
-
-exports[`renderer/components/layout/Page.tsx should render itself & its children - screen 1`] = `
-{
- "asFragment": [Function],
- "baseElement":
-
- ,
- "container":
-
Test
diff --git a/src/renderer/components/primitives/Footer.tsx b/src/renderer/components/primitives/Footer.tsx
index c1d2d637b..861d9f95c 100644
--- a/src/renderer/components/primitives/Footer.tsx
+++ b/src/renderer/components/primitives/Footer.tsx
@@ -1,4 +1,4 @@
-import { Stack } from '@primer/react';
+import { Box, Stack } from '@primer/react';
import type { FC, ReactNode } from 'react';
interface IFooter {
@@ -8,13 +8,10 @@ interface IFooter {
export const Footer: FC
= (props: IFooter) => {
return (
-
- {props.children}
-
+
+
+ {props.children}
+
+
);
};
diff --git a/src/renderer/components/primitives/Header.tsx b/src/renderer/components/primitives/Header.tsx
index 189474a11..1d72ffb42 100644
--- a/src/renderer/components/primitives/Header.tsx
+++ b/src/renderer/components/primitives/Header.tsx
@@ -2,7 +2,7 @@ import { type FC, useContext } from 'react';
import { useNavigate } from 'react-router-dom';
import { ArrowLeftIcon, type Icon } from '@primer/octicons-react';
-import { IconButton, Stack } from '@primer/react';
+import { Box, IconButton, Stack } from '@primer/react';
import { AppContext } from '../../context/App';
import { Title } from './Title';
@@ -19,24 +19,26 @@ export const Header: FC = (props: IHeader) => {
const { fetchNotifications } = useContext(AppContext);
return (
-
- {
- navigate(-1);
- if (props.fetchOnBack) {
- fetchNotifications();
- }
- }}
- data-testid="header-nav-back"
- />
+
+
+ {
+ navigate(-1);
+ if (props.fetchOnBack) {
+ fetchNotifications();
+ }
+ }}
+ data-testid="header-nav-back"
+ />
-
- {props.children}
-
-
+
+ {props.children}
+
+
+
);
};
diff --git a/src/renderer/components/primitives/__snapshots__/Footer.test.tsx.snap b/src/renderer/components/primitives/__snapshots__/Footer.test.tsx.snap
index 10e487af2..d347c3a50 100644
--- a/src/renderer/components/primitives/__snapshots__/Footer.test.tsx.snap
+++ b/src/renderer/components/primitives/__snapshots__/Footer.test.tsx.snap
@@ -6,7 +6,27 @@ exports[`renderer/components/primitives/Footer.tsx should render itself & its ch
"baseElement":
+
+ ,
+ "container":
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+