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

fix(site): add test and fix username params in terminal#8052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 1 commit intomainfrombq/fix-terminal-route
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletionssite/src/pages/TerminalPage/TerminalPage.test.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ import {
} from "../../testHelpers/renderHelpers"
import { server } from "../../testHelpers/server"
import TerminalPage, { Language } from "./TerminalPage"
import * as API from "api/api"

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

describe("TerminalPage", () => {
it("loads the right workspace data", async () => {
const spy = jest
.spyOn(API, "getWorkspaceByOwnerAndName")
.mockResolvedValue(MockWorkspace)
await renderTerminal(`/${MockUser.username}/${MockWorkspace.name}/terminal`)
await waitFor(() => {
expect(API.getWorkspaceByOwnerAndName).toHaveBeenCalledWith(
MockUser.username,
MockWorkspace.name,
)
})
spy.mockRestore()
})

it("shows an error if fetching workspace fails", async () => {
// Given
server.use(
Expand Down
4 changes: 3 additions & 1 deletionsite/src/pages/TerminalPage/TerminalPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,7 +73,9 @@ const TerminalPage: FC = () => {
const navigate = useNavigate()
const styles = useStyles()
const { proxy } = useProxy()
const { username, workspace: workspaceName } = useParams()
const params = useParams() as { username: string; workspace: string }
const username = params.username.replace("@", "")
const workspaceName = params.workspace
const xtermRef = useRef<HTMLDivElement>(null)
const [terminal, setTerminal] = useState<XTerm.Terminal | null>(null)
const [fitAddon, setFitAddon] = useState<FitAddon | null>(null)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp