Remove managed student assumptions from Lab 3 terminal

This commit is contained in:
2026-04-13 19:39:51 -06:00
parent ca6a966ad6
commit a97c8a7694
6 changed files with 25 additions and 45 deletions
+7 -13
View File
@@ -5,7 +5,6 @@ import {
} from "~/components/labs/Lab3TerminalFrame";
import {
LAB3_DEFAULT_TERMINAL_PATH,
LAB3_DEFAULT_WORKING_DIRECTORY,
fetchLab3RuntimeConfig,
getLab3TerminalPath,
LAB3_RUNTIME_CONFIG_PATH,
@@ -27,11 +26,9 @@ describe("getLab3TerminalPath", () => {
});
describe("normalizeLab3RuntimeConfig", () => {
it("fills in the default student terminal metadata", () => {
it("fills in the default terminal path", () => {
expect(normalizeLab3RuntimeConfig()).toEqual({
terminalPath: LAB3_DEFAULT_TERMINAL_PATH,
username: "student",
workingDirectory: LAB3_DEFAULT_WORKING_DIRECTORY,
});
});
});
@@ -48,8 +45,6 @@ describe("fetchLab3RuntimeConfig", () => {
new Response(
JSON.stringify({
lab3TerminalUrl: "http://127.0.0.1:7681/wetty",
lab3Username: "student",
lab3WorkingDirectory: "/home/student/lab3",
}),
{ status: 200 },
),
@@ -57,8 +52,6 @@ describe("fetchLab3RuntimeConfig", () => {
await expect(fetchLab3RuntimeConfig()).resolves.toEqual({
terminalPath: "http://127.0.0.1:7681/wetty",
username: "student",
workingDirectory: "/home/student/lab3",
});
expect(fetchMock).toHaveBeenCalledWith(LAB3_RUNTIME_CONFIG_PATH, {
@@ -82,7 +75,9 @@ describe("Lab3TerminalFrame", () => {
return link.getAttribute("href") === "/lab-terminal";
}),
).toBe(true);
expect(screen.getAllByText("/home/student/lab3")).toHaveLength(2);
expect(
screen.getByText(/log in with a local account that has/i),
).toBeInTheDocument();
});
it("loads the terminal settings from the runtime config artifact", async () => {
@@ -90,8 +85,6 @@ describe("Lab3TerminalFrame", () => {
new Response(
JSON.stringify({
lab3TerminalUrl: "http://127.0.0.1:7681/wetty",
lab3Username: "student",
lab3WorkingDirectory: "/srv/labs/lab3",
}),
{ status: 200 },
),
@@ -105,8 +98,9 @@ describe("Lab3TerminalFrame", () => {
"http://127.0.0.1:7681/wetty",
);
});
expect(screen.getAllByText("/srv/labs/lab3")).toHaveLength(2);
expect(
screen.getByText(/Sign in with any local account that can SSH/i),
).toBeInTheDocument();
});
it("toggles the dock open and closed", () => {
+4 -5
View File
@@ -87,8 +87,8 @@ export function Lab3TerminalFrame({ srcPath }: Lab3TerminalFrameProps) {
<h3>Use the lab shell directly in your browser</h3>
<p className="lab3-terminal-inline__lede">
The terminal is docked to the bottom of the page. Expand it with the
arrow when you&apos;re ready to log in as <code>{runtimeConfig.username}</code>{" "}
and work from <code>{runtimeConfig.workingDirectory}</code>.
arrow when you&apos;re ready to log in with a local account that has
password-based SSH access on this lab host.
</p>
</div>
@@ -140,9 +140,8 @@ export function Lab3TerminalFrame({ srcPath }: Lab3TerminalFrameProps) {
<div className="lab3-terminal-dock__panel" id="lab3-terminal-dock-panel">
<div className="lab3-terminal-dock__header">
<p className="lab3-terminal-dock__lede">
Log in as <code>{runtimeConfig.username}</code>, work from{" "}
<code>{runtimeConfig.workingDirectory}</code>, or pop the terminal
out into a full tab for more room.
Sign in with any local account that can SSH into this machine, or
pop the terminal out into a full tab for more room.
</p>
{isConfigResolved ? (
-9
View File
@@ -1,18 +1,12 @@
export const LAB3_DEFAULT_TERMINAL_PATH = "/wetty";
export const LAB3_DEFAULT_USERNAME = "student";
export const LAB3_DEFAULT_WORKING_DIRECTORY = "/home/student/lab3";
export const LAB3_RUNTIME_CONFIG_PATH = "/courseware-runtime.json";
export type Lab3RuntimeConfig = {
lab3TerminalUrl?: string;
lab3Username?: string;
lab3WorkingDirectory?: string;
};
export type ResolvedLab3RuntimeConfig = {
terminalPath: string;
username: string;
workingDirectory: string;
};
export function getLab3TerminalPath(envValue?: string) {
@@ -34,9 +28,6 @@ export function normalizeLab3RuntimeConfig(
): ResolvedLab3RuntimeConfig {
return {
terminalPath: getLab3TerminalPath(config?.lab3TerminalUrl),
username: config?.lab3Username?.trim() || LAB3_DEFAULT_USERNAME,
workingDirectory:
config?.lab3WorkingDirectory?.trim() || LAB3_DEFAULT_WORKING_DIRECTORY,
};
}