fix spawn page link

This commit is contained in:
Min RK
2022-06-08 10:48:04 +02:00
parent 62d24341ca
commit 2e878fb5ca
3 changed files with 15 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ const AccessServerButton = ({ url }) => (
); );
const ServerDashboard = (props) => { const ServerDashboard = (props) => {
let base_url = window.base_url; let base_url = window.base_url || "/";
// sort methods // sort methods
var usernameDesc = (e) => e.sort((a, b) => (a.name > b.name ? 1 : -1)), var usernameDesc = (e) => e.sort((a, b) => (a.name > b.name ? 1 : -1)),
usernameAsc = (e) => e.sort((a, b) => (a.name < b.name ? 1 : -1)), usernameAsc = (e) => e.sort((a, b) => (a.name < b.name ? 1 : -1)),
@@ -277,7 +277,7 @@ const ServerDashboard = (props) => {
/> />
<a <a
href={`${base_url}spawn/${user.name}${ href={`${base_url}spawn/${user.name}${
server.name && "/" + server.name server.name ? "/" + server.name : ""
}`} }`}
> >
<button <button

View File

@@ -98,6 +98,18 @@ test("Renders correctly the status of a single-user server", async () => {
expect(stop).toBeVisible(); expect(stop).toBeVisible();
}); });
test("Renders spawn page link", async () => {
let callbackSpy = mockAsync();
await act(async () => {
render(serverDashboardJsx(callbackSpy));
});
let link = screen.getByText("Spawn Page").closest("a");
let url = new URL(link.href);
expect(url.pathname).toEqual("/spawn/bar");
});
test("Invokes the startServer event on button click", async () => { test("Invokes the startServer event on button click", async () => {
let callbackSpy = mockAsync(); let callbackSpy = mockAsync();

View File

@@ -1,5 +1,5 @@
export const jhapiRequest = (endpoint, method, data) => { export const jhapiRequest = (endpoint, method, data) => {
let base_url = window.base_url, let base_url = window.base_url || "/",
api_url = `${base_url}hub/api`; api_url = `${base_url}hub/api`;
return fetch(api_url + endpoint, { return fetch(api_url + endpoint, {
method: method, method: method,