chore(D2D): Add granular permission for dashboard drilling operations (#28435)

This commit is contained in:
Vitor Avila
2024-05-15 11:31:30 -03:00
committed by GitHub
parent 11164e2450
commit 6232aac95a
5 changed files with 142 additions and 10 deletions

View File

@@ -302,7 +302,7 @@ test('Drill to detail modal is under featureflag', () => {
expect(screen.queryByText('Drill to detail')).not.toBeInTheDocument();
});
test('Should show "Drill to detail"', () => {
test('Should show "Drill to detail" with `can_explore` & `can_samples` perms', () => {
(global as any).featureFlags = {
[FeatureFlag.DrillToDetail]: true,
};
@@ -317,7 +317,43 @@ test('Should show "Drill to detail"', () => {
expect(screen.getByText('Drill to detail')).toBeInTheDocument();
});
test('Should not show "Drill to detail"', () => {
test('Should show "Drill to detail" with `can_drill` & `can_samples` perms', () => {
(global as any).featureFlags = {
[FeatureFlag.DrillToDetail]: true,
};
const props = {
...createProps(),
supersetCanExplore: false,
};
props.slice.slice_id = 18;
renderWrapper(props, {
Admin: [
['can_samples', 'Datasource'],
['can_drill', 'Dashboard'],
],
});
expect(screen.getByText('Drill to detail')).toBeInTheDocument();
});
test('Should show "Drill to detail" with both `canexplore` + `can_drill` & `can_samples` perms', () => {
(global as any).featureFlags = {
[FeatureFlag.DrillToDetail]: true,
};
const props = {
...createProps(),
supersetCanExplore: true,
};
props.slice.slice_id = 18;
renderWrapper(props, {
Admin: [
['can_samples', 'Datasource'],
['can_drill', 'Dashboard'],
],
});
expect(screen.getByText('Drill to detail')).toBeInTheDocument();
});
test('Should not show "Drill to detail" with neither of required perms', () => {
(global as any).featureFlags = {
[FeatureFlag.DrillToDetail]: true,
};
@@ -332,6 +368,21 @@ test('Should not show "Drill to detail"', () => {
expect(screen.queryByText('Drill to detail')).not.toBeInTheDocument();
});
test('Should not show "Drill to detail" only `can_dril` perm', () => {
(global as any).featureFlags = {
[FeatureFlag.DrillToDetail]: true,
};
const props = {
...createProps(),
supersetCanExplore: false,
};
props.slice.slice_id = 18;
renderWrapper(props, {
Admin: [['can_drill', 'Dashboard']],
});
expect(screen.queryByText('Drill to detail')).not.toBeInTheDocument();
});
test('Should show "View query"', () => {
const props = {
...createProps(),