From 3dde2062d8153dec90f5e7a5a1698e3f84831e60 Mon Sep 17 00:00:00 2001 From: ilkin-overleaf <100852799+ilkin-overleaf@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:04:45 +0200 Subject: [PATCH] Merge pull request #17597 from overleaf/ii-enable-checkout-component-test [web] Enable Cypress test for creating new subscription GitOrigin-RevId: c17efbeb6a29d8e757729cddffef46faf054da70 --- .../frontend/js/shared/components/location.js | 17 +++++++++-------- .../frontend/js/shared/hooks/use-location.ts | 7 +++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/web/frontend/js/shared/components/location.js b/services/web/frontend/js/shared/components/location.js index 21cbb8695b..86dcb397f3 100644 --- a/services/web/frontend/js/shared/components/location.js +++ b/services/web/frontend/js/shared/components/location.js @@ -1,11 +1,12 @@ // window location-related functions in a separate module so they can be mocked/stubbed in tests -export function reload() { - // eslint-disable-next-line no-restricted-syntax - window.location.reload() -} - -export function assign(url) { - // eslint-disable-next-line no-restricted-syntax - window.location.assign(url) +export const location = { + assign(url) { + // eslint-disable-next-line no-restricted-syntax + window.location.assign(url) + }, + reload() { + // eslint-disable-next-line no-restricted-syntax + window.location.reload() + }, } diff --git a/services/web/frontend/js/shared/hooks/use-location.ts b/services/web/frontend/js/shared/hooks/use-location.ts index 52792b0fa9..12ee581605 100644 --- a/services/web/frontend/js/shared/hooks/use-location.ts +++ b/services/web/frontend/js/shared/hooks/use-location.ts @@ -1,5 +1,6 @@ import { useCallback, useMemo } from 'react' import useIsMounted from './use-is-mounted' +import { location } from '@/shared/components/location' export const useLocation = () => { const isMounted = useIsMounted() @@ -7,8 +8,7 @@ export const useLocation = () => { const assign = useCallback( url => { if (isMounted.current) { - // eslint-disable-next-line no-restricted-syntax - window.location.assign(url) + location.assign(url) } }, [isMounted] @@ -16,8 +16,7 @@ export const useLocation = () => { const reload = useCallback(() => { if (isMounted.current) { - // eslint-disable-next-line no-restricted-syntax - window.location.reload() + location.reload() } }, [isMounted])