Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,32 @@ describe('Additional actions tests', () => {
});
});

test.each(
['semantic_view', 'table', 'query'].flatMap(type =>
[true, false].map(saved => ({ type, saved })),
),
)(
'Explore SQL Lab action respects datasource $type (saved=$saved)',
async ({ type, saved }) => {
const props = createProps(saved ? {} : { slice: null });
props.chart.latestQueryFormData = {
...props.chart.latestQueryFormData,
datasource: `49__${type}`,
slice_id: saved ? 318 : undefined,
};
render(<ExploreHeader {...props} />, { useRedux: true });
await userEvent.click(
await screen.findByLabelText('Menu actions trigger'),
);
expect(await screen.findByText('View query')).toBeInTheDocument();
if (type === 'semantic_view') {
expect(screen.queryByText('Run in SQL Lab')).not.toBeInTheDocument();
} else {
expect(screen.getByText('Run in SQL Lab')).toBeInTheDocument();
}
},
);

test('Should render a button', async () => {
const props = createProps();
render(<ExploreHeader {...props} />, { useRedux: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,3 +764,28 @@ test('should verify DatasourceControl callback fires on save', async () => {
// Note: Cross-component integration test removed due to complex Redux/user context setup
// The existing callback tests provide sufficient coverage for metric creation workflows
// Future enhancement could add MetricsControl integration when test infrastructure supports it

test.each(
['semantic_view', 'table', 'query'].flatMap(type =>
[true, false].map(saved => ({ type, saved })),
),
)(
'datasource SQL Lab action respects datasource $type (saved=$saved)',
async ({ type, saved }) => {
const props = createProps({
value: `25__${type}`,
datasource: { ...mockDatasource, type },
form_data: saved ? { slice_id: 318 } : {},
});
render(<DatasourceControl {...props} />, { useRouter: true });
await userEvent.click(await screen.findByTestId('datasource-menu-trigger'));
if (type !== 'query') {
expect(await screen.findByText('Swap dataset')).toBeInTheDocument();
}
if (type === 'semantic_view') {
expect(screen.queryByText('View in SQL Lab')).not.toBeInTheDocument();
} else {
expect(screen.getByText('View in SQL Lab')).toBeInTheDocument();
}
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ export default function DatasourceControl({
label: t('Swap %s', datasetLabelLower()),
});

if (!isMissingDatasource && canAccessSqlLab) {
if (
!isMissingDatasource &&
canAccessSqlLab &&
datasource.type !== DatasourceType.SemanticView
) {
defaultDatasourceMenuItems.push({
key: VIEW_IN_SQL_LAB,
label: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
JsonObject,
LatestQueryFormData,
QueryFormData,
DatasourceType,
Behavior,
getChartMetadataRegistry,
} from '@superset-ui/core';
Expand Down Expand Up @@ -1175,7 +1176,10 @@ export const useExploreAdditionalActionsMenu = (
});

// Run in SQL Lab
if (datasource) {
if (
datasource &&
!datasource.endsWith(`__${DatasourceType.SemanticView}`)
) {
menuItems.push({
key: MENU_KEYS.RUN_IN_SQL_LAB,
label: t('Run in SQL Lab'),
Expand Down
Loading