@cccsaurora/howler-ui 2.19.0-dev.1308 → 2.19.0-dev.1316

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -179,7 +179,7 @@ const RecordContextMenu = ({ children, getSelectedId, Component }) => {
179
179
  items: actions.map(action => ({
180
180
  key: action.action_id,
181
181
  label: action.name,
182
- onClick: () => executeAction(action.action_id, `howler.id:${record?.howler.id}`)
182
+ onClick: () => executeAction(action.action_id, `howler.id:(${records.map(r => r.howler.id).join(' OR ')})`)
183
183
  }))
184
184
  });
185
185
  if (!isEmpty(template?.keys ?? []) && setQuery) {
@@ -137,8 +137,12 @@ describe('HitContextMenu', () => {
137
137
  beforeEach(() => {
138
138
  user = userEvent.setup();
139
139
  vi.clearAllMocks();
140
+ // Reset context to clean state
140
141
  mockRecordContext.selectedRecords.length = 0;
141
- mockRecordContext.records['test-hit-1'] = createMockHit();
142
+ mockRecordContext.records = {
143
+ 'test-hit-1': createMockHit()
144
+ };
145
+ mockGetSelectedId.mockReturnValue('test-hit-1');
142
146
  mockGetMatchingAnalytic.mockResolvedValue(createMockAnalytic());
143
147
  mockGetMatchingTemplate.mockResolvedValue(createMockTemplate());
144
148
  rerender = render(_jsx(Wrapper, { children: _jsx(RecordContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) })).rerender;
@@ -461,7 +465,7 @@ describe('HitContextMenu', () => {
461
465
  expect(mockExecuteAction).toHaveBeenCalled();
462
466
  });
463
467
  });
464
- it('should call executeAction with action_id and hit query', async () => {
468
+ it('should call executeAction with action_id and hit query for a single hit', async () => {
465
469
  const mockActions = [createMockAction({ action_id: 'action-1', name: 'Custom Action' })];
466
470
  mockDispatchApi.mockResolvedValue({ items: mockActions });
467
471
  rerender(_jsx(Wrapper, { children: _jsx(RecordContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) }));
@@ -485,7 +489,42 @@ describe('HitContextMenu', () => {
485
489
  await user.click(customActionOption);
486
490
  });
487
491
  await waitFor(() => {
488
- expect(mockExecuteAction).toHaveBeenCalledWith('action-1', 'howler.id:test-hit-1');
492
+ expect(mockExecuteAction).toHaveBeenCalledWith('action-1', 'howler.id:(test-hit-1)');
493
+ });
494
+ });
495
+ it('should call executeAction with combined hit query when multiple hits are selected', async () => {
496
+ const mockActions = [createMockAction({ action_id: 'action-1', name: 'Custom Action' })];
497
+ mockDispatchApi.mockResolvedValue({ items: mockActions });
498
+ const hit1 = createMockHit({ howler: { id: 'hit-1' } });
499
+ const hit2 = createMockHit({ howler: { id: 'hit-2' } });
500
+ const hit3 = createMockHit({ howler: { id: 'hit-3' } });
501
+ mockRecordContext.records['hit-1'] = hit1;
502
+ mockRecordContext.records['hit-2'] = hit2;
503
+ mockRecordContext.records['hit-3'] = hit3;
504
+ mockRecordContext.selectedRecords = [hit1, hit2, hit3];
505
+ mockGetSelectedId.mockReturnValue('hit-1');
506
+ rerender(_jsx(Wrapper, { children: _jsx(RecordContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) }));
507
+ act(() => {
508
+ const contextMenuWrapper = screen.getByText('Test Content').parentElement;
509
+ fireEvent.contextMenu(contextMenuWrapper);
510
+ });
511
+ let actionsMenuItem;
512
+ await waitFor(() => {
513
+ actionsMenuItem = screen.getByText('Run Action');
514
+ expect(actionsMenuItem).toBeInTheDocument();
515
+ });
516
+ act(() => {
517
+ fireEvent.mouseEnter(actionsMenuItem);
518
+ });
519
+ await waitFor(() => {
520
+ expect(screen.getByTestId('actions-submenu')).toBeInTheDocument();
521
+ });
522
+ await act(async () => {
523
+ const customActionOption = screen.getByText('Custom Action');
524
+ await user.click(customActionOption);
525
+ });
526
+ await waitFor(() => {
527
+ expect(mockExecuteAction).toHaveBeenCalledWith('action-1', 'howler.id:(hit-1 OR hit-2 OR hit-3)');
489
528
  });
490
529
  });
491
530
  it('should close menu after action execution', async () => {
package/package.json CHANGED
@@ -93,7 +93,7 @@
93
93
  "url": "https://github.com/CybercentreCanada/howler"
94
94
  },
95
95
  "type": "module",
96
- "version": "2.19.0-dev.1308",
96
+ "version": "2.19.0-dev.1316",
97
97
  "exports": {
98
98
  "./i18n": "./i18n.js",
99
99
  "./index.css": "./index.css",