File tree Expand file tree Collapse file tree 4 files changed +31
-11
lines changed
test/unit/lib/static/modules/reducers Expand file tree Collapse file tree 4 files changed +31
-11
lines changed Original file line number Diff line number Diff line change 11import actionNames from '../action-names' ;
2+ import { State } from '@/static/new-ui/types/store' ;
3+ import { SomeAction } from '@/static/modules/actions/types' ;
4+ import { applyStateUpdate } from '../utils' ;
25
3- export default ( state , action ) => {
6+ export default ( state : State , action : SomeAction ) : State => {
47 switch ( action . type ) {
58 case actionNames . INIT_STATIC_REPORT : {
69 const { stats} = action . payload ;
7- const { perBrowser, ...restStats } = stats ;
10+ const { perBrowser, ...restStats } = stats || { } ;
811
9- return {
10- ...state ,
12+ return applyStateUpdate ( state , {
1113 stats : {
1214 all : restStats ,
1315 perBrowser
1416 }
15- } ;
17+ } ) ;
1618 }
1719
1820 default :
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {AcceptableImage} from '@/static/modules/static-image-accepter';
1515import { CheckStatus } from '@/constants/checked-statuses' ;
1616import { EntityType } from '@/static/new-ui/features/suites/components/SuitesPage/types' ;
1717import { DbDetails } from '@/db-utils/common' ;
18+ import { Stats , PerBrowserStats } from '@/tests-tree-builder/static' ;
1819
1920export interface GroupEntity {
2021 id : string ;
@@ -342,6 +343,7 @@ export interface State {
342343 } ;
343344 timestamp : number ;
344345 fetchDbDetails : DbDetails [ ] ;
346+ stats : { all : Stats | Record < string , never > , perBrowser : PerBrowserStats | undefined } | null ;
345347}
346348
347349declare module 'react-redux' {
Original file line number Diff line number Diff line change @@ -5,22 +5,22 @@ import {ReporterTestResult} from '../adapters/test-result';
55import { SqliteTestResultAdapter } from '../adapters/test-result/sqlite' ;
66import { BrowserItem , RawSuitesRow } from '../types' ;
77
8- interface Stats {
8+ export interface Stats {
99 total : number ;
1010 passed : number ;
1111 failed : number ;
1212 skipped : number ;
1313 retries : number ;
1414}
1515
16- export type FinalStats = Stats & {
17- perBrowser : {
18- [ browserName : string ] : {
19- [ browserVersion : string ] : Stats
20- }
16+ export interface PerBrowserStats {
17+ [ browserName : string ] : {
18+ [ browserVersion : string ] : Stats
2119 }
2220}
2321
22+ export type FinalStats = Stats & { perBrowser : PerBrowserStats }
23+
2424export interface SkipItem {
2525 browser : string ;
2626 suite : string ;
Original file line number Diff line number Diff line change 1+ import reducer from 'lib/static/modules/reducers/stats' ;
2+ import actionNames from 'lib/static/modules/action-names' ;
3+ import type { State } from 'lib/static/new-ui/types/store' ;
4+ import type { InitStaticReportAction } from 'lib/static/modules/actions/lifecycle' ;
5+
6+ describe ( 'lib/static/modules/reducers/stats' , ( ) => {
7+ describe ( `"${ actionNames . INIT_STATIC_REPORT } " action` , ( ) => {
8+ it ( 'should not fail if stats is empty' , ( ) => {
9+ const action = { type : actionNames . INIT_STATIC_REPORT , payload : { stats : null } as InitStaticReportAction [ 'payload' ] } ;
10+
11+ const newState = reducer ( { } as State , action ) ;
12+
13+ assert . deepEqual ( newState . stats , { all : { } , perBrowser : undefined } as State [ 'stats' ] ) ;
14+ } ) ;
15+ } ) ;
16+ } ) ;
You can’t perform that action at this time.
0 commit comments