Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar committed Sep 2, 2022
1 parent 37c65be commit 35f792b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
19 changes: 9 additions & 10 deletions superset-frontend/src/views/CRUD/chart/ChartList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import InfoTooltip from 'src/components/InfoTooltip';
import CertifiedBadge from 'src/components/CertifiedBadge';
import { GenericLink } from 'src/components/GenericLink/GenericLink';
import { bootstrapData } from 'src/preamble';
import Owner from 'src/types/Owner';
import ChartCard from './ChartCard';

const FlexRowContainer = styled.div`
Expand Down Expand Up @@ -223,6 +224,12 @@ function ChartList(props: ChartListProps) {
});
setPreparingExport(true);
};
const changedByName = (lastSavedBy: Owner) => {
// eslint-disable-next-line no-unused-expressions
return lastSavedBy?.first_name
? `${lastSavedBy?.first_name} ${lastSavedBy?.last_name}`
: null;
};

function handleBulkChartDelete(chartsToDelete: Chart[]) {
SupersetClient.delete({
Expand Down Expand Up @@ -329,17 +336,9 @@ function ChartList(props: ChartListProps) {
},
}: any) =>
enableBroadUserAccess ? (
<a href={changedByUrl}>
{lastSavedBy?.first_name
? `${lastSavedBy?.first_name} ${lastSavedBy?.last_name}`
: null}
</a>
<a href={changedByUrl}>{changedByName(lastSavedBy)}</a>
) : (
<>
{lastSavedBy?.first_name
? `${lastSavedBy?.first_name} ${lastSavedBy?.last_name}`
: null}
</>
<>{changedByName(lastSavedBy)}</>
),
Header: t('Modified by'),
accessor: 'last_saved_by.first_name',
Expand Down
12 changes: 12 additions & 0 deletions tests/integration_tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,18 @@ def test_user_profile(self, username="admin"):
data = self.get_json_resp(endpoint)
self.assertNotIn("message", data)

def test_user_profile_optional_access(self):
self.login(username="gamma")
resp = self.client.get(f"/superset/profile/admin/")
self.assertEqual(resp.status_code, 200)

app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = False
resp = self.client.get(f"/superset/profile/admin/")
self.assertEqual(resp.status_code, 403)

# Restore config
app.config["ENABLE_BROAD_ACTIVITY_ACCESS"] = True

@pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
def test_user_activity_access(self, username="gamma"):
self.login(username=username)
Expand Down

0 comments on commit 35f792b

Please sign in to comment.