diff --git a/packages/compass-query-bar/src/components/query-bar/query-bar.jsx b/packages/compass-query-bar/src/components/query-bar/query-bar.jsx
index 5b3760793a0..5d16745e7b8 100644
--- a/packages/compass-query-bar/src/components/query-bar/query-bar.jsx
+++ b/packages/compass-query-bar/src/components/query-bar/query-bar.jsx
@@ -97,6 +97,14 @@ class QueryBar extends Component {
skipString: PropTypes.string,
limitString: PropTypes.string,
+ filterPlaceholder: PropTypes.string,
+ projectPlaceholder: PropTypes.string,
+ collationPlaceholder: PropTypes.string,
+ sortPlaceholder: PropTypes.string,
+ skipPlaceholder: PropTypes.string,
+ limitPlaceholder: PropTypes.string,
+ maxTimeMSPlaceholder: PropTypes.string,
+
actions: PropTypes.object,
buttonLabel: PropTypes.string,
queryState: PropTypes.string,
@@ -219,6 +227,8 @@ class QueryBar extends Component {
this.props[option] : this.props[`${option}String`];
const label = OPTION_DEFINITION[option].label || option;
+ const placeholder = this.props[`${option}Placeholder`] || OPTION_DEFINITION[option].placeholder;
+
return (
+ );
+
+ expect(component.find('div[data-test-id="query-bar-options-toggle"]')).to.exist;
+ component.find('div[data-test-id="query-bar-options-toggle"]').simulate('click');
+ expect(component.find('OptionEditor[label="filter"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('OptionEditor[label="project"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('OptionEditor[label="collation"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('OptionEditor[label="sort"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('QueryOption[label="Max Time MS"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('QueryOption[label="skip"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('QueryOption[label="limit"]').prop('placeholder')).to.not.be.empty;
+ });
+
+ it('the input fields placeholders can be modified', function() {
+ const component = mount(
+
+ );
+
+ expect(component.find('div[data-test-id="query-bar-options-toggle"]')).to.exist;
+ component.find('div[data-test-id="query-bar-options-toggle"]').simulate('click');
+ expect(component.find('OptionEditor[label="filter"]').prop('placeholder')).to.equal("{field: 'matchValue'}");
+ expect(component.find('OptionEditor[label="project"]').prop('placeholder')).to.equal('{field: 1}');
+ expect(component.find('OptionEditor[label="collation"]').prop('placeholder')).to.equal("{locale: 'fr' }");
+ expect(component.find('OptionEditor[label="sort"]').prop('placeholder')).to.equal('{field: 1}');
+ expect(component.find('QueryOption[label="Max Time MS"]').prop('placeholder')).to.equal('50000');
+ expect(component.find('QueryOption[label="skip"]').prop('placeholder')).to.equal('10');
+ expect(component.find('QueryOption[label="limit"]').prop('placeholder')).to.equal('20');
+ });
+ });
});
});
diff --git a/packages/compass-query-bar/src/plugin.spec.js b/packages/compass-query-bar/src/plugin.spec.js
index f8eafbd4513..06e8a0cfef1 100644
--- a/packages/compass-query-bar/src/plugin.spec.js
+++ b/packages/compass-query-bar/src/plugin.spec.js
@@ -172,4 +172,59 @@ describe('QueryBar [Plugin]', () => {
expect(component.find('#query-bar-menu-actions')).to.not.exist;
});
});
+
+ describe('a user is able to provide custom placeholders for the input fields', function() {
+ const layout = ['filter', 'project', ['sort', 'maxTimeMS'], ['collation', 'skip', 'limit']];
+
+
+ it('the input fields have a placeholder by default', function() {
+ component = mount(
+
+ );
+
+ expect(component.find('div[data-test-id="query-bar-options-toggle"]')).to.exist;
+ component.find('div[data-test-id="query-bar-options-toggle"]').simulate('click');
+ expect(component.find('OptionEditor[label="filter"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('OptionEditor[label="project"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('OptionEditor[label="collation"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('OptionEditor[label="sort"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('QueryOption[label="Max Time MS"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('QueryOption[label="skip"]').prop('placeholder')).to.not.be.empty;
+ expect(component.find('QueryOption[label="limit"]').prop('placeholder')).to.not.be.empty;
+ });
+
+ it('the input fields placeholders can be modified', function() {
+ component = mount(
+
+ );
+
+ expect(component.find('div[data-test-id="query-bar-options-toggle"]')).to.exist;
+ component.find('div[data-test-id="query-bar-options-toggle"]').simulate('click');
+ expect(component.find('OptionEditor[label="filter"]').prop('placeholder')).to.equal("{field: 'matchValue'}");
+ expect(component.find('OptionEditor[label="project"]').prop('placeholder')).to.equal('{field: 1}');
+ expect(component.find('OptionEditor[label="collation"]').prop('placeholder')).to.equal("{locale: 'fr' }");
+ expect(component.find('OptionEditor[label="sort"]').prop('placeholder')).to.equal('{field: 1}');
+ expect(component.find('QueryOption[label="Max Time MS"]').prop('placeholder')).to.equal('50000');
+ expect(component.find('QueryOption[label="skip"]').prop('placeholder')).to.equal('10');
+ expect(component.find('QueryOption[label="limit"]').prop('placeholder')).to.equal('20');
+ });
+ });
});