-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
463 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
import {parseQuery} from './query-params'; | ||
import {pick, has} from 'lodash'; | ||
|
||
const allowedViewModes = new Set(['all', 'failed']); | ||
|
||
export function getViewQuery(queryString) { | ||
const query = parseQuery(queryString, {browser: 'filteredBrowsers'}); | ||
|
||
if (typeof query.filteredBrowsers === 'string') { | ||
query.filteredBrowsers = [query.filteredBrowsers]; | ||
} | ||
|
||
if (has(query, 'viewMode') && !allowedViewModes.has(query.viewMode)) { | ||
query.viewMode = 'all'; | ||
} | ||
|
||
return pick(query, [ | ||
'filteredBrowsers', | ||
'testNameFilter', | ||
'retryIndex', | ||
'viewMode', | ||
'expand', | ||
'groupByError' | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
'use strict'; | ||
|
||
import qs from 'qs'; | ||
import {assign} from 'lodash'; | ||
|
||
export function parseQuery(queryString, rename = {}) { | ||
if (!queryString || typeof queryString !== 'string') { | ||
return {}; | ||
} | ||
|
||
if (queryString[0] === '?') { | ||
queryString = queryString.slice(1); | ||
} | ||
|
||
return qs.parse(queryString, { | ||
decoder: (str, defaultDecoder, charset, type) => { | ||
if (type === 'key') { | ||
const key = defaultDecoder(str, null, charset); | ||
return rename[key] ? rename[key] : key; | ||
} | ||
|
||
const value = defaultDecoder(str, null, charset); | ||
|
||
if (value === 'true') { | ||
return true; | ||
} | ||
|
||
if (value === 'false') { | ||
return false; | ||
} | ||
|
||
if (value && !isNaN(value)) { | ||
return Number(value); | ||
} | ||
|
||
return value; | ||
}} | ||
); | ||
} | ||
|
||
export function appendQuery(url, query) { | ||
const resultUrl = new URL(url); | ||
|
||
const urlQuery = resultUrl.search || ''; | ||
|
||
const resultQuery = assign( | ||
qs.parse(urlQuery.slice(1)), | ||
query | ||
); | ||
|
||
resultUrl.search = qs.stringify(resultQuery, {arrayFormat: 'repeat'}); | ||
|
||
return resultUrl.href; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.