Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6252f78

Browse files
fix: Setup redirect state (#5759)
1 parent 501cfa9 commit 6252f78

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

site/jest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { cleanup } from "@testing-library/react"
33
import crypto from "crypto"
44
import * as util from "util"
55
import { server } from "./src/testHelpers/server"
6+
import "jest-location-mock"
67

78
// Polyfill the getRandomValues that is used on utils/random.ts
89
Object.defineProperty(global.self, "crypto", {

site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"front-matter": "4.0.2",
5656
"history": "5.3.0",
5757
"i18next": "21.9.1",
58+
"jest-location-mock": "1.0.9",
5859
"js-untar": "2.0.0",
5960
"just-debounce-it": "3.1.1",
6061
"playwright": "^1.29.2",

site/src/pages/SetupPage/SetupPage.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ describe("Setup Page", () => {
9494
)
9595

9696
await fillForm()
97-
await waitFor(() =>
98-
expect(history.location.pathname).toEqual("/workspaces"),
99-
)
97+
await waitFor(() => expect(window.location).toBeAt("/workspaces"))
10098
})
10199
})

site/src/pages/SetupPage/SetupPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { useActor, useMachine } from "@xstate/react"
22
import { FC, useContext, useEffect } from "react"
33
import { Helmet } from "react-helmet-async"
4-
import { useNavigate } from "react-router-dom"
54
import { pageTitle } from "util/page"
65
import { setupMachine } from "xServices/setup/setupXService"
76
import { XServiceContext } from "xServices/StateContext"
87
import { SetupPageView } from "./SetupPageView"
98

109
export const SetupPage: FC = () => {
11-
const navigate = useNavigate()
1210
const xServices = useContext(XServiceContext)
1311
const [authState, authSend] = useActor(xServices.authXService)
1412
const [setupState, setupSend] = useMachine(setupMachine, {
@@ -30,9 +28,9 @@ export const SetupPage: FC = () => {
3028

3129
useEffect(() => {
3230
if (authState.matches("signedIn")) {
33-
return navigate("/workspaces")
31+
window.location.assign("/workspaces")
3432
}
35-
}, [authState, navigate])
33+
}, [authState])
3634

3735
return (
3836
<>

site/yarn.lock

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,11 @@
13781378
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98"
13791379
integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==
13801380

1381+
"@jedmao/location@^3.0.0":
1382+
version "3.0.0"
1383+
resolved "https://registry.yarnpkg.com/@jedmao/location/-/location-3.0.0.tgz#f2b24e937386f95252f3a1fefbf7ca2e0a4b87e9"
1384+
integrity sha512-p7mzNlgJbCioUYLUEKds3cQG4CHONVFJNYqMe6ocEtENCL/jYmMo1Q3ApwsMmU+L0ZkaDJEyv4HokaByLoPwlQ==
1385+
13811386
"@jest/console@^27.5.1":
13821387
version "27.5.1"
13831388
resolved "https://registry.yarnpkg.com/@jest/console/-/console-27.5.1.tgz#260fe7239602fe5130a94f1aa386eff54b014bba"
@@ -8671,7 +8676,7 @@ jest-config@^27.5.1:
86718676
slash "^3.0.0"
86728677
strip-json-comments "^3.1.1"
86738678

8674-
jest-diff@^27.5.1:
8679+
jest-diff@^27.0.1, jest-diff@^27.5.1:
86758680
version "27.5.1"
86768681
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.5.1.tgz#a07f5011ac9e6643cf8a95a462b7b1ecf6680def"
86778682
integrity sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==
@@ -8839,6 +8844,14 @@ jest-leak-detector@^27.5.1:
88398844
jest-get-type "^27.5.1"
88408845
pretty-format "^27.5.1"
88418846

8847+
8848+
version "1.0.9"
8849+
resolved "https://registry.yarnpkg.com/jest-location-mock/-/jest-location-mock-1.0.9.tgz#f4466362423b273e12ca3716467a3d478ce78fa8"
8850+
integrity sha512-DN/v7Zsa3N4uGgWTCrMrPPxhZORr/4N5gi+u7Tk6sLdORYplrC0//wfFN5FOtx4ZdQzDVfY6rLa4d+wfTKzQHw==
8851+
dependencies:
8852+
"@jedmao/location" "^3.0.0"
8853+
jest-diff "^27.0.1"
8854+
88428855
jest-matcher-utils@^27.0.0, jest-matcher-utils@^27.5.1:
88438856
version "27.5.1"
88448857
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz#9c0cdbda8245bc22d2331729d1091308b40cf8ab"

0 commit comments

Comments
 (0)