diff --git a/jsx/src/components/ServerDashboard/ServerDashboard.jsx b/jsx/src/components/ServerDashboard/ServerDashboard.jsx index e467fa85..7f159b6c 100644 --- a/jsx/src/components/ServerDashboard/ServerDashboard.jsx +++ b/jsx/src/components/ServerDashboard/ServerDashboard.jsx @@ -342,7 +342,7 @@ const ServerDashboard = (props) => { , - + { expect(delete_button).toBeEnabled(); } }); + +test("Start server and confirm pending state", async () => { + let spy = mockAsync(); + + let mockStartServer = jest.fn(() => { + return new Promise(async (resolve) => + clock.setTimeout(() => { + resolve({ status: 200 }); + }, 100), + ); + }); + + let mockUpdateUsers = jest.fn(() => Promise.resolve(mockAppState())); + + await act(async () => { + render( + + + + + + + , + ); + }); + + let actions = screen.getAllByTestId("user-row-server-activity")[1]; + let buttons = getAllByRole(actions, "button"); + + expect(buttons.length).toBe(2); + expect(buttons[0].textContent).toBe("Start Server"); + expect(buttons[1].textContent).toBe("Spawn Page"); + + await act(async () => { + fireEvent.click(buttons[0]); + }); + expect(mockUpdateUsers.mock.calls).toHaveLength(1); + + expect(buttons.length).toBe(2); + expect(buttons[0].textContent).toBe("Start Server"); + expect(buttons[0]).toBeDisabled(); + expect(buttons[1].textContent).toBe("Spawn Page"); + expect(buttons[1]).toBeEnabled(); + + await act(async () => { + await clock.tick(100); + }); + expect(mockUpdateUsers.mock.calls).toHaveLength(2); +}); diff --git a/jupyterhub/tests/browser/test_browser.py b/jupyterhub/tests/browser/test_browser.py index 502d2dcc..c15477ed 100644 --- a/jupyterhub/tests/browser/test_browser.py +++ b/jupyterhub/tests/browser/test_browser.py @@ -985,7 +985,7 @@ async def test_start_stop_server_on_admin_page( async def click_spawn_page(browser, username): """spawn the server for one user via the Spawn page button, index = 0 or 1""" - spawn_btn_xpath = f'//a[contains(@href, "spawn/{username}")]/button[contains(@class, "secondary")]' + spawn_btn_xpath = f'//a[contains(@href, "spawn/{username}")]/button[contains(@class, "btn-light")]' spawn_btn = browser.locator(spawn_btn_xpath) await expect(spawn_btn).to_be_enabled() async with browser.expect_navigation(url=f"**/user/{username}/"): @@ -993,7 +993,7 @@ async def test_start_stop_server_on_admin_page( async def click_access_server(browser, username): """access to the server for users via the Access Server button""" - access_btn_xpath = f'//a[contains(@href, "user/{username}")]/button[contains(@class, "primary")]' + access_btn_xpath = f'//a[contains(@href, "user/{username}")]/button[contains(@class, "btn-primary")]' access_btn = browser.locator(access_btn_xpath) await expect(access_btn).to_be_enabled() await access_btn.click()