Skip to content

Commit

Permalink
update tests for embedded mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sadpandajoe authored Nov 8, 2024
1 parent 094f081 commit 56e34ee
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions superset-frontend/src/dashboard/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,28 +374,47 @@ test('should render an extension component if one is supplied', () => {
).toBeInTheDocument();
});

test('should render metadata when !isEmbedded is true', () => {
test('should NOT render MetadataBar when in edit mode', () => {
const mockedProps = {
...createProps(),
editMode: true,
dashboardInfo: {
...createProps().dashboardInfo,
userId: undefined,
userId: '123',
},
};
setup(mockedProps);
expect(
screen.getByText(getOwnerName(mockedProps.dashboardInfo.created_by)),
).toBeInTheDocument();
expect(
screen.getByText(mockedProps.dashboardInfo.changed_on_delta_humanized),
).toBeInTheDocument();
screen.queryByText(mockedProps.dashboardInfo.changed_on_delta_humanized),
).not.toBeInTheDocument();
});

test('should NOT render MetadataBar when embedded', () => {
const mockedProps = createProps();
const mockedProps = {
...createProps(),
editMode: false,
dashboardInfo: {
...createProps().dashboardInfo,
userId: undefined,
},
};
setup(mockedProps);

expect(
screen.queryByText(mockedProps.dashboardInfo.changed_on_delta_humanized),
).not.toBeInTheDocument();
});

test('should render MetadataBar when not in edit mode and not embedded', () => {
const mockedProps = {
...createProps(),
editMode: false,
dashboardInfo: {
...createProps().dashboardInfo,
userId: '123',
},
};
setup(mockedProps);
expect(
screen.getByText(mockedProps.dashboardInfo.changed_on_delta_humanized),
).toBeInTheDocument();
});

0 comments on commit 56e34ee

Please # to comment.