From c7e5925f20d13afb0ef5309f4dc0c1faa47c613e Mon Sep 17 00:00:00 2001 From: Spencer Peace Date: Tue, 12 Nov 2024 13:49:17 +0100 Subject: [PATCH 1/5] enable deprecation, no-alphabetical-sort sonarjs eslint rules, replace waitForNavigation with waitForURL --- eslint.config.js | 2 -- scripts/unusedStrapiEntries.ts | 2 +- tests/e2e/pom/Formular.ts | 3 ++- tests/e2e/pom/Vorabcheck.ts | 3 ++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 0efdb1e7e..6a342261e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -128,9 +128,7 @@ export default tseslint.config( // fix/reevaluate "sonarjs/new-cap": "off", - "sonarjs/deprecation": "off", "sonarjs/function-return-type": "off", - "sonarjs/no-alphabetical-sort": "off", "sonarjs/no-base-to-string": "off", "sonarjs/no-invalid-await": "off", "sonarjs/no-undefined-argument": "off", diff --git a/scripts/unusedStrapiEntries.ts b/scripts/unusedStrapiEntries.ts index 311c70bee..4f8488775 100644 --- a/scripts/unusedStrapiEntries.ts +++ b/scripts/unusedStrapiEntries.ts @@ -106,7 +106,7 @@ async function unusedStrapiEntry() { console.log( `Found ${unusedUrls.length} unused strapi entries with following stepIds: `, - // eslint-disable-next-line sonarjs/no-misleading-array-reverse + // eslint-disable-next-line sonarjs/no-misleading-array-reverse, sonarjs/no-alphabetical-sort unusedUrls.sort(), ); } diff --git a/tests/e2e/pom/Formular.ts b/tests/e2e/pom/Formular.ts index 3b5742790..7ad162092 100644 --- a/tests/e2e/pom/Formular.ts +++ b/tests/e2e/pom/Formular.ts @@ -5,6 +5,7 @@ export class Formular { readonly url: string = ""; readonly initialStep: string = ""; readonly nextButtonName = "_action"; + readonly isValidUrl = (url: URL) => url.toString().includes(this.url); constructor(page: Page) { this.page = page; @@ -30,7 +31,7 @@ export class Formular { async clickNext() { await this.page.locator(`button[name="${this.nextButtonName}"]`).click(); - await this.page.waitForNavigation(); // deprecated but URL for waitForURL is unknown + await this.page.waitForURL(this.isValidUrl); } async fillRadioPage(field: string, option: string) { diff --git a/tests/e2e/pom/Vorabcheck.ts b/tests/e2e/pom/Vorabcheck.ts index 326ec7ac1..62fd5895a 100644 --- a/tests/e2e/pom/Vorabcheck.ts +++ b/tests/e2e/pom/Vorabcheck.ts @@ -6,6 +6,7 @@ export class Vorabcheck { readonly url: string = ""; readonly initialStep: string = ""; readonly nextButtonName = "_action"; + readonly isValidUrl = (url: URL) => url.toString().includes(this.url); constructor(page: Page) { this.page = page; @@ -29,7 +30,7 @@ export class Vorabcheck { async clickNext() { await this.page.locator(`button[name="${this.nextButtonName}"]`).click(); await this.page.waitForLoadState("load"); - await this.page.waitForNavigation(); // deprecated but URL for waitForURL is unknown + await this.page.waitForURL(this.isValidUrl); } async clickNextWithoutJavaScript() { From 62aea26a5eab3e0eebb054a1e2a379c9692b66b8 Mon Sep 17 00:00:00 2001 From: Spencer Peace Date: Tue, 12 Nov 2024 16:02:33 +0100 Subject: [PATCH 2/5] replace all instances of json() with data() where applicable, plain objects otherwise --- .../userFeedback/__test__/RatingBox.test.tsx | 7 ---- .../__test__/UserFeedback.test.tsx | 16 ++++++--- app/components/userFeedback/index.tsx | 5 +-- app/root.tsx | 36 ++++++++++--------- app/routes/$.tsx | 3 +- .../__test__/action.send-feedback.test.ts | 28 +++++++++------ .../__test__/action.send-rating.test.ts | 24 ++++++++----- .../persoenliche-daten-loeschen.test.tsx | 9 +++-- app/routes/_index.tsx | 3 +- app/routes/action.send-rating.ts | 4 +-- app/routes/action.set-analytics.tsx | 4 +-- app/routes/beratungshilfe.tsx | 4 +-- ...ilfe.zustaendiges-gericht.auswahl.$PLZ.tsx | 6 ++-- ...shilfe.zustaendiges-gericht.ergebnis.$.tsx | 4 +-- ...atungshilfe.zustaendiges-gericht.suche.tsx | 9 ++--- app/routes/data-list-options.$TYPE.ts | 6 ++-- app/routes/feedback.erfolgreich.tsx | 3 +- app/routes/fluggastrechte.tsx | 4 +-- ...n.vorabcheck.partnergericht.ergebnis.$.tsx | 3 +- app/routes/kitchensink._index.tsx | 3 +- app/routes/opensource.tsx | 6 ++-- app/routes/prozesskostenhilfe.tsx | 4 +-- app/routes/shared/components/FormFlowPage.tsx | 28 ++++++++------- app/routes/shared/components/ResultPage.tsx | 5 +-- .../shared/components/VorabcheckPage.tsx | 14 ++++---- app/routes/shared/formular.server.ts | 4 +-- app/routes/shared/result.server.ts | 4 +-- app/routes/shared/visualisierung.server.ts | 4 +-- app/routes/shared/vorabcheck.server.ts | 4 +-- .../getRedirectForNonRelativeUrl.test.ts | 8 ++--- .../feedback/getRedirectForNonRelativeUrl.ts | 4 +-- stories/UserFeedback.stories.tsx | 2 +- 32 files changed, 144 insertions(+), 124 deletions(-) diff --git a/app/components/userFeedback/__test__/RatingBox.test.tsx b/app/components/userFeedback/__test__/RatingBox.test.tsx index f2c4230a3..e85a22bb2 100644 --- a/app/components/userFeedback/__test__/RatingBox.test.tsx +++ b/app/components/userFeedback/__test__/RatingBox.test.tsx @@ -1,4 +1,3 @@ -import { json } from "@remix-run/node"; import { createRemixStub } from "@remix-run/testing"; import { fireEvent, render } from "@testing-library/react"; import { useMemo } from "react"; @@ -59,9 +58,6 @@ describe("RatingBox", () => { }, { path: "/action/send-rating", - action() { - return json({}); - }, }, ]); const { getByText } = render(); @@ -84,9 +80,6 @@ describe("RatingBox", () => { }, { path: "/action/send-rating", - action() { - return json({}); - }, }, ]); const { getByText } = render(); diff --git a/app/components/userFeedback/__test__/UserFeedback.test.tsx b/app/components/userFeedback/__test__/UserFeedback.test.tsx index cb78c01bf..7724b1784 100644 --- a/app/components/userFeedback/__test__/UserFeedback.test.tsx +++ b/app/components/userFeedback/__test__/UserFeedback.test.tsx @@ -22,7 +22,9 @@ describe("UserFeedback", () => { render( , ); @@ -40,7 +42,9 @@ describe("UserFeedback", () => { render( , ); @@ -58,7 +62,9 @@ describe("UserFeedback", () => { render( , ); @@ -75,7 +81,9 @@ describe("UserFeedback", () => { render( , ); diff --git a/app/components/userFeedback/index.tsx b/app/components/userFeedback/index.tsx index 18855a21b..901b37563 100644 --- a/app/components/userFeedback/index.tsx +++ b/app/components/userFeedback/index.tsx @@ -24,12 +24,13 @@ export default function UserFeedback(props: Readonly) { const [shouldFocus, setShouldFocus] = useState(false); const rootLoaderData = useRouteLoaderData("root"); - const bannerState = rootLoaderData?.bannerState ?? BannerState.ShowRating; - const applyFocus = useCallback(() => { setShouldFocus(true); }, []); + const bannerState = + rootLoaderData?.data.bannerState ?? BannerState.ShowRating; + return ( { trackingConsent, ); - return json( + return data( { header: { ...getPageHeaderProps(strapiHeader), @@ -148,16 +148,18 @@ export const loader = async ({ request, context }: LoaderFunctionArgs) => { function App() { const { - header, - footer, - cookieBannerContent, - hasTrackingConsent, - deletionLabel, - hasAnyUserData, - feedbackTranslations, - pageHeaderTranslations, - videoTranslations, - accessibilityTranslations, + data: { + header, + footer, + cookieBannerContent, + hasTrackingConsent, + deletionLabel, + hasAnyUserData, + feedbackTranslations, + pageHeaderTranslations, + videoTranslations, + accessibilityTranslations, + }, } = useLoaderData(); const matches = useMatches(); const { breadcrumbs, title, ogTitle, description } = metaFromMatches(matches); @@ -246,17 +248,17 @@ export function ErrorBoundary() { {loaderData && (
)}
- {loaderData &&