Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4d23ff

Browse files
fix(site): add test and fix username params in terminal (#8052)
1 parentf61001d commite4d23ff

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎site/src/pages/TerminalPage/TerminalPage.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
}from"../../testHelpers/renderHelpers"
1616
import{server}from"../../testHelpers/server"
1717
importTerminalPage,{Language}from"./TerminalPage"
18+
import*asAPIfrom"api/api"
1819

1920
Object.defineProperty(window,"matchMedia",{
2021
writable:true,
@@ -63,6 +64,20 @@ const expectTerminalText = (container: HTMLElement, text: string) => {
6364
}
6465

6566
describe("TerminalPage",()=>{
67+
it("loads the right workspace data",async()=>{
68+
constspy=jest
69+
.spyOn(API,"getWorkspaceByOwnerAndName")
70+
.mockResolvedValue(MockWorkspace)
71+
awaitrenderTerminal(`/${MockUser.username}/${MockWorkspace.name}/terminal`)
72+
awaitwaitFor(()=>{
73+
expect(API.getWorkspaceByOwnerAndName).toHaveBeenCalledWith(
74+
MockUser.username,
75+
MockWorkspace.name,
76+
)
77+
})
78+
spy.mockRestore()
79+
})
80+
6681
it("shows an error if fetching workspace fails",async()=>{
6782
// Given
6883
server.use(

‎site/src/pages/TerminalPage/TerminalPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ const TerminalPage: FC = () => {
7373
constnavigate=useNavigate()
7474
conststyles=useStyles()
7575
const{ proxy}=useProxy()
76-
const{ username,workspace:workspaceName}=useParams()
76+
constparams=useParams()as{username:string;workspace:string}
77+
constusername=params.username.replace("@","")
78+
constworkspaceName=params.workspace
7779
constxtermRef=useRef<HTMLDivElement>(null)
7880
const[terminal,setTerminal]=useState<XTerm.Terminal|null>(null)
7981
const[fitAddon,setFitAddon]=useState<FitAddon|null>(null)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp