Skip to content

Commit

Permalink
Update tests and components after antd bump
Browse files Browse the repository at this point in the history
Signed-off-by: Máté Szabó <mszabo@fandom.com>
  • Loading branch information
mszabo-wikia committed Mar 9, 2023
1 parent a47e9d1 commit 25a3431
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 26 deletions.
4 changes: 2 additions & 2 deletions packages/jaeger-ui/src/components/App/Page.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ describe('<Page>', () => {
trackPageView.mockReset();
props = {
pathname: String(Math.random()),
search: 'embed=v0&hideGraph',
search: 'hideGraph',
};
wrapper = mount(<Page {...props} />);
wrapper = mount(<Page embedded {...props} />);
});

it('does not explode', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/components/App/TopNav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('<TopNav>', () => {

it('renders sub-menu links', () => {
dropdownItems.slice(1, 2).forEach(itemConfig => {
const item = subMenu.find(`[href="${itemConfig.url}"]`);
const item = subMenu.dive().find(`[href="${itemConfig.url}"]`);
expect(item.length).toBe(1);
expect(item.prop('target')).toBe(itemConfig.anchorTarget || '_blank');
expect(item.text()).toBe(itemConfig.label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Upload, Icon } from 'antd';
const Dragger = Upload.Dragger;

type FileLoaderProps = {
loadJsonTraces: (fileList: FileList) => void;
loadJsonTraces: (fileList: { file: File }) => void;
};

export default function FileLoader(props: FileLoaderProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('AltViewOptions', () => {

let wrapper;
const getLink = text => {
const menu = shallow(wrapper.find(Dropdown).prop('overlay'));
const menu = shallow(wrapper.find(Dropdown).prop('overlay')).dive();
const links = menu.find(Link);
for (let i = 0; i < links.length; i++) {
const link = links.at(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default class KeyboardShortcutsHelp extends React.PureComponent<Props, St
<span className="KeyboardShortcutsHelp--cta"></span>
</Button>
<Modal
align={undefined}
title="Keyboard Shortcuts"
visible={this.state.visible}
onOk={this.onCloserClicked}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ describe('<TraceSpanView>', () => {
});

it('does not explode', () => {
const st = wrapper.find('.span-view-table');
expect(wrapper).toBeDefined();
expect(wrapper.find('.title--TraceSpanView').length).toBe(1);
expect(wrapper.find('.span-view-table').length).toBe(2);
expect(wrapper.find('.span-view-table').length).toBe(3);
expect(wrapper.find('table').length).toBe(1);
expect(wrapper.find('colgroup').length).toBe(1);
expect(wrapper.find('Pagination').length).toBe(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe(ReferencesButton, () => {
const wrapper = shallow(<ReferencesButton {...props} />);
const dropdown = wrapper.find(Dropdown);
expect(dropdown.length).toBe(1);
const menuInstance = shallow(dropdown.first().props().overlay);
const menuInstance = shallow(dropdown.first().props().overlay).dive();
const submenuItems = menuInstance.find(Menu.Item);
expect(submenuItems.length).toBe(3);
submenuItems.forEach((submenuItem, i) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('<KeyValuesTable>', () => {
: [],
});
const dropdown = wrapper.find(Dropdown);
const menu = shallow(dropdown.prop('overlay'));
const menu = shallow(dropdown.prop('overlay')).dive();
const anchors = menu.find(LinkValue);
expect(anchors).toHaveLength(2);
const firstAnchor = anchors.first();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,21 @@ describe('DetailTable', () => {
describe('_onCell', () => {
const onCell = makeTestFn(_onCell);

it('returns null for undefined', () => {
expect(onCell(undefined)).toBe(null);
it('returns empty props for undefined', () => {
expect(onCell(undefined)).toEqual({});
});

it('returns null for string', () => {
expect(onCell('test-string')).toBe(null);
it('returns empty props for string', () => {
expect(onCell('test-string')).toEqual({});
});

it('returns null for array', () => {
expect(onCell([])).toBe(null);
it('returns empty props for array', () => {
expect(onCell([])).toEqual({});
});

it('returns null for unstyled object', () => {
expect(onCell({})).toBe(null);
expect(onCell({ styling: {} })).toBe(null);
it('returns empty props for unstyled object', () => {
expect(onCell({})).toEqual({});
expect(onCell({ styling: {} })).toEqual({});
});

it('returns styling for styled object', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const _makeFilterDropdown =
// exported for tests
export const _onCell = (dataIndex: string) => (row: TRow) => {
const cellData = row[dataIndex];
if (!cellData || typeof cellData !== 'object' || Array.isArray(cellData)) return null;
if (!cellData || typeof cellData !== 'object' || Array.isArray(cellData)) return {};
const { styling } = cellData;
if (_isEmpty(styling)) return null;
if (_isEmpty(styling)) return {};
return {
style: styling,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('<ExternalLinks>', () => {
const wrapper = shallow(<ExternalLinks links={links} />);
const dropdown = wrapper.find(Dropdown);
expect(dropdown.length).toBe(1);
const linkValues = shallow(dropdown.first().props().overlay);
const linkValues = shallow(dropdown.first().props().overlay).dive();
const submenuItems = linkValues.find(Menu.Item);
expect(submenuItems.length).toBe(links.length);
submenuItems.forEach((subMenu, i) => {
Expand Down
15 changes: 10 additions & 5 deletions packages/jaeger-ui/src/components/common/NameSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ export default class NameSelector extends React.PureComponent<TProps, TState> {
}

private changeVisible(popoverVisible: boolean) {
if (popoverVisible) {
window.document.body.addEventListener('click', this.onBodyClicked);
} else {
window.document.body.removeEventListener('click', this.onBodyClicked);
}
this.setState({ popoverVisible });

// Defer registering a click handler to hide the selector popover
// to avoid handling the click event that triggered opening the popover itself.
setTimeout(() => {
if (popoverVisible) {
window.document.body.addEventListener('click', this.onBodyClicked);
} else {
window.document.body.removeEventListener('click', this.onBodyClicked);
}
});
}

private clearValue = (evt: React.MouseEvent<HTMLElement>) => {
Expand Down

0 comments on commit 25a3431

Please sign in to comment.