aminghadersohi commented on code in PR #44258:
URL: https://github.com/apache/superset/pull/44258#discussion_r4020256580


##########
superset-frontend/src/features/versionHistory/SaveGroupItem.test.tsx:
##########
@@ -129,3 +135,78 @@ test('rows of the highlighted group show the active 
timeline dot', () => {
   expandGroup(historical);
   expect(dotBorderColor(current)).not.toBe(dotBorderColor(historical));
 });
+
+const creationGroup = (overrides: Partial<SaveGroup> = {}): SaveGroup =>
+  makeGroup({
+    transactionId: 5,
+    versionUuid: 'v-created',
+    issuedAt: '2025-12-05T17:18:00',
+    changedBy: { id: 1, first_name: 'Ada', last_name: 'Lovelace' },
+    creationKind: 'created',
+    ...overrides,
+  });
+
+test('a chart starting group exposes an explicit preview action', async () => {
+  const onPreview = jest.fn();
+  const group = creationGroup();
+  renderItem({ group, onPreview });
+
+  const button = screen.getByRole('button', { name: 'Preview this version' });
+  await userEvent.click(button);
+
+  expect(onPreview).toHaveBeenCalledWith(group);
+});
+
+test('a dashboard starting group exposes the same preview action via 
keyboard', async () => {
+  const onPreview = jest.fn();
+  const group = creationGroup({ creationKind: 'pre_tracking' });
+  renderItem({ group, onPreview, entityType: 'dashboard' });
+
+  const button = screen.getByRole('button', { name: 'Preview this version' });
+  button.focus();
+  await userEvent.type(button, '{enter}', { skipClick: true });
+
+  expect(onPreview).toHaveBeenCalledWith(group);
+});
+
+test('the current starting version has nothing to preview', () => {
+  renderItem({ group: creationGroup(), isCurrent: true });
+
+  expect(
+    screen.queryByRole('button', { name: 'Preview this version' }),
+  ).not.toBeInTheDocument();
+});
+
+test('ordinary record-bearing groups do not grow the creation affordance', () 
=> {
+  renderItem({
+    group: creationGroup({
+      creationKind: undefined,
+      records: [
+        {
+          version_uuid: 'v-1',
+          entity_kind: 'chart',
+          entity_uuid: 'e-1',
+          entity_name: 'My chart',
+          entity_deleted: false,
+          entity_deletion_state: null,
+          source: 'self',
+          transaction_id: 5,
+          action_kind: null,
+          issued_at: '2025-12-05T17:18:00',
+          changed_by: null,
+          kind: 'metric',
+          operation: 'add',
+          path: ['params'],
+          from_value: null,
+          to_value: null,
+          summary: '',
+          impact: null,
+        },
+      ],
+    }),
+  });
+
+  expect(
+    screen.queryByRole('button', { name: 'Preview this version' }),
+  ).not.toBeInTheDocument();
+});

Review Comment:
   Superseding my earlier fence here: the #44181 merge replaced 
`renderItem(group)` with `renderItem({ group })`, so that suggestion no longer 
type-checks. This one varies only `creationKind` (records stay empty), so it 
pins that conjunct on its own — which the case above cannot.
   ```suggestion
   });
   
   test('an empty group with no creationKind gets no preview affordance', () => 
{
     renderItem({ group: creationGroup({ creationKind: undefined }) });
   
     expect(
       screen.queryByRole('button', { name: 'Preview this version' }),
     ).not.toBeInTheDocument();
   });
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to