Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-15 15:10:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-15 15:10:11 +0300
commit96acc69fae1ee7d559ba7eaa4e8304c8261525e3 (patch)
treeb1ed433da35a415cab8ed544d85ac4c939efab0e /spec/frontend/runner
parenta1498861799d1695682d72870580a6c3fb5ca3cf (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/runner')
-rw-r--r--spec/frontend/runner/runner_list/runner_search_utils_spec.js (renamed from spec/frontend/runner/runner_list/filtered_search_utils_spec.js)84
1 files changed, 80 insertions, 4 deletions
diff --git a/spec/frontend/runner/runner_list/filtered_search_utils_spec.js b/spec/frontend/runner/runner_list/runner_search_utils_spec.js
index abbe05452d1..a1f33e9c880 100644
--- a/spec/frontend/runner/runner_list/filtered_search_utils_spec.js
+++ b/spec/frontend/runner/runner_list/runner_search_utils_spec.js
@@ -3,7 +3,7 @@ import {
fromUrlQueryToSearch,
fromSearchToUrl,
fromSearchToVariables,
-} from '~/runner/runner_list/filtered_search_utils';
+} from '~/runner/runner_list/runner_search_utils';
describe('search_params.js', () => {
const examples = [
@@ -24,6 +24,40 @@ describe('search_params.js', () => {
graphqlVariables: { status: 'ACTIVE', sort: 'CREATED_DESC', first: RUNNER_PAGE_SIZE },
},
{
+ name: 'a single term text search',
+ urlQuery: '?search=something',
+ search: {
+ filters: [
+ {
+ type: 'filtered-search-term',
+ value: { data: 'something' },
+ },
+ ],
+ pagination: { page: 1 },
+ sort: 'CREATED_DESC',
+ },
+ graphqlVariables: { search: 'something', sort: 'CREATED_DESC', first: RUNNER_PAGE_SIZE },
+ },
+ {
+ name: 'a two terms text search',
+ urlQuery: '?search=something+else',
+ search: {
+ filters: [
+ {
+ type: 'filtered-search-term',
+ value: { data: 'something' },
+ },
+ {
+ type: 'filtered-search-term',
+ value: { data: 'else' },
+ },
+ ],
+ pagination: { page: 1 },
+ sort: 'CREATED_DESC',
+ },
+ graphqlVariables: { search: 'something else', sort: 'CREATED_DESC', first: RUNNER_PAGE_SIZE },
+ },
+ {
name: 'single instance type',
urlQuery: '?runner_type[]=INSTANCE_TYPE',
search: {
@@ -110,6 +144,13 @@ describe('search_params.js', () => {
});
});
+ it('When search params appear as array, they are concatenated', () => {
+ expect(fromUrlQueryToSearch('?search[]=my&search[]=text').filters).toEqual([
+ { type: 'filtered-search-term', value: { data: 'my' } },
+ { type: 'filtered-search-term', value: { data: 'text' } },
+ ]);
+ });
+
it('When a page cannot be parsed as a number, it defaults to `1`', () => {
expect(fromUrlQueryToSearch('?page=NONSENSE&after=AFTER_CURSOR').pagination).toEqual({
page: 1,
@@ -136,12 +177,15 @@ describe('search_params.js', () => {
});
});
- it('When a filtered search parameter is already present, it gets removed', () => {
- const initialUrl = `http://test.host/?status[]=ACTIVE`;
+ it.each([
+ 'http://test.host/?status[]=ACTIVE',
+ 'http://test.host/?runner_type[]=INSTANCE_TYPE',
+ 'http://test.host/?search=my_text',
+ ])('When a filter is removed, it is removed from the URL', (initalUrl) => {
const search = { filters: [], sort: 'CREATED_DESC' };
const expectedUrl = `http://test.host/`;
- expect(fromSearchToUrl(search, initialUrl)).toEqual(expectedUrl);
+ expect(fromSearchToUrl(search, initalUrl)).toEqual(expectedUrl);
});
it('When unrelated search parameter is present, it does not get removed', () => {
@@ -159,5 +203,37 @@ describe('search_params.js', () => {
expect(fromSearchToVariables(search)).toEqual(graphqlVariables);
});
});
+
+ it('When a search param is empty, it gets removed', () => {
+ expect(
+ fromSearchToVariables({
+ filters: [
+ {
+ type: 'filtered-search-term',
+ value: { data: '' },
+ },
+ ],
+ }),
+ ).toMatchObject({
+ search: '',
+ });
+
+ expect(
+ fromSearchToVariables({
+ filters: [
+ {
+ type: 'filtered-search-term',
+ value: { data: 'something' },
+ },
+ {
+ type: 'filtered-search-term',
+ value: { data: '' },
+ },
+ ],
+ }),
+ ).toMatchObject({
+ search: 'something',
+ });
+ });
});
});