Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8dc00aa

Browse files
committed
setup test notify
1 parentfeeaf97 commit8dc00aa

File tree

10 files changed

+84
-71
lines changed

10 files changed

+84
-71
lines changed

‎typings/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ export interface ErrorMessage {
4242
description?:string
4343
}
4444

45+
exportinterfaceTestStatus{
46+
type:'success'|'warning'|'error'|'loading'
47+
title:string
48+
content?:string
49+
}
50+
4551
exportinterfaceMachineContext{
4652
env:Environment
4753
error:ErrorMessage|null
4854
tutorial:G.Tutorial|null
4955
position:Position
5056
progress:Progress
5157
processes:ProcessEvent[]
58+
testStatus:TestStatus|null
5259
}
5360

5461
exportinterfaceMachineEvent{

‎web-app/src/components/ProcessMessages/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as T from 'typings'
44
import{css,jsx}from'@emotion/core'
55

66
interfaceProps{
7+
testStatus:T.TestStatus|null
78
processes:T.ProcessEvent[]
89
}
910

@@ -15,7 +16,14 @@ const styles = {
1516
}
1617

1718
// display a list of active processes
18-
constProcessMessages=({ processes}:Props)=>{
19+
constProcessMessages=({ processes, testStatus}:Props)=>{
20+
if(testStatus){
21+
return(
22+
<Messagekey={testStatus.title}type={testStatus.type}title={testStatus.title}size="medium">
23+
{testStatus.content}
24+
</Message>
25+
)
26+
}
1927
if(!processes.length){
2028
returnnull
2129
}

‎web-app/src/containers/LoadingPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const LoadingPage = ({ text, context }: Props) => {
2525
if(error){
2626
return(
2727
<divcss={styles.page}>
28-
<Messagetype="error"title={error.title}description={error.description}/>
28+
<Messagetype="error"title={error.title}>
29+
{error.description}
30+
</Message>
2931
</div>
3032
)
3133
}

‎web-app/src/containers/Tutorial/LevelPage/Level.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ const styles = {
6868
interfaceProps{
6969
level:G.Level&{status:T.ProgressStatus;index:number;steps:Array<G.Step&{status:T.ProgressStatus}>}
7070
processes:T.ProcessEvent[]
71+
testStatus:T.TestStatus|null
7172
onContinue():void
7273
onLoadSolution():void
7374
}
7475

75-
constLevel=({ level, onContinue, onLoadSolution, processes}:Props)=>{
76+
constLevel=({ level, onContinue, onLoadSolution, processes, testStatus}:Props)=>{
7677
if(!level.steps){
7778
thrownewError('No Stage steps found')
7879
}
@@ -109,7 +110,7 @@ const Level = ({ level, onContinue, onLoadSolution, processes }: Props) => {
109110

110111
{processes.length>0&&(
111112
<divcss={styles.processes}>
112-
<ProcessMessagesprocesses={processes}/>
113+
<ProcessMessagesprocesses={processes}testStatus={testStatus}/>
113114
</div>
114115
)}
115116

‎web-app/src/containers/Tutorial/LevelPage/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface PageProps {
1010
}
1111

1212
constLevelSummaryPageContainer=(props:PageProps)=>{
13-
const{ position, progress, processes, error}=props.context
13+
const{ position, progress, processes,testStatus,error}=props.context
1414

1515
constversion=selectors.currentVersion(props.context)
1616
constlevelData:G.Level=selectors.currentLevel(props.context)
@@ -48,7 +48,15 @@ const LevelSummaryPageContainer = (props: PageProps) => {
4848
}),
4949
}
5050

51-
return<Levellevel={level}onContinue={onContinue}onLoadSolution={onLoadSolution}processes={processes}/>
51+
return(
52+
<Level
53+
level={level}
54+
onContinue={onContinue}
55+
onLoadSolution={onLoadSolution}
56+
processes={processes}
57+
testStatus={testStatus}
58+
/>
59+
)
5260
}
5361

5462
exportdefaultLevelSummaryPageContainer

‎web-app/src/services/notify/index.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import*asCRfrom'typings'
2-
import{ActionFunctionMap}from'xstate'
3-
importnotifyfrom'../../notify'
2+
import{assign,ActionFunctionMap}from'xstate'
43

54
consttestActions:ActionFunctionMap<CR.MachineContext,CR.MachineEvent>={
6-
testPass(){
7-
notify({
8-
key:'test',
5+
//@ts-ignore
6+
testStart:assign({
7+
testStatus:()=>({
8+
type:'loading',
9+
title:'Test running...',
10+
}),
11+
}),
12+
//@ts-ignore
13+
testPass:assign({
14+
testStatus:()=>({
15+
type:'success',
916
title:'Success!',
10-
content:'',
11-
duration:1500,
12-
})
13-
},
14-
testFail(context,event){
15-
notify({
16-
key:'test',
17-
title:'Fail',
18-
content:'',
19-
duration:3000,
20-
})
21-
},
17+
}),
18+
}),
19+
//@ts-ignore
20+
testFail:assign({
21+
testStatus:()=>({
22+
type:'warning',
23+
title:'Fail!',
24+
content:'Test failed for some reason',
25+
}),
26+
}),
2227
}
2328

2429
exportdefaulttestActions

‎web-app/src/services/state/machine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const createMachine = (options: any) => {
2727
complete:false,
2828
},
2929
processes:[],
30+
testStatus:null,
3031
},
3132
states:{
3233
Start:{

‎web-app/stories/Commands.stories.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ storiesOf('Components', module)
1414
.addDecorator(SideBarDecorator)
1515
.add('Processes',()=>(
1616
<ProcessMessages
17+
testStatus={null}
1718
processes={[
1819
{
1920
title:'npm install',
@@ -26,3 +27,31 @@ storiesOf('Components', module)
2627
]}
2728
/>
2829
))
30+
.add('Test Start',()=>(
31+
<ProcessMessages
32+
testStatus={{
33+
type:'loading',
34+
title:'Test running...',
35+
}}
36+
processes={[]}
37+
/>
38+
))
39+
.add('Test Pass',()=>(
40+
<ProcessMessages
41+
testStatus={{
42+
type:'success',
43+
title:'Success!',
44+
}}
45+
processes={[]}
46+
/>
47+
))
48+
.add('Test Fail',()=>(
49+
<ProcessMessages
50+
testStatus={{
51+
type:'warning',
52+
title:'Fail!',
53+
content:'Test failed for some reason',
54+
}}
55+
processes={[]}
56+
/>
57+
))

‎web-app/stories/TestNotify.stories.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp