mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-01 19:25:56 +00:00
Updates the tests and autocomplete facets to origin string
This commit is contained in:
parent
424e7f79cb
commit
829a10ce09
@ -3,7 +3,8 @@ import {
|
||||
AutocompleteRuleNames,
|
||||
ISuggestionBuilder,
|
||||
IState,
|
||||
INodeFacetProcessor
|
||||
INodeFacetProcessor,
|
||||
ISuggestion
|
||||
} from 'wherehows-web/utils/parsers/autocomplete/types';
|
||||
import { dataToString } from 'wherehows-web/utils/parsers/autocomplete/utils';
|
||||
import { platform } from 'wherehows-web/utils/parsers/autocomplete/processors/facets/platform';
|
||||
@ -55,7 +56,7 @@ const getFacetValueFromStateRule = (state: IState): string => {
|
||||
*/
|
||||
export const facetNameProcessor: INodeFacetProcessor = {
|
||||
platform,
|
||||
dataorigin: fabric
|
||||
origin: fabric
|
||||
};
|
||||
|
||||
export const facetsProcessor: INodeProcessor = {
|
||||
@ -65,16 +66,20 @@ export const facetsProcessor: INodeProcessor = {
|
||||
[AutocompleteRuleNames.FacetName]: (builder: ISuggestionBuilder, ruleState: IState): Promise<ISuggestionBuilder> => {
|
||||
const allFields: Array<ISearchEntityRenderProps> = DataModelEntity[builder.entity].renderProps.search.attributes;
|
||||
const facetName = getFacetNameFromStateRule(ruleState);
|
||||
const fields = allFields.filter(field => field.fieldName.indexOf(facetName) >= 0 && field.showInAutoCompletion);
|
||||
const fields = allFields.filter(
|
||||
(field): boolean => field.fieldName.indexOf(facetName) >= 0 && field.showInAutoCompletion
|
||||
);
|
||||
return Promise.resolve({
|
||||
...builder,
|
||||
facetNames: [
|
||||
...builder.facetNames,
|
||||
...fields.map(field => ({
|
||||
title: `${field.fieldName}:`,
|
||||
text: `${builder.textPrevious}${field.fieldName}:`,
|
||||
description: `${field.desc}, e.g.: ${field.example}`
|
||||
}))
|
||||
...fields.map(
|
||||
(field): ISuggestion => ({
|
||||
title: `${field.fieldName}:`,
|
||||
text: `${builder.textPrevious}${field.fieldName}:`,
|
||||
description: `${field.desc}, e.g.: ${field.example}`
|
||||
})
|
||||
)
|
||||
]
|
||||
});
|
||||
},
|
||||
@ -106,10 +111,12 @@ export const facetsProcessor: INodeProcessor = {
|
||||
...builder,
|
||||
facetNames: [
|
||||
...builder.facetNames,
|
||||
...(suggestions || []).map(value => ({
|
||||
title: `${facetName}:${value}`,
|
||||
text: `${builder.textPrevious}${facetName}:${value} `
|
||||
}))
|
||||
...(suggestions || []).map(
|
||||
(value): ISuggestion => ({
|
||||
title: `${facetName}:${value}`,
|
||||
text: `${builder.textPrevious}${facetName}:${value} `
|
||||
})
|
||||
)
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
@ -55,9 +55,9 @@ module('Acceptance | search', function(hooks): void {
|
||||
|
||||
test('visiting /search and restoring facet selections', async function(assert): Promise<void> {
|
||||
await appLogin();
|
||||
await visit('/search?facets=(dataorigin%3AList(prod%2Ccorp))&keyword=car');
|
||||
await visit('/search?facets=(origin%3AList(prod%2Ccorp))&keyword=car');
|
||||
|
||||
assert.equal(currentURL(), '/search?facets=(dataorigin%3AList(prod%2Ccorp))&keyword=car');
|
||||
assert.equal(currentURL(), '/search?facets=(origin%3AList(prod%2Ccorp))&keyword=car');
|
||||
|
||||
const { prod, corp } = getCheckboxes(this);
|
||||
const searchBar = find(searchBarSelector) as HTMLInputElement;
|
||||
@ -68,7 +68,7 @@ module('Acceptance | search', function(hooks): void {
|
||||
|
||||
await click(getCheckboxSelector('corp'));
|
||||
|
||||
assert.equal(currentURL(), '/search?entity=datasets&facets=(dataorigin%3AList(prod))&keyword=car&page=1');
|
||||
assert.equal(currentURL(), '/search?entity=datasets&facets=(origin%3AList(prod))&keyword=car&page=1');
|
||||
});
|
||||
|
||||
test('visiting /search and getting no results', async function(assert): Promise<void> {
|
||||
|
||||
@ -24,7 +24,7 @@ module('Integration | Component | search/containers/search-facets', function(hoo
|
||||
setProperties(this, {
|
||||
fields: DatasetEntity.renderProps.search.attributes,
|
||||
counts: {
|
||||
dataorigin: {
|
||||
origin: {
|
||||
PROD: 1,
|
||||
CORP: 10
|
||||
}
|
||||
@ -52,8 +52,8 @@ module('Integration | Component | search/containers/search-facets', function(hoo
|
||||
getText(this)
|
||||
.replace(/\s/gi, '')
|
||||
.trim(),
|
||||
'dataorigin-2CORPPROD',
|
||||
'Should show just dataorigin but not platform and sorted'
|
||||
'origin-2CORPPROD',
|
||||
'Should show just origin but not platform and sorted'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -118,7 +118,7 @@ const tests = [
|
||||
},
|
||||
{
|
||||
description: 'Facets 2',
|
||||
text: ' (name:dataset1 AND platform:something) OR ( dataorigin:corp AND dataset4 )',
|
||||
text: ' (name:dataset1 AND platform:something) OR ( origin:corp AND dataset4 )',
|
||||
result: [
|
||||
[
|
||||
{
|
||||
@ -134,7 +134,7 @@ const tests = [
|
||||
'OR',
|
||||
[
|
||||
{
|
||||
facetName: 'dataorigin',
|
||||
facetName: 'origin',
|
||||
facetValue: 'corp'
|
||||
},
|
||||
'AND',
|
||||
|
||||
@ -40,9 +40,9 @@ const createTests = (server: IMirageWherehows): Array<ITestSet> => {
|
||||
groupName: 'Filter By',
|
||||
options: [
|
||||
{
|
||||
description: 'The data origin of the dataset, e.g.: dataorigin:PROD',
|
||||
text: 'dataorigin:',
|
||||
title: 'dataorigin:'
|
||||
description: 'The origin of the dataset, e.g.: origin:PROD',
|
||||
text: 'origin:',
|
||||
title: 'origin:'
|
||||
},
|
||||
{
|
||||
description: 'The name of the dataset, e.g.: name:TRACKING.PageViewEvent',
|
||||
@ -189,7 +189,7 @@ const createTests = (server: IMirageWherehows): Array<ITestSet> => {
|
||||
{
|
||||
entity: DatasetEntity.displayName,
|
||||
description: 'Dataset with filter fabric',
|
||||
text: 'dataorigin:co',
|
||||
text: 'origin:co',
|
||||
results: [
|
||||
{
|
||||
groupName: 'Filter By',
|
||||
@ -296,9 +296,9 @@ const createTests = (server: IMirageWherehows): Array<ITestSet> => {
|
||||
groupName: 'Filter By',
|
||||
options: [
|
||||
{
|
||||
description: 'The data origin of the dataset, e.g.: dataorigin:PROD',
|
||||
text: 'something dataorigin:',
|
||||
title: 'dataorigin:'
|
||||
description: 'The origin of the dataset, e.g.: origin:PROD',
|
||||
text: 'something origin:',
|
||||
title: 'origin:'
|
||||
},
|
||||
{
|
||||
description: 'The name of the dataset, e.g.: name:TRACKING.PageViewEvent',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user