Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
within,
} from 'sentry-test/reactTestingLibrary';

import DashboardList from 'sentry/views/dashboards/manage/dashboardList';
import DashboardGrid from 'sentry/views/dashboards/manage/dashboardGrid';
import {type DashboardListItem, DisplayType} from 'sentry/views/dashboards/types';

describe('Dashboards - DashboardList', function () {
describe('Dashboards - DashboardGrid', function () {
let dashboards: DashboardListItem[];
let deleteMock: jest.Mock;
let dashboardUpdateMock: jest.Mock;
Expand Down Expand Up @@ -100,9 +100,9 @@ describe('Dashboards - DashboardList', function () {
dashboardUpdateMock = jest.fn();
});

it('renders an empty list', function () {
it('renders an empty list', async function () {
render(
<DashboardList
<DashboardGrid
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={[]}
Expand All @@ -113,11 +113,14 @@ describe('Dashboards - DashboardList', function () {
);

expect(screen.getByTestId('empty-state')).toBeInTheDocument();
expect(
await screen.findByText('Sorry, no Dashboards match your filters.')
).toBeInTheDocument();
});

it('renders dashboard list', function () {
render(
<DashboardList
<DashboardGrid
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
Expand All @@ -133,7 +136,7 @@ describe('Dashboards - DashboardList', function () {

it('returns landing page url for dashboards', function () {
render(
<DashboardList
<DashboardGrid
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
Expand All @@ -156,7 +159,7 @@ describe('Dashboards - DashboardList', function () {

it('persists global selection headers', function () {
render(
<DashboardList
<DashboardGrid
onDashboardsChange={jest.fn()}
organization={organization}
dashboards={dashboards}
Expand All @@ -175,7 +178,7 @@ describe('Dashboards - DashboardList', function () {

it('can delete dashboards', async function () {
render(
<DashboardList
<DashboardGrid
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {}}}
Expand Down Expand Up @@ -213,7 +216,7 @@ describe('Dashboards - DashboardList', function () {
}),
];
render(
<DashboardList
<DashboardGrid
organization={organization}
dashboards={singleDashboard}
location={LocationFixture()}
Expand All @@ -232,7 +235,7 @@ describe('Dashboards - DashboardList', function () {

it('can duplicate dashboards', async function () {
render(
<DashboardList
<DashboardGrid
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {}}}
Expand All @@ -259,7 +262,7 @@ describe('Dashboards - DashboardList', function () {
});

render(
<DashboardList
<DashboardGrid
organization={organization}
dashboards={dashboards}
location={{...LocationFixture(), query: {}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Props = {
isLoading?: boolean;
};

function DashboardList({
function DashboardGrid({
api,
organization,
location,
Expand Down Expand Up @@ -203,21 +203,25 @@ function DashboardList({
: dashboards?.length ?? 0;

return (
<DashboardGrid rows={rowCount} columns={columnCount}>
<DashboardGridContainer
rows={rowCount}
columns={columnCount}
data-test-id={'dashboard-grid'}
>
{renderMiniDashboards()}
{isLoading &&
rowCount * columnCount > numDashboards &&
new Array(rowCount * columnCount - numDashboards)
.fill(0)
.map((_, index) => <Placeholder key={index} height="270px" />)}
</DashboardGrid>
</DashboardGridContainer>
);
}

return <Fragment>{renderDashboardGrid()}</Fragment>;
}

const DashboardGrid = styled('div')<{columns: number; rows: number}>`
const DashboardGridContainer = styled('div')<{columns: number; rows: number}>`
display: grid;
grid-template-columns: repeat(
${props => props.columns},
Expand All @@ -231,4 +235,4 @@ const DropdownTrigger = styled(Button)`
transform: translateX(${space(1)});
`;

export default withApi(DashboardList);
export default withApi(DashboardGrid);
Loading
Loading