Skip to content

Commit

Permalink
fix: test case errors
Browse files Browse the repository at this point in the history
  • Loading branch information
scottsut committed Oct 27, 2020
1 parent cfb4c34 commit 773f165
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 38 deletions.
16 changes: 8 additions & 8 deletions webapp/test/app/containers/Display/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
mockSlideId,
mockGraphLayerFormed,
mockWidgetFormed,
mockView,
mockFormedViews,
mockHttpError,
mockCover,
mockSlide,
Expand All @@ -48,8 +48,8 @@ import {
mockShareLinkParams,
mockShareToken,
mockAuthShareToken,
mockPwdToken,
mockPwd,
mockPasswordToken,
mockPassword,
mockDisplayTitle
} from './fixtures'

Expand Down Expand Up @@ -77,15 +77,15 @@ describe('Display Actions', () => {
slideId: mockSlideId,
layers: [mockGraphLayerFormed],
widgets: [mockWidgetFormed],
views: [mockView]
formedViews: mockFormedViews
}
}
expect(
actions.slideDetailLoaded(
mockSlideId,
[mockGraphLayerFormed],
[mockWidgetFormed],
[mockView]
mockFormedViews
)
).toEqual(expectedResult)
})
Expand Down Expand Up @@ -556,12 +556,12 @@ describe('Display Actions', () => {
const expectedResult = {
type: ActionTypes.LOAD_DISPLAY_PASSWORD_SHARE_LINK_SUCCESS,
payload: {
pwdToken: mockPwdToken,
pwd: mockPwd
passwordShareToken: mockPasswordToken,
password: mockPassword
}
}
expect(
actions.displayPasswordShareLinkLoaded(mockPwdToken, mockPwd)
actions.displayPasswordShareLinkLoaded(mockPasswordToken, mockPassword)
).toEqual(expectedResult)
})
})
Expand Down
60 changes: 38 additions & 22 deletions webapp/test/app/containers/Display/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
ILayerParams
} from 'app/containers/Display/components/types'

import { IView } from 'app/containers/View/types'
import { IFormedViews, IView } from 'app/containers/View/types'
import {
IDisplayState,
IDisplaySharePanelState,
Expand All @@ -37,6 +37,11 @@ import { displayInitialState } from 'app/containers/Display/reducer'
import { appInitialState } from 'app/containers/App/reducer'
import { viewInitialState } from 'app/containers/View/reducer'
import { IVizState } from 'app/containers/Viz/types'
import { IShareTokenParams } from 'app/components/SharePanel/types'
import {
ViewModelTypes,
ViewModelVisualTypes
} from 'app/containers/View/constants'
export const mockDisplayId: number = 72

export const mockSlideId: number = 627
Expand Down Expand Up @@ -75,7 +80,7 @@ export const Req =
export const mockAuthShareToken =
'eNoVjskRBDEIxFIazoYnBpN_SOv9Syp5RcR-Yo11zerL6o4oxNbFFKxCSAyUPTr57W5Ysto0nSSXM0pfqt4RhWJSM4UT7PjzT8uKV9DnJt_tSEJKfK--eZs0LilMittsZe5UvL7nW3C7x-EF7uMn4nlRxnyMqPV8mmu4B2BzNmQ8alU6dBy0_gM8rDKA'

export const mockPwdToken =
export const mockPasswordToken =
'eNoVzrkBAzEIBMCWED8hQmz_JZ0dTD7emQkSm4Br9Syre2RHojcepwomni3LC6adhRz48ZGT8ISk0S3fjEzCUB9G14z5ueEGU9C03eSWcCe-oPjJwpOunaOg'

export const mockHttpError = new Error('Request failed with status code 403')
Expand All @@ -95,12 +100,12 @@ export const mockDeltaSize = {
deltaHeight: 0
}

export const mockCover = new Blob([''], {
export const mockCover = new Blob([''], {
type: 'image/png'
})
export const mockShareToken =
'eNoNybkBwDAIBLCVAGM4Ssyz_0hJpUKWAJbOLV_TyBpRM0c6Nscbr9jHmlmzrNEjTLtZOOYVI61sTwr0opc0wZO0NEJT_q8QXVylZvP4jbMmRYuRKsgHZMwdFA'
export const mockPwd = 'RYO92FBC'
export const mockPassword = 'RYO92FBC'
export const mockShareTokenReq = {
password: '',
token:
Expand All @@ -112,12 +117,13 @@ export const defaultSharePanelState: IDisplaySharePanelState = {
title: '',
visible: false
}
export const mockShareLinkParams = {
export const mockShareLinkParams: IShareTokenParams = {
id: 72,
mode: 'AUTH',
expired: '2030-01-01',
permission: 'SHARER',
roles: null,
viewerIds: null
viewers: null
}

export const mockBaseLines: IBaseline = {
Expand All @@ -129,18 +135,30 @@ export const mockBaseLines: IBaseline = {
adjust: [0, 0]
}

export const mockView: IView = {
roles: [],
name: '渠道信息',
projectId: 41,
sourceId: 53,
sql: 'SELECT * from dad',
variable: '[]',
config: '',
description: '',
id: 127,
model:
'{"name_level1":{"sqlType":"VARCHAR","visualType":"string","modelType":"category"},"总停留时间":{"sqlType":"DECIMAL","visualType":"number","modelType":"value"},"name_level2":{"sqlType":"VARCHAR","visualType":"string","modelType":"category"},"总调出次数":{"sqlType":"DECIMAL","visualType":"number","modelType":"value"},"name_level3":{"sqlType":"VARCHAR","visualType":"string","modelType":"category"},"platform":{"sqlType":"VARCHAR","visualType":"string","modelType":"category"},"总访问次数":{"sqlType":"DECIMAL","visualType":"number","modelType":"value"},"QD_id":{"sqlType":"VARCHAR","visualType":"string","modelType":"category"},"总页数":{"sqlType":"DECIMAL","visualType":"number","modelType":"value"}}'
export const mockFormedViews: IFormedViews = {
127: {
id: 127,
roles: [],
name: '渠道信息',
projectId: 41,
sourceId: 53,
sql: 'SELECT * from dad',
variable: [],
config: '',
description: '',
model: {
name_level1: {
sqlType: 'VARCHAR',
visualType: ViewModelVisualTypes.String,
modelType: ViewModelTypes.Category
},
总停留时间: {
sqlType: 'DECIMAL',
visualType: ViewModelVisualTypes.Number,
modelType: ViewModelTypes.Value
}
}
}
}

export const mockSlideParams: ISlideParams = {
Expand Down Expand Up @@ -389,13 +407,13 @@ export const mockViewItem = {
config: '',
description: '演示-人员信息',
id: 84,
model: '',
model: '{}',
name: '人员信息',
projectId: 41,
sourceId: 53,
sql:
'SELECT * from personinfo where 1=1↵$if(name)$↵ and name = $name$↵$endif$↵$if(nation)$↵ and nation = $nation$↵$endif$↵$if(education)$↵ and education in ($education$)↵$endif$↵$if(city)$↵ and city in ($city$)↵$endif$',
variable: '',
variable: '[]',
roles: []
}

Expand Down Expand Up @@ -511,5 +529,3 @@ export const mockAppState = appInitialState
export const mockViewState = {
view: viewInitialState
}


14 changes: 7 additions & 7 deletions webapp/test/app/containers/Display/reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import {
mockGraphLayerFormed,
mockSlideLayersOperationInfo,
mockWidgetFormed,
mockPwdToken,
mockPwd,
mockPasswordToken,
mockPassword,
mockChangedOperationInfo,
mockDeltaSize,
mockFinish,
Expand All @@ -45,7 +45,7 @@ import {
mockShareToken,
mockAuthShareToken,
mockDisplayTitle,
mockView,
mockFormedViews,
mockCurrentDisplayWidgets,
mockDefaultSlideLayersOperationGraphInfo,
mockGraphLayerId,
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('displayReducer', () => {
mockSlideId,
[mockGraphLayerFormed],
[mockWidgetFormed],
[mockView]
mockFormedViews
)
)
).toEqual(expectedResult)
Expand Down Expand Up @@ -127,14 +127,14 @@ describe('displayReducer', () => {

it('should handle the displayPasswordShareLinkLoaded action correctly', () => {
const expectedResult = produce(state, (draft) => {
draft.currentDisplayPasswordShareToken = mockPwdToken
draft.currentDisplayPasswordPassword = mockPwd
draft.currentDisplayPasswordShareToken = mockPasswordToken
draft.currentDisplayPasswordPassword = mockPassword
draft.loading.shareToken = false
})
expect(
reducer(
state,
actions.displayPasswordShareLinkLoaded(mockPwdToken, mockPwd)
actions.displayPasswordShareLinkLoaded(mockPasswordToken, mockPassword)
)
).toEqual(expectedResult)
})
Expand Down
6 changes: 5 additions & 1 deletion webapp/test/app/containers/Display/sagas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ describe('getSlideDetail Saga', () => {
mockSlideId,
[mockGraphLayerFormed],
[mockWidgetFormed],
[mockViewItem]
{[mockWidgetFormed.viewId]: {
...mockViewItem,
model: {},
variable: []
}}
)
)
.run()
Expand Down

0 comments on commit 773f165

Please sign in to comment.