mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 20:05:42 +03:00
Add check that active summary isn’t filtered out
This commit is contained in:
@@ -179,6 +179,20 @@ export default class OptimizeController extends Controller {
|
||||
@action
|
||||
setFacetQueryParam(queryParam, selection) {
|
||||
this[queryParam] = serialize(selection);
|
||||
this.ensureActiveSummaryIsNotExcluded();
|
||||
}
|
||||
|
||||
@action
|
||||
ensureActiveSummaryIsNotExcluded() {
|
||||
scheduleOnce('actions', () => {
|
||||
if (!this.filteredSummaries.includes(this.activeRecommendationSummary)) {
|
||||
const firstFilteredSummary = this.filteredSummaries.objectAt(0);
|
||||
|
||||
if (firstFilteredSummary) {
|
||||
this.transitionToSummary(firstFilteredSummary);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
{{#if @model}}
|
||||
<SearchBox
|
||||
data-test-recommendation-summaries-search
|
||||
@onChange={{this.ensureActiveSummaryIsNotExcluded}}
|
||||
@searchTerm={{mut this.searchTerm}}
|
||||
@placeholder="Search {{this.model.length}} {{pluralize "recommendation" this.model.length}}..." />
|
||||
{{/if}}
|
||||
|
||||
@@ -366,7 +366,18 @@ module('Acceptance | optimize search and facets', function(hooks) {
|
||||
window.localStorage.nomadTokenSecret = managementToken.secretId;
|
||||
});
|
||||
|
||||
test('search field narrows summary table results and displays a no matches message when there are none', async function(assert) {
|
||||
test('search field narrows summary table results, changes the active summary if it no longer matches, and displays a no matches message when there are none', async function(assert) {
|
||||
server.createList('job', 1, {
|
||||
name: 'zzzzzz',
|
||||
createRecommendations: true,
|
||||
groupsCount: 1,
|
||||
groupTaskCount: 6,
|
||||
});
|
||||
|
||||
// Ensure this job’s recommendations are sorted to the top of the table
|
||||
const futureSubmitTime = (Date.now() + 10000) * 1000000;
|
||||
server.db.recommendations.update({ submitTime: futureSubmitTime });
|
||||
|
||||
server.createList('job', 1, {
|
||||
name: 'oooooo',
|
||||
createRecommendations: true,
|
||||
@@ -383,6 +394,8 @@ module('Acceptance | optimize search and facets', function(hooks) {
|
||||
|
||||
await Optimize.visit();
|
||||
|
||||
assert.equal(Optimize.card.slug.jobName, 'zzzzzz');
|
||||
|
||||
assert.equal(Optimize.search.placeholder, `Search ${Optimize.recommendationSummaries.length} recommendations...`);
|
||||
|
||||
await Optimize.search.fillIn('ooo');
|
||||
@@ -390,6 +403,9 @@ module('Acceptance | optimize search and facets', function(hooks) {
|
||||
assert.equal(Optimize.recommendationSummaries.length, 2);
|
||||
assert.ok(Optimize.recommendationSummaries[0].slug.startsWith('oooooo'));
|
||||
|
||||
assert.equal(Optimize.card.slug.jobName, 'oooooo');
|
||||
assert.ok(currentURL().includes('oooooo'));
|
||||
|
||||
await Optimize.search.fillIn('qqq');
|
||||
|
||||
assert.notOk(Optimize.card.isPresent);
|
||||
|
||||
Reference in New Issue
Block a user