Skip to content

Commit

Permalink
fix bug with traceId not showing in dropdown (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Bulicek authored and ashishagg committed Apr 23, 2019
1 parent 29bf3d0 commit c5dc496
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/components/universalSearch/searchBar/autosuggest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default class Autocomplete extends React.Component {
componentDidMount() {
this.props.options.serviceName = {isRangeQuery: false, values: this.props.serviceStore.services};
this.props.options.operationName = {isRangeQuery: false, values: []};
this.props.options.traceId = {isRangeQuery: false, values: []};

// Automatically checks for operations when a user supplies a new serviceName
when(() => this.props.serviceStore.services.length,
Expand Down
17 changes: 9 additions & 8 deletions test/src/components/universalSearch/universalSearch.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const stubHistory = {
const stubOptions = {
error: {values: ['true, false'], isRangeQuery: false},
serviceName: {values: ['test-a', 'test-b', 'test-c', 'whitespace test'], isRangeQuery: false},
operationName: {values: [], isRangeQuery: false}
operationName: {values: [], isRangeQuery: false},
traceId: {values: [], isRangeQuery: false}
};


Expand Down Expand Up @@ -300,7 +301,7 @@ describe('<Autosuggest />', () => {
expect(wrapper.instance().state.suggestionStrings.length).to.equal(0);
const input = wrapper.find('.usb-searchbar__input');
input.prop('onFocus')({target: {value: ''}});
expect(wrapper.instance().state.suggestionStrings.length).to.equal(3);
expect(wrapper.instance().state.suggestionStrings.length).to.equal(4);
});

it('update suggestion string index on suggestion mouseover', () => {
Expand All @@ -312,7 +313,7 @@ describe('<Autosuggest />', () => {
const firstSuggestion = wrapper.find('.usb-suggestions__field').last();
firstSuggestion.simulate('mouseEnter');

expect(wrapper.instance().state.suggestionIndex).to.equal(2);
expect(wrapper.instance().state.suggestionIndex).to.equal(3);
});

it('update suggestion string index on suggestion mouseover', () => {
Expand Down Expand Up @@ -375,7 +376,7 @@ describe('<Autosuggest />', () => {
expect(wrapper.instance().state.suggestedOnType).to.equal('Keys');

input.prop('onKeyDown')({keyCode: 38, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(2);
expect(wrapper.instance().state.suggestionIndex).to.equal(3);
expect(wrapper.instance().state.suggestedOnType).to.equal('Keys');

input.prop('onKeyDown')({keyCode: 13, preventDefault: () => {}});
Expand Down Expand Up @@ -429,16 +430,16 @@ describe('<Autosuggest />', () => {
const input = wrapper.find('.usb-searchbar__input');
input.prop('onFocus')({target: {value: ''}});
input.prop('onKeyDown')({keyCode: 38, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(2);
expect(wrapper.instance().state.suggestionIndex).to.equal(3);
input.prop('onKeyDown')({keyCode: 38, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(1);
expect(wrapper.instance().state.suggestionIndex).to.equal(2);
input.prop('onKeyDown')({keyCode: 38, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(0);
input.prop('onKeyDown')({keyCode: 40, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(1);
input.prop('onKeyDown')({keyCode: 40, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(2);
input.prop('onKeyDown')({keyCode: 40, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(3);
input.prop('onKeyDown')({keyCode: 40, preventDefault: () => {}});
expect(wrapper.instance().state.suggestionIndex).to.equal(0);
});

Expand Down

0 comments on commit c5dc496

Please sign in to comment.