feat: filter by me on CRUD list view (#11683)

This commit is contained in:
Lily Kuang
2020-11-25 11:56:48 -08:00
committed by GitHub
parent c354e7e0ab
commit 9c69679e14
16 changed files with 135 additions and 12 deletions

View File

@@ -55,6 +55,10 @@ const mocklayers = [...new Array(3)].map((_, i) => ({
desc: 'layer description',
}));
const mockUser = {
userId: 1,
};
fetchMock.get(layersInfoEndpoint, {
permissions: ['can_delete'],
});
@@ -74,7 +78,9 @@ fetchMock.get(layersRelatedEndpoint, {
});
describe('AnnotationLayersList', () => {
const wrapper = mount(<AnnotationLayersList />, { context: { store } });
const wrapper = mount(<AnnotationLayersList user={mockUser} />, {
context: { store },
});
beforeAll(async () => {
await waitForComponentToPaint(wrapper);

View File

@@ -36,9 +36,11 @@ const store = mockStore({});
const chartsInfoEndpoint = 'glob:*/api/v1/chart/_info*';
const chartssOwnersEndpoint = 'glob:*/api/v1/chart/related/owners*';
const chartsCreatedByEndpoint = 'glob:*/api/v1/chart/related/created_by*';
const chartsEndpoint = 'glob:*/api/v1/chart/?*';
const chartsVizTypesEndpoint = 'glob:*/api/v1/chart/viz_types';
const chartsDtasourcesEndpoint = 'glob:*/api/v1/chart/datasources';
const chartsDatasourcesEndpoint = 'glob:*/api/v1/chart/datasources';
const chartFavoriteStatusEndpoint = 'glob:*/api/v1/chart/favorite_status*';
const mockCharts = [...new Array(3)].map((_, i) => ({
changed_on: new Date().toISOString(),
@@ -51,6 +53,10 @@ const mockCharts = [...new Array(3)].map((_, i) => ({
thumbnail_url: '/thumbnail',
}));
const mockUser = {
userId: 1,
};
fetchMock.get(chartsInfoEndpoint, {
permissions: ['can_list', 'can_edit', 'can_delete'],
});
@@ -58,6 +64,12 @@ fetchMock.get(chartsInfoEndpoint, {
fetchMock.get(chartssOwnersEndpoint, {
result: [],
});
fetchMock.get(chartsCreatedByEndpoint, {
result: [],
});
fetchMock.get(chartFavoriteStatusEndpoint, {
result: [],
});
fetchMock.get(chartsEndpoint, {
result: mockCharts,
chart_count: 3,
@@ -68,7 +80,7 @@ fetchMock.get(chartsVizTypesEndpoint, {
count: 0,
});
fetchMock.get(chartsDtasourcesEndpoint, {
fetchMock.get(chartsDatasourcesEndpoint, {
result: [],
count: 0,
});
@@ -85,7 +97,7 @@ describe('ChartList', () => {
isFeatureEnabledMock.restore();
});
const mockedProps = {};
const wrapper = mount(<ChartList {...mockedProps} />, {
const wrapper = mount(<ChartList {...mockedProps} user={mockUser} />, {
context: { store },
});

View File

@@ -53,6 +53,10 @@ const mocktemplates = [...new Array(3)].map((_, i) => ({
template_name: `template ${i}`,
}));
const mockUser = {
userId: 1,
};
fetchMock.get(templatesInfoEndpoint, {
permissions: ['can_delete'],
});
@@ -72,7 +76,9 @@ fetchMock.get(templatesRelatedEndpoint, {
});
describe('CssTemplatesList', () => {
const wrapper = mount(<CssTemplatesList />, { context: { store } });
const wrapper = mount(<CssTemplatesList user={mockUser} />, {
context: { store },
});
beforeAll(async () => {
await waitForComponentToPaint(wrapper);

View File

@@ -37,6 +37,10 @@ const store = mockStore({});
const dashboardsInfoEndpoint = 'glob:*/api/v1/dashboard/_info*';
const dashboardOwnersEndpoint = 'glob:*/api/v1/dashboard/related/owners*';
const dashboardCreatedByEndpoint =
'glob:*/api/v1/dashboard/related/created_by*';
const dashboardFavoriteStatusEndpoint =
'glob:*/api/v1/dashboard/favorite_status*';
const dashboardsEndpoint = 'glob:*/api/v1/dashboard/?*';
const mockDashboards = [...new Array(3)].map((_, i) => ({
@@ -53,12 +57,23 @@ const mockDashboards = [...new Array(3)].map((_, i) => ({
thumbnail_url: '/thumbnail',
}));
const mockUser = {
userId: 1,
};
fetchMock.get(dashboardsInfoEndpoint, {
permissions: ['can_list', 'can_edit', 'can_delete'],
});
fetchMock.get(dashboardOwnersEndpoint, {
result: [],
});
fetchMock.get(dashboardCreatedByEndpoint, {
result: [],
});
fetchMock.get(dashboardFavoriteStatusEndpoint, {
result: [],
});
fetchMock.get(dashboardsEndpoint, {
result: mockDashboards,
dashboard_count: 3,
@@ -77,7 +92,7 @@ describe('DashboardList', () => {
});
const mockedProps = {};
const wrapper = mount(<DashboardList {...mockedProps} />, {
const wrapper = mount(<DashboardList {...mockedProps} user={mockUser} />, {
context: { store },
});

View File

@@ -56,6 +56,10 @@ const mockdatabases = [...new Array(3)].map((_, i) => ({
id: i,
}));
const mockUser = {
userId: 1,
};
fetchMock.get(databasesInfoEndpoint, {
permissions: ['can_delete'],
});
@@ -77,7 +81,9 @@ fetchMock.get(databaseRelatedEndpoint, {
});
describe('DatabaseList', () => {
const wrapper = mount(<DatabaseList />, { context: { store } });
const wrapper = mount(<DatabaseList user={mockUser} />, {
context: { store },
});
beforeAll(async () => {
await waitForComponentToPaint(wrapper);

View File

@@ -52,6 +52,10 @@ const mockdatasets = [...new Array(3)].map((_, i) => ({
table_name: `coolest table ${i}`,
}));
const mockUser = {
userId: 1,
};
fetchMock.get(datasetsInfoEndpoint, {
permissions: ['can_list', 'can_edit', 'can_add', 'can_delete'],
});
@@ -70,7 +74,7 @@ fetchMock.get(databaseEndpoint, {
});
async function mountAndWait(props) {
const mounted = mount(<DatasetList {...props} />, {
const mounted = mount(<DatasetList {...props} user={mockUser} />, {
context: { store },
});
await waitForComponentToPaint(mounted);

View File

@@ -91,7 +91,9 @@ fetchMock.get(queriesDistinctEndpoint, {
});
describe('SavedQueryList', () => {
const wrapper = mount(<SavedQueryList />, { context: { store } });
const wrapper = mount(<SavedQueryList />, {
context: { store },
});
beforeAll(async () => {
await waitForComponentToPaint(wrapper);