From 24c29fe0b35efa1dd7662c662ab319ad9ce4288e Mon Sep 17 00:00:00 2001 From: Chi-chi Wang Date: Fri, 5 Jul 2024 20:37:59 -0500 Subject: [PATCH] [app:components:ExternalLink] Do not automatically open external links in new tab --- app/Layout/__tests__/Nav.test.js | 1 - .../__tests__/__snapshots__/Nav.test.js.snap | 2 - .../__snapshots__/index.test.js.snap | 4 - .../__snapshots__/index.test.js.snap | 4 - app/components/ExternalLink/index.tsx | 2 +- .../__snapshots__/index.test.js.snap | 156 ------------------ .../__snapshots__/index.test.js.snap | 54 ------ 7 files changed, 1 insertion(+), 222 deletions(-) diff --git a/app/Layout/__tests__/Nav.test.js b/app/Layout/__tests__/Nav.test.js index 2d2e4d3..c6e7039 100644 --- a/app/Layout/__tests__/Nav.test.js +++ b/app/Layout/__tests__/Nav.test.js @@ -69,7 +69,6 @@ describe('Layout/Nav Component', () => { render(); expect(screen.getByRole('link', { name: 'Github logo' })).toHaveAttribute('href', 'https://github.com/chichiwang/tamsui'); - expect(screen.getByRole('link', { name: 'Github logo' })).toHaveAttribute('target', '_blank'); }); }); }); diff --git a/app/Layout/__tests__/__snapshots__/Nav.test.js.snap b/app/Layout/__tests__/__snapshots__/Nav.test.js.snap index 420693f..53785b4 100644 --- a/app/Layout/__tests__/__snapshots__/Nav.test.js.snap +++ b/app/Layout/__tests__/__snapshots__/Nav.test.js.snap @@ -42,8 +42,6 @@ exports[`Layout/Nav Component matches snapshot 1`] = ` > Github logo Github logo Chi-chi Wang diff --git a/app/components/ExternalLink/__tests__/__snapshots__/index.test.js.snap b/app/components/ExternalLink/__tests__/__snapshots__/index.test.js.snap index 6fa6152..eab527b 100644 --- a/app/components/ExternalLink/__tests__/__snapshots__/index.test.js.snap +++ b/app/components/ExternalLink/__tests__/__snapshots__/index.test.js.snap @@ -4,8 +4,6 @@ exports[`ExternalLink Component className snapshot 1`] = ` Developer Documentation @@ -16,8 +14,6 @@ exports[`ExternalLink Component className snapshot 1`] = ` exports[`ExternalLink Component matches snapshot 1`] = ` Repository diff --git a/app/components/ExternalLink/index.tsx b/app/components/ExternalLink/index.tsx index f5fa721..f8b9f7f 100644 --- a/app/components/ExternalLink/index.tsx +++ b/app/components/ExternalLink/index.tsx @@ -11,7 +11,7 @@ function ExternalLink({ href, }: ExternalLinkProps) { return ( - + {children} ); diff --git a/pages/Documentation/__tests__/__snapshots__/index.test.js.snap b/pages/Documentation/__tests__/__snapshots__/index.test.js.snap index 043574b..39fa698 100644 --- a/pages/Documentation/__tests__/__snapshots__/index.test.js.snap +++ b/pages/Documentation/__tests__/__snapshots__/index.test.js.snap @@ -25,16 +25,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Documentation is also provided in the Github repository in the README file /docs/README.md @@ -188,8 +184,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Clone the repository @@ -540,8 +534,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` > Reset the git remote @@ -593,8 +585,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` If using nvm @@ -658,8 +648,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` to see the version of Node.js @@ -853,8 +841,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Run webpack-bundle-analyzer @@ -940,8 +926,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Build dev assets and run webpack-bundle-analyzer @@ -1021,8 +1005,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Build prod assets and run webpack-bundle-analyzer @@ -1506,8 +1488,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Build dev assets and run the webserver, running server logs through pino-pretty @@ -1587,8 +1567,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Run ESLint @@ -1667,8 +1645,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Build prod assets and run the webserver, running server logs through pino-pretty @@ -1974,8 +1950,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Update snapshots with Jest @@ -2260,16 +2234,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` uses environment-aware configurations via Webpack's DefinePlugin . This behavior is instrumented in webpack/define.js @@ -2334,16 +2304,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` (string): The intended deployment URL of the application in each environment, used to set canonical links and Open Graph @@ -2495,16 +2461,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Then add a type declaration for the new configuration variable to app/global.d.ts @@ -2594,8 +2556,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` To avoid running afoul of ESLint's no-undef @@ -2737,8 +2697,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` passed into the DefinePlugin @@ -2911,8 +2869,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` object, or adding the variable to the Jest globals object @@ -2943,8 +2899,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` (as appropriate) in jest.config.js @@ -3024,8 +2978,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` will run the server output through pino-pretty @@ -3091,8 +3043,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` At the moment it only contains the entrypoint file, which mounts and hydrates the root application @@ -3109,32 +3059,24 @@ exports[`Documentation Page Component matches snapshot 1`] = ` the html root, head, and body. The routes are housed in app/dataRoutes as a data routes object . The reason the routes are not declared in JSX is for compatibility with rendering React to a Node.js stream @@ -3151,8 +3093,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` application via the dataRoutes object @@ -3169,8 +3109,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` directories. Pino @@ -3368,8 +3306,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` should be updated in the Webpack configs @@ -3379,16 +3315,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` The alias mapping should be added to the eslint configuration @@ -3398,8 +3330,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` The alias should be updated in the paths configuration @@ -3409,16 +3339,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` The alias should be updated in the moduleNameMapper configuration in the Jest configuration @@ -3491,8 +3417,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` The directory static/ @@ -3639,40 +3563,30 @@ exports[`Documentation Page Component matches snapshot 1`] = ` implements a basic React Error Boundary in app/ErrorBoundary . This error boundary is configured as an errorElement in the dataRoutes object. It is recommended all root routes are wrapped in this error boundary. A utility, withErrorBoundary @@ -3860,16 +3774,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` , configured by default to be the application's error page @@ -3879,8 +3789,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` On the client, an error in a page will render the ErrorPage component @@ -3899,16 +3807,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` in server/appHandler.tsx . Make sure you define this route in the app/dataRoutes/index.ts @@ -3918,8 +3822,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Alternatively, keep the error page path and just replace the ErrorPage component @@ -3981,8 +3883,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` utilizes Jest @@ -4009,8 +3909,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` The default coverage threshold @@ -4023,8 +3921,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` field in the config @@ -4040,8 +3936,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` . To update Jest snapshots @@ -4112,16 +4006,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` Layouts can be directly applied to routes in React Router using Layout Routes @@ -4373,8 +4263,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` In the boilerplate, a default Layout has been created in app/Layout @@ -4389,32 +4277,24 @@ exports[`Documentation Page Component matches snapshot 1`] = ` A solution has been implemented in this boilerplate in the form of a custom react hook : useResetScroll . This hook needs to be invoked by any layouts in use, and Links to pages that need the scroll reset need to pass a state @@ -4433,8 +4313,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` . A reusable component InternalLink @@ -4496,16 +4374,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` uses a React Router data router . A route can be passed a handle @@ -4513,8 +4387,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` component using the useMatches @@ -4524,8 +4396,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` This boilerplate has a baseline implementation of this usage in place, passing a PageHandle @@ -4693,8 +4563,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` then these values will be used by the app/Head @@ -4707,24 +4575,18 @@ exports[`Documentation Page Component matches snapshot 1`] = ` : app/Head is rendered by app/HTMLBody , which rendered by app/Layout @@ -4737,8 +4599,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` the ideal component to house site-wide document head @@ -4757,8 +4617,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` and invoke the hook useResetScroll @@ -4768,8 +4626,6 @@ exports[`Documentation Page Component matches snapshot 1`] = ` A custom hook, app/hooks/useRouteHead @@ -5345,16 +5201,12 @@ exports[`Documentation Page Component matches snapshot 1`] = ` contains a Github Pull Request template that is intended to provide a scaffold for a thorough pull request. This template @@ -5471,32 +5323,24 @@ exports[`Documentation Page Component matches snapshot 1`] = ` contains a Github workflow configured to run the linter and test runner on push events . If this is not desired, disable the workflow in Github diff --git a/pages/Home/__tests__/__snapshots__/index.test.js.snap b/pages/Home/__tests__/__snapshots__/index.test.js.snap index 7bc83e4..3e409e5 100644 --- a/pages/Home/__tests__/__snapshots__/index.test.js.snap +++ b/pages/Home/__tests__/__snapshots__/index.test.js.snap @@ -650,40 +650,30 @@ exports[`Home Component matches snapshot 1`] = ` Tamsui is a Node.js boilerplate using TypeScript and React . It provides server-side rendering using an Express webserver for a client-side React @@ -693,16 +683,12 @@ exports[`Home Component matches snapshot 1`] = ` Tamsui renders a React application to a Node.js stream utilizing React 18's renderToPipeableStream method @@ -765,8 +751,6 @@ exports[`Home Component matches snapshot 1`] = ` for building out a client served by a webserver that acts as a backend for frontend @@ -780,16 +764,12 @@ exports[`Home Component matches snapshot 1`] = ` Technical decisions will be documented in pull request descriptions , project decisions documented in a project board @@ -848,24 +828,18 @@ exports[`Home Component matches snapshot 1`] = ` Tamsui is an isomorphic JavaScript application. The Express server that renders the application is intended to serve as a simple backend for frontend @@ -944,8 +918,6 @@ exports[`Home Component matches snapshot 1`] = ` > Node.js @@ -955,8 +927,6 @@ exports[`Home Component matches snapshot 1`] = ` > Express @@ -966,8 +936,6 @@ exports[`Home Component matches snapshot 1`] = ` > React @@ -977,8 +945,6 @@ exports[`Home Component matches snapshot 1`] = ` > React Router @@ -988,8 +954,6 @@ exports[`Home Component matches snapshot 1`] = ` > Pino @@ -1012,8 +976,6 @@ exports[`Home Component matches snapshot 1`] = ` > React @@ -1023,8 +985,6 @@ exports[`Home Component matches snapshot 1`] = ` > React Router @@ -1047,8 +1007,6 @@ exports[`Home Component matches snapshot 1`] = ` > TypeScript @@ -1058,8 +1016,6 @@ exports[`Home Component matches snapshot 1`] = ` > Sass @@ -1069,8 +1025,6 @@ exports[`Home Component matches snapshot 1`] = ` > Webpack @@ -1080,8 +1034,6 @@ exports[`Home Component matches snapshot 1`] = ` > Babel @@ -1091,8 +1043,6 @@ exports[`Home Component matches snapshot 1`] = ` > Jest @@ -1102,8 +1052,6 @@ exports[`Home Component matches snapshot 1`] = ` > React Testing Library @@ -1113,8 +1061,6 @@ exports[`Home Component matches snapshot 1`] = ` > Eslint