2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2021-12-28 19:30:38 +00:00
|
|
|
/* eslint-disable ember-a11y-testing/a11y-audit-called */
|
|
|
|
/* eslint-disable qunit/require-expect */
|
2020-06-19 18:05:28 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { currentURL, triggerEvent, visit } from '@ember/test-helpers';
|
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
|
|
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
2020-12-10 17:51:22 +00:00
|
|
|
import Layout from 'nomad-ui/tests/pages/layout';
|
2020-06-19 18:05:28 +00:00
|
|
|
import JobsList from 'nomad-ui/tests/pages/jobs/list';
|
|
|
|
import { selectSearch } from 'ember-power-select/test-support';
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
import Response from 'ember-cli-mirage/response';
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
module('Acceptance | search', function (hooks) {
|
2020-06-19 18:05:28 +00:00
|
|
|
setupApplicationTest(hooks);
|
|
|
|
setupMirage(hooks);
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('search exposes and navigates to results from the fuzzy search endpoint', async function (assert) {
|
2020-06-19 18:05:28 +00:00
|
|
|
server.create('node', { name: 'xyz' });
|
2020-11-04 18:12:31 +00:00
|
|
|
const otherNode = server.create('node', { name: 'ghi' });
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2023-01-26 21:03:07 +00:00
|
|
|
server.create('namespace');
|
|
|
|
server.create('namespace', { id: 'dev' });
|
|
|
|
|
2021-07-26 21:23:21 +00:00
|
|
|
server.create('job', {
|
|
|
|
id: 'vwxyz',
|
|
|
|
namespaceId: 'default',
|
|
|
|
groupsCount: 1,
|
|
|
|
groupTaskCount: 1,
|
|
|
|
});
|
|
|
|
server.create('job', {
|
|
|
|
id: 'xyz',
|
|
|
|
name: 'xyz job',
|
|
|
|
namespaceId: 'default',
|
|
|
|
groupsCount: 1,
|
|
|
|
groupTaskCount: 1,
|
|
|
|
});
|
2023-01-26 21:03:07 +00:00
|
|
|
server.create('job', {
|
|
|
|
id: 'xyzw',
|
|
|
|
name: 'xyzw job',
|
|
|
|
namespaceId: 'dev',
|
|
|
|
groupsCount: 1,
|
|
|
|
groupTaskCount: 1,
|
|
|
|
});
|
2021-12-28 16:08:12 +00:00
|
|
|
server.create('job', {
|
|
|
|
id: 'abc',
|
|
|
|
namespaceId: 'default',
|
|
|
|
groupsCount: 1,
|
|
|
|
groupTaskCount: 1,
|
|
|
|
});
|
2020-06-19 18:05:28 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
const firstAllocation = server.schema.allocations.all().models[0];
|
|
|
|
const firstTaskGroup = server.schema.taskGroups.all().models[0];
|
2023-01-26 21:03:07 +00:00
|
|
|
const namespacedTaskGroup = server.schema.taskGroups.all().models[2];
|
2020-06-19 18:05:28 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
server.create('csi-plugin', { id: 'xyz-plugin', createVolumes: false });
|
2020-06-19 18:05:28 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await visit('/');
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, 'xy');
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
Layout.navbar.search.as((search) => {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.equal(search.groups.length, 5);
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
search.groups[0].as((jobs) => {
|
2023-01-26 21:03:07 +00:00
|
|
|
assert.equal(jobs.name, 'Jobs (3)');
|
|
|
|
assert.equal(jobs.options.length, 3);
|
2021-08-09 21:50:49 +00:00
|
|
|
assert.equal(jobs.options[0].text, 'default > vwxyz');
|
|
|
|
assert.equal(jobs.options[1].text, 'default > xyz job');
|
2023-01-26 21:03:07 +00:00
|
|
|
assert.equal(jobs.options[2].text, 'dev > xyzw job');
|
2020-06-19 18:05:28 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
search.groups[1].as((clients) => {
|
2020-06-19 18:05:28 +00:00
|
|
|
assert.equal(clients.name, 'Clients (1)');
|
|
|
|
assert.equal(clients.options.length, 1);
|
|
|
|
assert.equal(clients.options[0].text, 'xyz');
|
|
|
|
});
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
search.groups[2].as((allocs) => {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.equal(allocs.name, 'Allocations (0)');
|
|
|
|
assert.equal(allocs.options.length, 0);
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
search.groups[3].as((groups) => {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.equal(groups.name, 'Task Groups (0)');
|
|
|
|
assert.equal(groups.options.length, 0);
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
search.groups[4].as((plugins) => {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.equal(plugins.name, 'CSI Plugins (1)');
|
|
|
|
assert.equal(plugins.options.length, 1);
|
|
|
|
assert.equal(plugins.options[0].text, 'xyz-plugin');
|
|
|
|
});
|
2020-06-19 18:05:28 +00:00
|
|
|
});
|
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await Layout.navbar.search.groups[0].options[1].click();
|
2023-01-26 21:03:07 +00:00
|
|
|
assert.equal(currentURL(), '/jobs/xyz@default');
|
|
|
|
|
|
|
|
await selectSearch(Layout.navbar.search.scope, 'xy');
|
|
|
|
await Layout.navbar.search.groups[0].options[2].click();
|
|
|
|
assert.equal(currentURL(), '/jobs/xyzw@dev');
|
2020-06-19 18:05:28 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, otherNode.name);
|
2020-12-10 17:51:22 +00:00
|
|
|
await Layout.navbar.search.groups[1].options[0].click();
|
2020-06-19 18:05:28 +00:00
|
|
|
assert.equal(currentURL(), `/clients/${otherNode.id}`);
|
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, firstAllocation.name);
|
2021-07-26 21:23:21 +00:00
|
|
|
assert.equal(
|
|
|
|
Layout.navbar.search.groups[2].options[0].text,
|
2021-08-09 21:50:49 +00:00
|
|
|
`${firstAllocation.namespace} > ${firstAllocation.name}`
|
2021-07-26 21:23:21 +00:00
|
|
|
);
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await Layout.navbar.search.groups[2].options[0].click();
|
|
|
|
assert.equal(currentURL(), `/allocations/${firstAllocation.id}`);
|
2020-06-19 18:05:28 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, firstTaskGroup.name);
|
2021-08-09 21:50:49 +00:00
|
|
|
assert.equal(
|
|
|
|
Layout.navbar.search.groups[3].options[0].text,
|
|
|
|
`default > vwxyz > ${firstTaskGroup.name}`
|
|
|
|
);
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await Layout.navbar.search.groups[3].options[0].click();
|
2023-01-26 21:03:07 +00:00
|
|
|
assert.equal(currentURL(), `/jobs/vwxyz@default/${firstTaskGroup.name}`);
|
|
|
|
|
|
|
|
await selectSearch(Layout.navbar.search.scope, namespacedTaskGroup.name);
|
|
|
|
assert.equal(
|
|
|
|
Layout.navbar.search.groups[3].options[0].text,
|
|
|
|
`dev > xyzw > ${namespacedTaskGroup.name}`
|
|
|
|
);
|
|
|
|
await Layout.navbar.search.groups[3].options[0].click();
|
|
|
|
assert.equal(currentURL(), `/jobs/xyzw@dev/${namespacedTaskGroup.name}`);
|
2020-06-19 18:05:28 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, 'xy');
|
|
|
|
await Layout.navbar.search.groups[4].options[0].click();
|
|
|
|
assert.equal(currentURL(), '/csi/plugins/xyz-plugin');
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2021-12-28 16:08:12 +00:00
|
|
|
const fuzzySearchQueries = server.pretender.handledRequests.filterBy(
|
|
|
|
'url',
|
|
|
|
'/v1/search/fuzzy'
|
|
|
|
);
|
2021-05-27 18:45:34 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
const featureDetectionQueries = fuzzySearchQueries.filter((request) =>
|
2021-07-26 21:23:21 +00:00
|
|
|
request.requestBody.includes('feature-detection-query')
|
|
|
|
);
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2021-12-28 19:30:38 +00:00
|
|
|
assert.equal(
|
2021-07-26 21:23:21 +00:00
|
|
|
featureDetectionQueries.length,
|
|
|
|
1,
|
|
|
|
'expect the feature detection query to only run once'
|
|
|
|
);
|
2021-05-27 18:45:34 +00:00
|
|
|
|
|
|
|
const realFuzzySearchQuery = fuzzySearchQueries[1];
|
|
|
|
|
|
|
|
assert.deepEqual(JSON.parse(realFuzzySearchQuery.requestBody), {
|
2021-07-26 21:23:21 +00:00
|
|
|
Context: 'all',
|
|
|
|
Namespace: '*',
|
|
|
|
Text: 'xy',
|
2021-05-27 18:45:34 +00:00
|
|
|
});
|
2020-06-19 18:05:28 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('search does not perform a request when only one character has been entered', async function (assert) {
|
2020-06-25 13:51:52 +00:00
|
|
|
await visit('/');
|
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, 'q');
|
2020-06-25 13:51:52 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.ok(Layout.navbar.search.noOptionsShown);
|
2021-07-26 21:23:21 +00:00
|
|
|
assert.equal(
|
2021-12-28 16:08:12 +00:00
|
|
|
server.pretender.handledRequests.filterBy('url', '/v1/search/fuzzy')
|
|
|
|
.length,
|
2021-07-26 21:23:21 +00:00
|
|
|
1,
|
|
|
|
'expect the feature detection query'
|
|
|
|
);
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
});
|
2020-06-25 13:51:52 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('when fuzzy search is disabled on the server, the search control is hidden', async function (assert) {
|
|
|
|
server.post('/search/fuzzy', function () {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
return new Response(500, {}, '');
|
2020-06-25 20:26:52 +00:00
|
|
|
});
|
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await visit('/');
|
2020-06-25 20:26:52 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.ok(Layout.navbar.search.isHidden);
|
2020-06-25 13:51:52 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('results are truncated at 10 per group', async function (assert) {
|
2020-08-05 20:58:44 +00:00
|
|
|
server.create('node', { name: 'xyz' });
|
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
for (let i = 0; i < 11; i++) {
|
2020-08-05 20:58:44 +00:00
|
|
|
server.create('job', { id: `job-${i}`, namespaceId: 'default' });
|
|
|
|
}
|
|
|
|
|
|
|
|
await visit('/');
|
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, 'job');
|
2020-08-05 20:58:44 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
Layout.navbar.search.as((search) => {
|
|
|
|
search.groups[0].as((jobs) => {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.equal(jobs.name, 'Jobs (showing 10 of 11)');
|
2020-08-05 20:58:44 +00:00
|
|
|
assert.equal(jobs.options.length, 10);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('server-side truncation is indicated in the group label', async function (assert) {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
server.create('node', { name: 'xyz' });
|
2020-11-04 18:12:31 +00:00
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
for (let i = 0; i < 21; i++) {
|
|
|
|
server.create('job', { id: `job-${i}`, namespaceId: 'default' });
|
|
|
|
}
|
2020-11-04 18:12:31 +00:00
|
|
|
|
|
|
|
await visit('/');
|
|
|
|
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
await selectSearch(Layout.navbar.search.scope, 'job');
|
2020-11-04 18:12:31 +00:00
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
Layout.navbar.search.as((search) => {
|
|
|
|
search.groups[0].as((jobs) => {
|
ui: Change global search to use fuzzy search API (#10412)
This updates the UI to use the new fuzzy search API. It’s a drop-in
replacement so the / shortcut to jump to search is preserved, and
results can be cycled through and chosen via arrow keys and the
enter key.
It doesn’t use everything returned by the API:
* deployments and evaluations: these match by id, doesn’t seem like
people would know those or benefit from quick navigation to them
* namespaces: doesn’t seem useful as they currently function
* scaling policies
* tasks: the response doesn’t include an allocation id, which means they
can’t be navigated to in the UI without an additional query
* CSI volumes: aren’t actually returned by the API
Since there’s no API to check the server configuration and know whether
the feature has been disabled, this adds another query in
route:application#beforeModel that acts as feature detection: if the
attempt to query fails (500), the global search field is hidden.
Upon having added another query on load, I realised that beforeModel was
being triggered any time service:router#transitionTo was being called,
which happens upon navigating to a search result, for instance, because
of refreshModel being present on the region query parameter. This PR
adds a check for transition.queryParamsOnly and skips rerunning the
onload queries (token permissions check, license check, fuzzy search
feature detection).
Implementation notes:
* there are changes to unrelated tests to ignore the on-load feature
detection query
* some lifecycle-related guards against undefined were required to
address failures when navigating to an allocation
* the minimum search length of 2 characters is hard-coded as there’s
currently no way to determine min_term_length in the UI
2021-04-28 18:31:05 +00:00
|
|
|
assert.equal(jobs.name, 'Jobs (showing 10 of 20+)');
|
2020-11-04 18:12:31 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('clicking the search field starts search immediately', async function (assert) {
|
2020-06-19 18:05:28 +00:00
|
|
|
await visit('/');
|
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
assert.notOk(Layout.navbar.search.field.isPresent);
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
await Layout.navbar.search.click();
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
assert.ok(Layout.navbar.search.field.isPresent);
|
2020-06-19 18:05:28 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('pressing slash starts a search', async function (assert) {
|
2020-06-19 18:05:28 +00:00
|
|
|
await visit('/');
|
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
assert.notOk(Layout.navbar.search.field.isPresent);
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2021-06-07 14:34:20 +00:00
|
|
|
await triggerEvent('.page-layout', 'keydown', { key: '/' });
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
assert.ok(Layout.navbar.search.field.isPresent);
|
2020-06-19 18:05:28 +00:00
|
|
|
});
|
|
|
|
|
2021-12-28 14:45:20 +00:00
|
|
|
test('pressing slash when an input element is focused does not start a search', async function (assert) {
|
2020-06-19 18:05:28 +00:00
|
|
|
server.create('node');
|
|
|
|
server.create('job');
|
|
|
|
|
|
|
|
await visit('/');
|
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
assert.notOk(Layout.navbar.search.field.isPresent);
|
2020-06-19 18:05:28 +00:00
|
|
|
|
|
|
|
await JobsList.search.click();
|
2021-06-07 14:34:20 +00:00
|
|
|
await JobsList.search.keydown({ key: '/' });
|
2020-06-19 18:05:28 +00:00
|
|
|
|
2020-12-10 17:51:22 +00:00
|
|
|
assert.notOk(Layout.navbar.search.field.isPresent);
|
2020-06-19 18:05:28 +00:00
|
|
|
});
|
|
|
|
});
|