Skip to content

Commit

Permalink
Conda store bug fix (#541)
Browse files Browse the repository at this point in the history
* updated code to fix bug when trying to open conda-store from app card

* adding index.js

* removed failing test will

* udpated code and test

* rearranged prevent default

---------

Co-authored-by: Kilian <[email protected]>
  • Loading branch information
kildre and Kilian authored Nov 25, 2024
1 parent cd088bf commit 9392e7e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 34 deletions.
2 changes: 1 addition & 1 deletion jhub_apps/static/js/index.js

Large diffs are not rendered by default.

59 changes: 29 additions & 30 deletions ui/src/components/app-card/app-card.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,36 +672,6 @@ describe('AppCard', () => {
expect(stopMenuItem).toBeInTheDocument();
expect(stopMenuItem).toHaveAttribute('aria-disabled', 'true');
});

test('disables edit and delete for shared apps', async () => {
const { getByTestId, getByText } = render(
<RecoilRoot>
<QueryClientProvider client={queryClient}>
<AppCard
id="1"
title="Shared App"
username="Other User"
framework="Some Framework"
url="/some-url"
serverStatus="Ready"
isShared={true} // App is shared
/>
</QueryClientProvider>
</RecoilRoot>,
);

// Open context menu first
const contextMenuButton = getByTestId('context-menu-button-card-menu-1');
act(() => {
contextMenuButton.click();
});

const editMenuItem = await waitFor(() => getByText('Edit'));
const deleteMenuItem = getByText('Delete');

expect(editMenuItem).toHaveAttribute('aria-disabled', 'true');
expect(deleteMenuItem).toHaveAttribute('aria-disabled', 'true');
});
test('redirects to app URL when app is running', async () => {
const mockHref = vi.spyOn(window, 'location', 'get').mockReturnValue({
href: '',
Expand Down Expand Up @@ -749,6 +719,35 @@ describe('AppCard', () => {
expect(window.location.href).toBe('/some-url'); // Verify redirection
mockHref.mockRestore();
});
test('disables edit and delete for shared apps', async () => {
const { getByTestId, getByText } = render(
<RecoilRoot>
<QueryClientProvider client={queryClient}>
<AppCard
id="1"
title="Shared App"
username="Other User"
framework="Some Framework"
url="/some-url"
serverStatus="Ready"
isShared={true} // App is shared
/>
</QueryClientProvider>
</RecoilRoot>,
);

// Open context menu first
const contextMenuButton = getByTestId('context-menu-button-card-menu-1');
act(() => {
contextMenuButton.click();
});

const editMenuItem = await waitFor(() => getByText('Edit'));
const deleteMenuItem = getByText('Delete');

expect(editMenuItem).toHaveAttribute('aria-disabled', 'true');
expect(deleteMenuItem).toHaveAttribute('aria-disabled', 'true');
});

test('sets currentApp state correctly on card click', async () => {
const { getByText } = render(
Expand Down
5 changes: 2 additions & 3 deletions ui/src/components/app-card/app-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,12 @@ export const AppCard = ({
<Link
href={url}
onClick={(e) => {
e.preventDefault();

if (serverStatus === 'Running') {
// Redirect to the app's URL if it is already running
window.location.href = url;
} else if (serverStatus === 'Ready') {
} else if (app && serverStatus === 'Ready') {
// Set the current app and open the Start modal
e.preventDefault();
setCurrentApp({
id,
name: title,
Expand Down

0 comments on commit 9392e7e

Please sign in to comment.