Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conda store bug fix #541

Merged
merged 5 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
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,12 +215,11 @@ export const AppCard = ({
<Link
href={url}
onClick={(e) => {
e.preventDefault();

if (serverStatus === 'Running') {
e.preventDefault();
kildre marked this conversation as resolved.
Show resolved Hide resolved
// 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
setCurrentApp({
id,
Expand Down
Loading