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