import { uniq } from 'lodash' ; /**
 * Possible statuses for tests.
 */ export type Status = 'queued' | 'running' | 'passed' | 'failed' | 'incomplete' | 'skipped' | 'warning' | 'partial' | 'empty' | 'idle' | 'error' ; /**
 * Possible statuses for frameworks.
 */ export type FrameworkStatus = Status | 'refreshing' | 'loading' | 'missing' ; /**
 * A ledger of statuses.
 */ export type StatusLedger = { [ key in Status ] : number ; } ; /**
 * A map of ids and their statuses.
 */ export type StatusMap = { [ key ] : Status ; } ; /**
 * Labels for each status
 */ export const labels = { empty : 'Empty' , error : 'Error' , failed : 'Failed' , idle : 'Idle' , incomplete : 'Incomplete' , loading : 'Loading' , missing : 'Missing' , partial : 'Partial' , passed : 'Passed' , queued : 'Queued' , refreshing : 'Refreshing' , running : 'Running' , skipped : 'Skipped' , stopped : 'Stopped' , warning : 'Warning' } ; param components export function parseStatus ( components ) { if ( ! components . length || components . every ( component => component === 'empty' ) ) { return 'empty' ; } components = components . filter ( component => component !== 'empty' ) ; components = uniq ( components ) ; if ( components . length === 1 ) { return components [ 0 ] ; } if ( components . includes ( 'queued' ) || components . includes ( 'running' ) ) { return 'running' ; } if ( components . includes ( 'error' ) ) { return 'error' ; } if ( components . includes ( 'failed' ) ) { return 'failed' ; } if ( components . includes ( 'warning' ) ) { return 'warning' ; } if ( components . includes ( 'incomplete' ) && ! components . includes ( 'idle' ) ) { return 'incomplete' ; } if ( components . includes ( 'skipped' ) && ! components . includes ( 'idle' ) ) { return 'incomplete' ; } return 'partial' ; } param components export function parseFrameworkStatus ( components ) { if ( ! components . length || components . every ( component => component === 'empty' ) ) { return 'empty' ; } components = uniq ( components ) ; if ( components . length === 1 ) { return components [ 0 ] ; } if ( components . includes ( 'loading' ) ) { return 'loading' ; } if ( components . includes ( 'refreshing' ) ) { return 'refreshing' ; } if ( components . includes ( 'missing' ) ) { return 'error' ; } return parseStatus ( components as Array < Status > ) ; }