Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix(JobsTab): improve aria-label and test coverage for disabled Run Now action (#4036)

[._.]/ Adam Eivy8c8c66a4dbed
diff --git a/client/src/components/cos/tabs/JobsTab.jsx b/client/src/components/cos/tabs/JobsTab.jsx
index 44ae3765c1..378ece467c 100644
--- a/client/src/components/cos/tabs/JobsTab.jsx
+++ b/client/src/components/cos/tabs/JobsTab.jsx
@@ -425,11 +425,11 @@ function JobCard({ job, apps, providers, onToggle, onTrigger, onDelete, onUpdate
<button
onClick={() => onTrigger(job.id)}
disabled={editing}
- className={`p-1.5 transition-colors ${
- editing ? 'text-gray-600 opacity-50 cursor-not-allowed' : 'text-gray-500 hover:text-port-accent'
+ className={`p-1.5 transition-colors text-gray-500 ${
+ editing ? 'opacity-50 cursor-not-allowed' : 'hover:text-port-accent'
}`}
title={editing ? 'Save changes before running job' : 'Run now'}
- aria-label="Run now"
+ aria-label={editing ? 'Save changes before running job' : 'Run now'}
>
<Play size={14} />
</button>
diff --git a/client/src/components/cos/tabs/JobsTab.test.jsx b/client/src/components/cos/tabs/JobsTab.test.jsx
index 2aef526e53..58109710a1 100644
--- a/client/src/components/cos/tabs/JobsTab.test.jsx
+++ b/client/src/components/cos/tabs/JobsTab.test.jsx
@@ -1,5 +1,6 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import JobsTab from './JobsTab';
const api = vi.hoisted(() => ({
getCosJobs: vi.fn(),
@@ -17,8 +18,6 @@ const toast = vi.hoisted(() => ({ success: vi.fn(), error: vi.fn() }));
vi.mock('../../../services/api', () => api);
vi.mock('../../ui/Toast', () => ({ default: toast }));
-const JobsTab = (await import('./JobsTab')).default;
-
const mockJob = {
id: 'job-1',
name: 'Test Job',
@@ -46,7 +45,7 @@ beforeEach(() => {
});
describe('JobsTab / JobCard Run Now disable behavior (#4036)', () => {
- it('enables the Run now button when not editing and disables it while editing', async () => {
+ it('enables the Run now button when not editing and disables it while editing (save flow)', async () => {
render(<JobsTab apps={[]} providers={[]} />);
// Wait for jobs to load
@@ -60,19 +59,37 @@ describe('JobsTab / JobCard Run Now disable behavior (#4036)', () => {
const editButton = screen.getByRole('button', { name: 'Edit' });
fireEvent.click(editButton);
- // Now Run now button should be disabled
- expect(runNowButton).toBeDisabled();
- expect(runNowButton).toHaveAttribute('title', 'Save changes before running job');
+ // Now Run now button should be disabled with updated title & aria-label
+ const disabledRunNowButton = screen.getByRole('button', { name: 'Save changes before running job' });
+ expect(disabledRunNowButton).toBeDisabled();
+ expect(disabledRunNowButton).toHaveAttribute('title', 'Save changes before running job');
// Attempting to click Run now while editing should not trigger job
- fireEvent.click(runNowButton);
+ fireEvent.click(disabledRunNowButton);
expect(api.triggerCosJob).not.toHaveBeenCalled();
// Saving edits should re-enable the button
const saveButton = screen.getByRole('button', { name: 'Save' });
fireEvent.click(saveButton);
- await waitFor(() => expect(runNowButton).not.toBeDisabled());
- expect(runNowButton).toHaveAttribute('title', 'Run now');
+ await waitFor(() => expect(screen.getByRole('button', { name: 'Run now' })).not.toBeDisabled());
+ });
+
+ it('re-enables the Run now button when exiting edit mode via Cancel', async () => {
+ render(<JobsTab apps={[]} providers={[]} />);
+
+ await waitFor(() => expect(screen.getByText('Test Job')).toBeInTheDocument());
+
+ const editButton = screen.getByRole('button', { name: 'Edit' });
+ fireEvent.click(editButton);
+
+ expect(screen.getByRole('button', { name: 'Save changes before running job' })).toBeDisabled();
+
+ // Click Cancel button
+ const cancelButton = screen.getByRole('button', { name: 'Cancel' });
+ fireEvent.click(cancelButton);
+
+ const reEnabledRunNow = screen.getByRole('button', { name: 'Run now' });
+ expect(reEnabledRunNow).not.toBeDisabled();
});
});