Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display search results as cards #2055

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
59 changes: 50 additions & 9 deletions cypress/e2e/immutableDatabaseTests/searchTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ describe('Dockstore tool/workflow search table', () => {
_id: '52',
_score: 1.0,
_source: {
entryTypeMetadata: {
termPlural: 'tools',
sitePath: 'containers',
trsSupported: true,
trsPrefix: '',
term: 'tool',
searchSupported: true,
type: 'TOOL',
searchEntryType: 'tools',
},
tool_maintainer_email: '',
aliases: {},
default_dockerfile_path: '/Dockerfile',
Expand Down Expand Up @@ -102,6 +112,16 @@ describe('Dockstore tool/workflow search table', () => {
_id: '5',
_score: 1.0,
_source: {
entryTypeMetadata: {
termPlural: 'tools',
sitePath: 'containers',
trsSupported: true,
trsPrefix: '',
term: 'tool',
searchSupported: true,
type: 'TOOL',
searchEntryType: 'tools',
},
tool_maintainer_email: '',
aliases: {},
default_dockerfile_path: '/Dockerfile',
Expand Down Expand Up @@ -190,6 +210,16 @@ describe('Dockstore tool/workflow search table', () => {
_id: '4',
_score: 1.0,
_source: {
entryTypeMetadata: {
termPlural: 'tools',
sitePath: 'containers',
trsSupported: true,
trsPrefix: '',
term: 'tool',
searchSupported: true,
type: 'TOOL',
searchEntryType: 'tools',
},
tool_maintainer_email: '',
aliases: {},
default_dockerfile_path: '/Dockerfile',
Expand Down Expand Up @@ -278,6 +308,16 @@ describe('Dockstore tool/workflow search table', () => {
_id: '11',
_score: 1.0,
_source: {
entryTypeMetadata: {
termPlural: 'workflows',
sitePath: 'workflows',
trsSupported: true,
trsPrefix: '#workflow/',
term: 'workflow',
searchSupported: true,
type: 'WORKFLOW',
searchEntryType: 'workflows',
},
aliases: {},
is_published: true,
last_modified_date: null,
Expand Down Expand Up @@ -338,7 +378,7 @@ describe('Dockstore tool/workflow search table', () => {
if (type === 'workflow') {
goToTab('Workflows');
}
cy.get('.mat-icon.star-icon').should('not.exist');
cy.get('[data-cy=starredUsers]').should('not.exist');
// cy.visit(url);
// cy.get('#starringButton')
// .click();
Expand All @@ -354,7 +394,7 @@ describe('Dockstore tool/workflow search table', () => {
if (type === 'workflow') {
goToTab('Workflows');
}
cy.get('.mat-icon.star-icon').should('exist');
cy.get('[data-cy=starredUsers]').should('exist');
// cy.visit(url);
// cy.get('#starringButton')
// .click();
Expand Down Expand Up @@ -382,11 +422,15 @@ describe('search table items per page', () => {

it('tool items per page', () => {
cy.visit('/search');
cy.get('#mat-select-0 ').click();
cy.get('#mat-option-1 ').click();
// Modify the number of items per page
cy.get('[data-cy=search-entry-table-paginator]').contains(10).should('be.visible').click();
cy.get('mat-option').contains(20).click();
cy.get('[data-cy=search-entry-table-paginator]').contains(20);
// Click an entry then go back to the search page
cy.contains('A/l').click();
cy.get('.flex-toolbar ').contains(' Search ').click();
cy.get('.mat-select-value-text ').contains('20');
cy.get('a').contains('Search').click();
// The number of items should remain the same
cy.get('[data-cy=search-entry-table-paginator]').contains(20);
});

it('tool items per page after advanced search', () => {
Expand Down Expand Up @@ -454,9 +498,6 @@ describe('check search table and tabs for notebooks', () => {
// Select notebooks tab
goToTab('Notebooks');
cy.url().should('contain', 'notebooks');
// Check that the notebooks variations are in the table header
cy.get('.mat-header-cell').contains('Language');
cy.get('.mat-header-cell').contains('Format');
// Check that the notebooks variations are in the table body
cy.get('.mat-cell').contains('jupyter', { matchCase: false });
cy.get('.mat-cell').contains('python', { matchCase: false });
Expand Down
32 changes: 9 additions & 23 deletions cypress/e2e/smokeTests/sharedTests/basic-enduser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ describe('run stochastic smoke test', () => {
function testEntry(tab: string) {
function goToRandomEntry() {
cy.visit('/search');
cy.get('[data-cy=workflowColumn] a');
cy.get('[data-cy=entryColumn] a');
goToTab(tab);
const linkName = getLinkName(tab);
// select a random entry on the first page and navigate to it
let chosen_index = 0;
cy.get('[data-cy=' + linkName + ']')
cy.get('[data-cy=entryColumn]')
.then(($list) => {
chosen_index = Math.floor(Math.random() * $list.length);
})
Expand Down Expand Up @@ -55,19 +54,6 @@ function testEntry(tab: string) {
});
}

function getLinkName(tab: string): string {
switch (tab) {
case 'Tools':
return 'toolNames';
case 'Workflows':
return 'workflowColumn';
case 'Notebooks':
return 'notebookColumn';
default:
throw new Error('unknown tab');
}
}

function isStagingOrProd() {
const baseUrl = Cypress.config('baseUrl');
return baseUrl === 'https://staging.dockstore.org' || baseUrl === 'https://dockstore.org';
Expand Down Expand Up @@ -104,7 +90,7 @@ describe('Test logged out home page', () => {
describe('Test search page functionality', () => {
it('displays tools', () => {
cy.visit('/search');
cy.get('[data-cy=workflowColumn]').should('have.length.of.at.least', 1);
cy.get('[data-cy=entryColumn]').should('have.length.of.at.least', 1);
});
it('has working tag cloud', () => {
cy.visit('/search');
Expand All @@ -123,7 +109,7 @@ describe('Test search page functionality', () => {
cy.visit('/search');
cy.wait(2500); // Wait less than ideal, facets keep getting rerendered is the problem
cy.contains('mat-checkbox', 'Nextflow').click();
cy.get('[data-cy=workflowColumn] a');
cy.get('[data-cy=entryColumn] a');
cy.wait(2500); // Wait less than ideal, facets keep getting rerendered is the problem
cy.contains('mat-checkbox', 'Nextflow'); // wait for the checkbox to reappear, indicating the filtering is almost complete
cy.get('[data-cy=descriptorType]').each(($el, index, $list) => {
Expand All @@ -139,7 +125,7 @@ describe('Test search page functionality', () => {
cy.visit('/search');
cy.contains('mat-checkbox', /^[ ]*verified/).click();
cy.url().should('contain', 'verified=1');
cy.get('[data-cy=workflowColumn] a');
cy.get('[data-cy=entryColumn] a');
cy.contains('mat-checkbox', /^[ ]*verified/);
});
});
Expand All @@ -148,11 +134,11 @@ describe('Test workflow page functionality', () => {
it('find a WDL workflow', () => {
cy.visit('/search');
cy.contains('.mat-tab-label', 'Workflows');
cy.get('[data-cy=workflowColumn]').should('have.length.of.at.least', 1);
cy.get('[data-cy=entryColumn]').should('have.length.of.at.least', 1);

// click twice to sort by descriptor type descending so WDL is at the top
cy.get('[data-cy=descriptorTypeHeader]').click().click();
cy.get('[data-cy=workflowColumn] a').first().click();
// Use facet to find WDL workflow
cy.contains('mat-checkbox', 'WDL').click();
cy.get('[data-cy=entryColumn] a').first().click();
});
});

Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/smokeTests/sharedTests/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ describe('Admin UI', () => {
cy.url().should('not.include', 'search=dhockstore');

cy.contains('Items per page');
cy.get('[data-cy=search-workflow-table-paginator]').within(() => {
cy.get('[data-cy=search-entry-table-paginator]').within(() => {
cy.get('.mat-paginator-range-label').contains('10 of');
});
cy.get('[data-cy=search-workflow-table-paginator]').contains(10).should('be.visible').click();
cy.get('[data-cy=search-entry-table-paginator]').contains(10).should('be.visible').click();
cy.get('mat-option').contains(20).click();
cy.get('[data-cy=search-workflow-table-paginator]').contains(20);
cy.get('[data-cy=search-entry-table-paginator]').contains(20);
cy.get('a').contains('Organizations').click();
cy.go('back');
cy.get('[data-cy=search-workflow-table-paginator]').contains(20);
cy.get('[data-cy=search-entry-table-paginator]').contains(20);

cy.get('[data-cy=basic-search]').type('dockstore_{enter}');
cy.contains('Open Advanced Search').click();
Expand Down
50 changes: 50 additions & 0 deletions cypress/fixtures/searchTableResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
"_id": "52",
"_score": 1.0,
"_source": {
"entryTypeMetadata": {
"termPlural": "tools",
"sitePath": "containers",
"trsSupported": true,
"trsPrefix": "",
"term": "tool",
"searchSupported": true,
"type": "TOOL",
"searchEntryType": "tools"
},
"tool_maintainer_email": "",
"aliases": {},
"default_dockerfile_path": "/Dockerfile",
Expand Down Expand Up @@ -89,6 +99,16 @@
"_id": "5",
"_score": 1.0,
"_source": {
"entryTypeMetadata": {
"termPlural": "tools",
"sitePath": "containers",
"trsSupported": true,
"trsPrefix": "",
"term": "tool",
"searchSupported": true,
"type": "TOOL",
"searchEntryType": "tools"
},
"tool_maintainer_email": "",
"aliases": {},
"default_dockerfile_path": "/Dockerfile",
Expand Down Expand Up @@ -179,6 +199,16 @@
"_id": "4",
"_score": 1.0,
"_source": {
"entryTypeMetadata": {
"termPlural": "tools",
"sitePath": "containers",
"trsSupported": true,
"trsPrefix": "",
"term": "tool",
"searchSupported": true,
"type": "TOOL",
"searchEntryType": "tools"
},
"tool_maintainer_email": "",
"aliases": {},
"default_dockerfile_path": "/Dockerfile",
Expand Down Expand Up @@ -270,6 +300,16 @@
"_id": "11",
"_score": 1.0,
"_source": {
"entryTypeMetadata": {
"termPlural": "workflows",
"sitePath": "workflows",
"trsSupported": true,
"trsPrefix": "#workflow/",
"term": "workflow",
"searchSupported": true,
"type": "WORKFLOW",
"searchEntryType": "workflows"
},
"aliases": {},
"is_published": true,
"last_modified_date": null,
Expand Down Expand Up @@ -333,6 +373,16 @@
"_id": "61",
"_score": 1.0,
"_source": {
"entryTypeMetadata": {
"termPlural": "notebooks",
"sitePath": "notebooks",
"trsSupported": true,
"trsPrefix": "#notebook/",
"term": "notebook",
"searchSupported": true,
"type": "NOTEBOOK",
"searchEntryType": "notebooks"
},
"aliases": {},
"is_published": true,
"last_modified_date": null,
Expand Down
4 changes: 2 additions & 2 deletions src/app/organizations/collection/collection.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ <h5>
</span>
</div>
</div>
<div class="truncate-text-2">
<app-ai-bubble *ngIf="entry.topicSelection === TopicSelectionEnum.AI && !entry.isApprovedAITopic"></app-ai-bubble>
<div>
<span class="size-small" [matTooltip]="entry.topic" matTooltipPosition="left">
{{ entry.topic }}
</span>
<app-ai-bubble *ngIf="entry.topicSelection === TopicSelectionEnum.AI && !entry.isApprovedAITopic"></app-ai-bubble>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the cards in the collection so they match the search cards more, i.e. the AI bubble is after the topic instead of before.

</div>
<hr />
<div fxLayout="row" fxLayoutAlign="space-between center">
Expand Down
5 changes: 3 additions & 2 deletions src/app/search/query-builder.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SearchStubService } from './../test/service-stubs';
import { inject, TestBed } from '@angular/core/testing';
import { QueryBuilderService } from './query-builder.service';
import { SearchService } from './state/search.service';
import { EntryType } from 'app/shared/openapi';

describe('Service: QueryBuilder', () => {
beforeEach(() => {
Expand All @@ -32,7 +33,7 @@ describe('Service: QueryBuilder', () => {
expect(service).toBeTruthy();
}));
it('should exclude terms from tagcloud query', inject([QueryBuilderService], (service: QueryBuilderService) => {
expect(service.getTagCloudQuery('tool')).toContain('significant_text');
expect(service.getTagCloudQuery('tool')).toContain('exclude');
expect(service.getTagCloudQuery(EntryType.TOOL)).toContain('significant_text');
expect(service.getTagCloudQuery(EntryType.TOOL)).toContain('exclude');
}));
});
9 changes: 7 additions & 2 deletions src/app/search/query-builder.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { tagCloudCommonTerms } from './../shared/constants';
import { AdvancedSearchObject } from './../shared/models/AdvancedSearchObject';
import { SearchService } from './state/search.service';
import { parseTerms } from './helpers';
import { EntryType } from 'app/shared/openapi';

type Index = 'workflows' | 'tools' | 'notebooks';

Expand All @@ -37,9 +38,9 @@ export class QueryBuilderService {
private shard_size = 10000;
constructor(private searchService: SearchService) {}

getTagCloudQuery(type: string): string {
getTagCloudQuery(type: EntryType): string {
const tagCloudSize = 20;
const index = type + 's';
const index = type.toLowerCase() + 's';
// Size to 0 here because https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html#agg-caches
let body = bodybuilder().size(0);
body = this.excludeContent(body);
Expand Down Expand Up @@ -80,16 +81,20 @@ export class QueryBuilderService {
return body.rawOption('_source', [
'all_authors',
'approvedAITopic',
'categories',
'descriptorType',
'descriptorTypeSubclass',
'entryTypeMetadata',
'full_workflow_path',
'gitUrl',
'last_modified_date',
'name',
'namespace',
'organization',
'private_access',
'providerUrl',
'repository',
'selected_concept_doi',
'starredUsers',
'toolname',
'tool_path',
Expand Down
Loading
Loading