From 6ec3694163575097a9e3b185326525357729c4ad Mon Sep 17 00:00:00 2001 From: Kyle Holmberg Date: Mon, 10 Nov 2025 19:11:38 +0700 Subject: [PATCH 1/5] style tweaks --- .../__snapshots__/LinkButton.test.tsx.snap | 14 +- .../FeaturedJobItem/FeaturedJobItem.tsx | 30 +- .../FeaturedJobItem.test.tsx.snap | 151 ++--- .../RegistrationForm.test.tsx.snap | 64 +- components/OutboundLink/OutboundLink.tsx | 8 +- .../__snapshots__/OutboundLink.test.tsx.snap | 32 +- .../PartnerLogoLink.test.tsx.snap | 28 +- .../__snapshots__/JoinSection.test.tsx.snap | 32 +- .../SponsorsSection.test.tsx.snap | 602 ++++++++---------- .../SocialMediaItem.test.tsx.snap | 40 +- 10 files changed, 471 insertions(+), 530 deletions(-) diff --git a/components/Buttons/LinkButton/__tests__/__snapshots__/LinkButton.test.tsx.snap b/components/Buttons/LinkButton/__tests__/__snapshots__/LinkButton.test.tsx.snap index 20ceff98c..948b3a60f 100644 --- a/components/Buttons/LinkButton/__tests__/__snapshots__/LinkButton.test.tsx.snap +++ b/components/Buttons/LinkButton/__tests__/__snapshots__/LinkButton.test.tsx.snap @@ -9,14 +9,12 @@ exports[`LinkButton > should render with many props assigned 1`] = ` rel="noopener noreferrer" target="_blank" > - - Test - - Opens in new window - + Test + + Opens in new window `; diff --git a/components/FeaturedJobItem/FeaturedJobItem.tsx b/components/FeaturedJobItem/FeaturedJobItem.tsx index d9088ca5a..d792d548c 100644 --- a/components/FeaturedJobItem/FeaturedJobItem.tsx +++ b/components/FeaturedJobItem/FeaturedJobItem.tsx @@ -50,30 +50,30 @@ function FeaturedJobItem({ remote = false, }: FeaturedJobItemPropsType) { return ( -
+
-
{title}
+
{title}
-
-
- +
+
+ {source}
-
- {(city || state || country) && ( - - )} - {city && {city},} - {state && {state},} - {country && {country}} +
+ +
+ {city && {city},} + {state && {state},} + {country && {country}} +
{remote && ( -
- - Remote +
+ + Remote
)}
diff --git a/components/FeaturedJobItem/__tests__/__snapshots__/FeaturedJobItem.test.tsx.snap b/components/FeaturedJobItem/__tests__/__snapshots__/FeaturedJobItem.test.tsx.snap index c01445ca0..5d3a4fcca 100644 --- a/components/FeaturedJobItem/__tests__/__snapshots__/FeaturedJobItem.test.tsx.snap +++ b/components/FeaturedJobItem/__tests__/__snapshots__/FeaturedJobItem.test.tsx.snap @@ -1,9 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`FeaturedJobItem > should render with many props assigned 1`] = ` -
+
should render with many props assigned 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Experienced React Engineer -
- - Opens in new window - - External Link Symbol", - } - } - viewBox="0 0 448 512" - /> +
+ Experienced React Engineer +
+ + Opens in new window + External Link Symbol", + } + } + viewBox="0 0 448 512" + />
Building", @@ -54,10 +50,10 @@ exports[`FeaturedJobItem > should render with many props assigned 1`] = `
Map Marker", @@ -65,29 +61,27 @@ exports[`FeaturedJobItem > should render with many props assigned 1`] = ` } viewBox="0 0 384 512" /> - - Seattle - , - - - WA - , - - - United States - + + Seattle + , + + + WA + , + + + United States + +
Cloud With Up Arrow Inside", @@ -95,9 +89,7 @@ exports[`FeaturedJobItem > should render with many props assigned 1`] = ` } viewBox="0 0 640 512" /> - + Remote
@@ -111,9 +103,7 @@ exports[`FeaturedJobItem > should render with many props assigned 1`] = ` `; exports[`FeaturedJobItem > should render with required props 1`] = ` -
+
should render with required props 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- DevOps Engineer -
- - Opens in new window - - External Link Symbol", - } - } - viewBox="0 0 448 512" - /> +
+ DevOps Engineer +
+ + Opens in new window + External Link Symbol", + } + } + viewBox="0 0 448 512" + />
Building", @@ -164,8 +152,21 @@ exports[`FeaturedJobItem > should render with required props 1`] = `
+ className="flex items-center gap-0.5" + > + Map Marker", + } + } + viewBox="0 0 384 512" + /> +
+

should render with required props 1`] = ` rel="noopener noreferrer" target="_blank" > - - Operation Code's Code of Conduct. - - Opens in new window - - External Link Symbol", - } - } - viewBox="0 0 448 512" - /> + Operation Code's Code of Conduct. + + Opens in new window + External Link Symbol", + } + } + viewBox="0 0 448 512" + /> * @@ -286,24 +284,22 @@ exports[`RegistrationForm > should render with required props 1`] = ` rel="noopener noreferrer" target="_blank" > - - Operation Code's Slack Community Guidelines. - - Opens in new window - - External Link Symbol", - } - } - viewBox="0 0 448 512" - /> + Operation Code's Slack Community Guidelines. + + Opens in new window + External Link Symbol", + } + } + viewBox="0 0 448 512" + /> * diff --git a/components/OutboundLink/OutboundLink.tsx b/components/OutboundLink/OutboundLink.tsx index bd8353d50..0e71b20bc 100644 --- a/components/OutboundLink/OutboundLink.tsx +++ b/components/OutboundLink/OutboundLink.tsx @@ -53,12 +53,10 @@ function OutboundLink({ rel={isNotMailToLink ? 'noopener noreferrer' : undefined} target={isNotMailToLink ? '_blank' : undefined} > - - {children} + {children} - Opens in new window - {hasIcon && } - + Opens in new window + {hasIcon && } ); } diff --git a/components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.tsx.snap b/components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.tsx.snap index 5b02edc29..13cc0a36c 100644 --- a/components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.tsx.snap +++ b/components/OutboundLink/__tests__/__snapshots__/OutboundLink.test.tsx.snap @@ -8,23 +8,21 @@ exports[`OutboundLink > should render with required props 1`] = ` rel="noopener noreferrer" target="_blank" > - - Test - - Opens in new window - - External Link Symbol", - } - } - viewBox="0 0 448 512" - /> + Test + + Opens in new window + External Link Symbol", + } + } + viewBox="0 0 448 512" + /> `; diff --git a/components/PartnerLogoLink/__tests__/__snapshots__/PartnerLogoLink.test.tsx.snap b/components/PartnerLogoLink/__tests__/__snapshots__/PartnerLogoLink.test.tsx.snap index d5c3ae655..877ace7df 100644 --- a/components/PartnerLogoLink/__tests__/__snapshots__/PartnerLogoLink.test.tsx.snap +++ b/components/PartnerLogoLink/__tests__/__snapshots__/PartnerLogoLink.test.tsx.snap @@ -8,21 +8,19 @@ exports[`PartnerLogoLink > should render with required props 1`] = ` rel="noopener noreferrer" target="_blank" > - -

- Partner Inc. logo -
- - Opens in new window - +
+ Partner Inc. logo +
+ + Opens in new window `; diff --git a/components/ReusableSections/JoinSection/__tests__/__snapshots__/JoinSection.test.tsx.snap b/components/ReusableSections/JoinSection/__tests__/__snapshots__/JoinSection.test.tsx.snap index d360ae62e..6829b69c5 100644 --- a/components/ReusableSections/JoinSection/__tests__/__snapshots__/JoinSection.test.tsx.snap +++ b/components/ReusableSections/JoinSection/__tests__/__snapshots__/JoinSection.test.tsx.snap @@ -67,24 +67,22 @@ exports[`JoinSection > should render 1`] = ` rel="noopener noreferrer" target="_blank" > - - Never heard of Slack before? - - Opens in new window - - External Link Symbol", - } - } - viewBox="0 0 448 512" - /> + Never heard of Slack before? + + Opens in new window + External Link Symbol", + } + } + viewBox="0 0 448 512" + />
diff --git a/components/ReusableSections/SponsorsSection/__tests__/__snapshots__/SponsorsSection.test.tsx.snap b/components/ReusableSections/SponsorsSection/__tests__/__snapshots__/SponsorsSection.test.tsx.snap index 866ecd5a7..32b4cf02f 100644 --- a/components/ReusableSections/SponsorsSection/__tests__/__snapshots__/SponsorsSection.test.tsx.snap +++ b/components/ReusableSections/SponsorsSection/__tests__/__snapshots__/SponsorsSection.test.tsx.snap @@ -70,20 +70,18 @@ exports[`SponsorsSection > should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Etsy logo -
- - Opens in new window - +
+ Etsy logo +
+ + Opens in new window should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Juniper Networks logo -
- - Opens in new window - +
+ Juniper Networks logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Threat Stack logo -
- - Opens in new window - +
+ Threat Stack logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- US Bank logo -
- - Opens in new window - +
+ US Bank logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Umpqua Bank logo -
- - Opens in new window - +
+ Umpqua Bank logo +
+ + Opens in new window
@@ -206,21 +196,19 @@ exports[`SponsorsSection > should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- 1Password logo -
- - Opens in new window - +
+ 1Password logo +
+ + Opens in new window should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- APEX Systems logo -
- - Opens in new window - +
+ APEX Systems logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Airbnb logo -
- - Opens in new window - +
+ Airbnb logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Chromatic logo -
- - Opens in new window - +
+ Chromatic logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Code Platoon logo -
- - Opens in new window - +
+ Code Platoon logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Coursera logo -
- - Opens in new window - +
+ Coursera logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Elyon International logo -
- - Opens in new window - +
+ Elyon International logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- GitHub logo -
- - Opens in new window - +
+ GitHub logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Google logo -
- - Opens in new window - +
+ Google logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- HackerRank logo -
- - Opens in new window - +
+ HackerRank logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- LogRocket logo -
- - Opens in new window - +
+ LogRocket logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- O'Reilly Media logo -
- - Opens in new window - +
+ O'Reilly Media logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Secure Code Warrior logo -
- - Opens in new window - +
+ Secure Code Warrior logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Team Treehouse logo -
- - Opens in new window - +
+ Team Treehouse logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Unite Us logo -
- - Opens in new window - +
+ Unite Us logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Vercel logo -
- - Opens in new window - +
+ Vercel logo +
+ + Opens in new window
should render 1`] = ` rel="noopener noreferrer" target="_blank" > - -
- Zapier logo -
- - Opens in new window - +
+ Zapier logo +
+ + Opens in new window
diff --git a/components/SocialMedia/SocialMediaItem/__tests__/__snapshots__/SocialMediaItem.test.tsx.snap b/components/SocialMedia/SocialMediaItem/__tests__/__snapshots__/SocialMediaItem.test.tsx.snap index b168f469b..c08d2149c 100644 --- a/components/SocialMedia/SocialMediaItem/__tests__/__snapshots__/SocialMediaItem.test.tsx.snap +++ b/components/SocialMedia/SocialMediaItem/__tests__/__snapshots__/SocialMediaItem.test.tsx.snap @@ -11,28 +11,26 @@ exports[`SocialMediaItem > should render with required props 1`] = ` rel="noopener noreferrer" target="_blank" > - - - Operation Code's - Facebook - - Facebook Logo", - } + + Operation Code's + Facebook + + Facebook Logo", } - viewBox="0 0 500 500" - /> - - Opens in new window - + } + viewBox="0 0 500 500" + /> + + Opens in new window
From cdbc1095b01faf6e0bbb96639a24da6529121c98 Mon Sep 17 00:00:00 2001 From: Kyle Holmberg Date: Mon, 10 Nov 2025 20:57:29 +0700 Subject: [PATCH 2/5] remove more unused stuff --- common/utils/api-utils.ts | 31 +----- common/utils/auth-utils.js | 66 ------------- common/utils/cookie-utils.ts | 34 ------- components/Nav/__tests__/Nav.test.tsx | 5 - package.json | 4 - pnpm-lock.yaml | 135 -------------------------- test-utils/createComponentInstance.js | 6 -- test-utils/flushPromises.js | 5 - test-utils/jest-next-image.js | 12 --- test-utils/mocks/jwtMock.js | 6 -- test-utils/mocks/nextContextMock.js | 59 ----------- test-utils/mocks/nextRouterMock.js | 19 ---- test-utils/mocks/passwordResetMock.js | 2 - test-utils/mocks/svgMock.js | 8 -- test-utils/mocks/testFileMock.js | 1 - test-utils/transforms/file.js | 13 --- test-utils/wait.js | 1 - 17 files changed, 4 insertions(+), 403 deletions(-) delete mode 100644 common/utils/auth-utils.js delete mode 100644 common/utils/cookie-utils.ts delete mode 100644 test-utils/createComponentInstance.js delete mode 100644 test-utils/flushPromises.js delete mode 100644 test-utils/jest-next-image.js delete mode 100644 test-utils/mocks/jwtMock.js delete mode 100644 test-utils/mocks/nextContextMock.js delete mode 100644 test-utils/mocks/nextRouterMock.js delete mode 100644 test-utils/mocks/passwordResetMock.js delete mode 100644 test-utils/mocks/svgMock.js delete mode 100644 test-utils/mocks/testFileMock.js delete mode 100644 test-utils/transforms/file.js delete mode 100644 test-utils/wait.js diff --git a/common/utils/api-utils.ts b/common/utils/api-utils.ts index 7b68dcc53..260973e0f 100644 --- a/common/utils/api-utils.ts +++ b/common/utils/api-utils.ts @@ -2,7 +2,6 @@ import type { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios'; import axios from 'axios'; import { networkErrorMessages } from 'common/constants/messages'; import { apiUrl, resourcesAPIURL } from 'common/config/environment'; -import { setAuthorizationHeader } from 'common/utils/cookie-utils'; const baseAxiosConfig = { baseURL: apiUrl, @@ -37,17 +36,13 @@ const getRequestAbortionPieces = () => { export const get = async ( path: string, - { - token, - parameters, - }: { token?: string; parameters?: Record } = {}, + { parameters }: { parameters?: Record } = {}, axiosClient = OperationCodeAPI, ) => { const { abort, connectionTimeout } = getRequestAbortionPieces(); return axiosClient .get(path, { - headers: setAuthorizationHeader(token), cancelToken: abort.token, params: parameters, }) @@ -61,17 +56,11 @@ export const get = async ( }); }; -export const post = async ( - path: string, - body: object, - { token }: { token?: string } = {}, - axiosClient: AxiosInstance = axios, -) => { +export const post = async (path: string, body: object, axiosClient: AxiosInstance = axios) => { const { abort, connectionTimeout } = getRequestAbortionPieces(); return axiosClient .post(path, body, { - headers: setAuthorizationHeader(token), cancelToken: abort.token, }) .then(response => { @@ -84,17 +73,11 @@ export const post = async ( }); }; -export const patch = async ( - path: string, - body: object, - { token }: { token?: string } = {}, - axiosClient: AxiosInstance = axios, -) => { +export const patch = async (path: string, body: object, axiosClient: AxiosInstance = axios) => { const { abort, connectionTimeout } = getRequestAbortionPieces(); return axiosClient .patch(path, body, { - headers: setAuthorizationHeader(token), cancelToken: abort.token, }) .then(response => { @@ -107,17 +90,11 @@ export const patch = async ( }); }; -export const put = async ( - path: string, - body: object, - { token }: { token?: string } = {}, - axiosClient: AxiosInstance = axios, -) => { +export const put = async (path: string, body: object, axiosClient: AxiosInstance = axios) => { const { abort, connectionTimeout } = getRequestAbortionPieces(); return axiosClient .put(path, body, { - headers: setAuthorizationHeader(token), cancelToken: abort.token, }) .then(response => { diff --git a/common/utils/auth-utils.js b/common/utils/auth-utils.js deleted file mode 100644 index 84e95488b..000000000 --- a/common/utils/auth-utils.js +++ /dev/null @@ -1,66 +0,0 @@ -import Router from 'next/router'; -import nextCookie from 'next-cookies'; -import { setAuthCookies, removeAuthCookies, hasValidAuthToken } from './cookie-utils'; - -export const login = async ({ token }, routeTo = '/profile') => { - setAuthCookies({ token }); - await Router.push(routeTo); -}; - -export const logout = ({ routeTo = '/login', shouldRedirect = true } = {}) => { - removeAuthCookies(); - window.localStorage.setItem('logout', Date.now()); // Log out from all windows - if (shouldRedirect) { - Router.push(routeTo); - } -}; - -/** - * @description This method examines ctx via `getInitialProps` and returns a token if it exists. - * If a token does not exist, the user will be routed to /login - * - * @export - * @param {{ - * pathname: string, - * query: Object., - * asPath: string, - * req: Object., - * res: Object., - * err: Object. - * }} ctx - * @returns {?string} token or null - */ -export const authenticate = ctx => { - const { token } = nextCookie(ctx); - - if (!token || !hasValidAuthToken(token)) { - isomorphicRedirect('/login', ctx); - return ''; - } - - return token; -}; - -/** - * @description Utility for handling redirects. Works on both server during - * SSR and on the client - * - * @export - * @param {string} path - * @param {{ - * pathname: string, - * query: Object., - * asPath: string, - * req: Object., - * res: Object., - * err: Object. - * }} ctx - */ -export const isomorphicRedirect = (path, ctx) => { - if (ctx && ctx.res) { - ctx.res.writeHead(302, { Location: path }); - ctx.res.end(); - } else { - Router.push(path); - } -}; diff --git a/common/utils/cookie-utils.ts b/common/utils/cookie-utils.ts deleted file mode 100644 index 658cfbff2..000000000 --- a/common/utils/cookie-utils.ts +++ /dev/null @@ -1,34 +0,0 @@ -import cookie from 'js-cookie'; -import jwtDecode from 'jwt-decode'; - -export const setAuthCookies = ({ token }: { token: string }) => { - cookie.set('token', token); -}; - -export const removeAuthCookies = () => { - cookie.remove('token'); -}; - -export const setAuthorizationHeader = (token = getAuthToken()) => { - if (hasValidAuthToken(token)) { - return { Authorization: `Bearer ${token}` }; - } - - return {}; -}; - -export const getAuthToken = () => { - return cookie.get('token'); -}; - -export const hasValidAuthToken = (token = cookie.get('token')) => { - if (token === undefined) { - return false; - } - - const jwt = jwtDecode<{ exp: number }>(token); - const currentTime = new Date().getTime() / 1000; - - // Valid if jwt expiry is in the future - return currentTime < jwt.exp; -}; diff --git a/components/Nav/__tests__/Nav.test.tsx b/components/Nav/__tests__/Nav.test.tsx index 456e2dbca..49fc4c9de 100644 --- a/components/Nav/__tests__/Nav.test.tsx +++ b/components/Nav/__tests__/Nav.test.tsx @@ -1,4 +1,3 @@ -import cookie from 'js-cookie'; import { fireEvent, render, screen } from '@testing-library/react'; import { CLOSE_BUTTON } from 'common/constants/testIDs'; import createShallowSnapshotTest from 'test-utils/createShallowSnapshotTest'; @@ -6,10 +5,6 @@ import createShallowSnapshotTest from 'test-utils/createShallowSnapshotTest'; import { Nav } from '../Nav'; describe('Nav', () => { - beforeEach(() => { - cookie.get = vi.fn().mockImplementation(() => undefined); - }); - it('should render with no props passed', () => createShallowSnapshotTest(