Skip to content

Commit 94ef5b5

Browse files
committed
make disable unavailable accel test more robust
1 parent 6fd2716 commit 94ef5b5

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/accelerators/__tests__/AcceleratorButton.test.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,9 @@ describe('AcceleratorSelector Component', () => {
761761
* Test flow:
762762
* 1. Set up system info with mix of available/unavailable accelerators
763763
* 2. Render component
764-
* 3. Component checks plugin status for each accelerator
765-
* 4. Verify getPluginStatus() was called (component checks availability)
766-
* 5. Unavailable accelerators should be disabled in dropdown (tested implicitly)
764+
* 3. Wait for dropdown to be populated
765+
* 4. Assert the unavailable option (cudf-pandas) is disabled in the DOM
766+
* 5. Assert the available option (cuml-accel) is not disabled
767767
*/
768768
it('should disable unavailable accelerators', async () => {
769769
// Create system info with one unavailable accelerator
@@ -787,7 +787,7 @@ describe('AcceleratorSelector Component', () => {
787787
unavailableInfo
788788
);
789789

790-
// Render component - it should check status of each plugin
790+
// Render component - it should check status and disable unavailable options
791791
render(
792792
<AcceleratorSelector
793793
sessionContext={mockSessionContext}
@@ -799,9 +799,20 @@ describe('AcceleratorSelector Component', () => {
799799
expect(screen.getByTestId('accelerator-select')).toBeInTheDocument();
800800
});
801801

802-
// Verify component checked plugin status (to determine which to disable)
803-
// The component should disable 'cudf-pandas' since it's unavailable
804-
expect(mockAcceleratorRegistry.getPluginStatus).toHaveBeenCalled();
802+
const select = screen.getByTestId('accelerator-select');
803+
const cudfOption = select.querySelector<HTMLOptionElement>(
804+
'option[value="cudf-pandas"]'
805+
);
806+
const cumlOption = select.querySelector<HTMLOptionElement>(
807+
'option[value="cuml-accel"]'
808+
);
809+
810+
expect(cudfOption).toBeTruthy();
811+
expect(cumlOption).toBeTruthy();
812+
// Unavailable accelerator must be disabled so users cannot select it
813+
expect(cudfOption).toBeDisabled();
814+
// Available accelerator must remain selectable
815+
expect(cumlOption).not.toBeDisabled();
805816
});
806817
});
807818
});

0 commit comments

Comments
 (0)