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

Commit695cb26

Browse files
committed
fix test run on page load bug, discriminate between timing for throttling testRun action
1 parent3ca9813 commit695cb26

File tree

12 files changed

+74
-21
lines changed

12 files changed

+74
-21
lines changed

‎CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to[Semantic Versioning](http://semver.org/).
44

5+
#[0.10.10] - 2016-07-30
6+
- performance increase
7+
- fix test run on page load
8+
59
##[0.10.9] - 2016-07-24
610
- improved error handling
711

‎lib/components/Page/Task/taskCheckbox.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ var TaskCheckbox = (function (_super) {
2929
_super.apply(this,arguments);
3030
}
3131
TaskCheckbox.prototype.render=function(){
32-
var_a=this.props,testRun=_a.testRun,isCurrentTask=_a.isCurrentTask;
33-
if(!isCurrentTask||!testRun){
32+
var_a=this.props,isRunning=_a.isRunning,isCurrentTask=_a.isCurrentTask;
33+
if(!isCurrentTask||!isRunning){
3434
returnnull;
3535
}
3636
returnReact.createElement(indeterminate_check_box_1.default,{color:colors_1.orange500,style:styles.checkbox});
3737
};
3838
TaskCheckbox=__decorate([
3939
react_redux_1.connect(function(state,props){return({
40-
testRun:state.testRun,
40+
isRunning:state.testRun.running,
4141
isCurrentTask:state.taskPosition===props.index,
4242
});}),
4343
__metadata('design:paramtypes',[])

‎lib/modules/tests/actions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ var actions_1 = require('../../actions');
33
vartypes_1=require('./types');
44
functiontestRun(){
55
returnfunction(dispatch,getState){
6+
vartimeSinceLastTestRun=performance.now()-getState().testRun.time;
7+
if(timeSinceLastTestRun<1000){
8+
return;
9+
}
610
var_a=getState(),taskTests=_a.taskTests,dir=_a.dir,tutorial=_a.tutorial,taskPosition=_a.taskPosition;
711
dispatch({
812
type:types_1.TEST_RUN,payload:{taskTests:taskTests,dir:dir,tutorial:tutorial,taskPosition:taskPosition}
@@ -61,6 +65,8 @@ function testComplete(result) {
6165
result.msg="Task "+result.taskPosition+" Complete";
6266
dispatch(testResult(result));
6367
break;
68+
default:
69+
return;
6470
}
6571
dispatch({type:types_1.TEST_COMPLETE});
6672
};

‎lib/modules/tests/test-run/index.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
"use strict";
22
vartypes_1=require('../types');
33
varrun_1=require('./run');
4+
vardefaultTestRun={
5+
running:false,
6+
time:performance.now(),
7+
};
48
functionrunTest(testRun,action){
5-
if(testRun===void0){testRun=false;}
9+
if(testRun===void0){testRun=defaultTestRun;}
610
switch(action.type){
711
casetypes_1.TEST_RUN:
812
var_a=action.payload,taskTests=_a.taskTests,dir=_a.dir,tutorial=_a.tutorial,taskPosition=_a.taskPosition;
9-
returnrun_1.default(taskTests,dir,tutorial,taskPosition);
13+
return{
14+
running:true,
15+
time:run_1.default(taskTests,dir,tutorial,taskPosition),
16+
};
1017
casetypes_1.TEST_COMPLETE:
11-
returnfalse;
18+
return{
19+
running:false,
20+
time:performance.now()+800,
21+
};
1222
case'PAGE_SET':
13-
returnfalse;
23+
return{
24+
running:false,
25+
time:performance.now()+2000,
26+
};
1427
default:
1528
returntestRun;
1629
}

‎lib/modules/tests/test-run/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function runTaskTests(taskTests, dir, tutorial, taskPosition) {
1313
};
1414
tutorialConfig.run({testString:testString,config:config,handleResult:handle_result_1.default});
1515
}
16-
returntrue;
16+
returnperformance.now();
1717
}
1818
Object.defineProperty(exports,"__esModule",{value:true});
1919
exports.default=runTaskTests;

‎lib/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
55
exports.default=core_coderoad_1.configureStore({
66
reducer:reducers_1.default,
77
devMode:false,
8-
throttle:{TEST_RUN:800},
8+
throttle:{},
99
});

‎src/components/Page/Task/taskCheckbox.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ const styles = {
1414
};
1515

1616
@connect((state,props)=>({
17-
testRun:state.testRun,
17+
isRunning:state.testRun.running,
1818
isCurrentTask:state.taskPosition===props.index,
1919
}))
2020
exportdefaultclassTaskCheckboxextendsReact.Component<{
21-
testRun?:boolean,isCurrentTask?:boolean,index:number
21+
isRunning?:boolean,isCurrentTask?:boolean,index:number
2222
},{}>{
2323
publicrender(){
24-
const{testRun, isCurrentTask}=this.props;
25-
if(!isCurrentTask||!testRun){returnnull;}
24+
const{isRunning, isCurrentTask}=this.props;
25+
if(!isCurrentTask||!isRunning){returnnull;}
2626
return<IndeterminateCheckBox
2727
color={orange500}
2828
style={styles.checkbox}

‎src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Subscriptions from './subscriptions';
99
import{loadPolyfills,render}from'core-coderoad';
1010
import*asinjectTapEventPluginfrom'react-tap-event-plugin';
1111

12+
// React optimization
1213
process.env.NODE_ENV='production';
1314

1415
classMain{

‎src/modules/tests/actions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import {TEST_COMPLETE, TEST_RESULT, TEST_RUN} from './types';
33

44
exportfunctiontestRun():ReduxThunk.ThunkInterface{
55
return(dispatch,getState):void=>{
6+
// less than a second since the last test run, skip
7+
consttimeSinceLastTestRun=performance.now()-getState().testRun.time;
8+
if(timeSinceLastTestRun<1000){
9+
return;
10+
}
611
const{taskTests, dir, tutorial, taskPosition}=getState();
712
dispatch({
813
type:TEST_RUN,payload:{ taskTests, dir, tutorial, taskPosition}
@@ -70,6 +75,8 @@ export function testComplete(result: Test.Result) {
7075
// check if page is completed
7176
dispatch(testResult(result));
7277
break;
78+
default:
79+
return;
7380
}
7481
dispatch({type:TEST_COMPLETE});
7582
};

‎src/modules/tests/test-run/index.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
11
import{TEST_COMPLETE,TEST_RUN}from'../types';
22
importrunTaskTestsfrom'./run';
33

4+
interfaceIRunTest{
5+
running:boolean;
6+
time:number;
7+
}
8+
9+
constdefaultTestRun:IRunTest={
10+
running:false,
11+
time:performance.now(),
12+
};
13+
414
exportdefaultfunctionrunTest(
5-
testRun=false,action:Action
6-
):boolean{
15+
testRun=defaultTestRun,action:Action
16+
):IRunTest{
717
switch(action.type){
818

919
caseTEST_RUN:
1020
const{taskTests, dir, tutorial, taskPosition}=action.payload;
11-
returnrunTaskTests(taskTests,dir,tutorial,taskPosition);
21+
// call test runner
22+
return{
23+
running:true,
24+
time:runTaskTests(taskTests,dir,tutorial,taskPosition),
25+
};
1226

1327
caseTEST_COMPLETE:
14-
returnfalse;
28+
return{
29+
running:false,
30+
time:performance.now()+800,
31+
};
1532

1633
case'PAGE_SET':
17-
returnfalse;
34+
// add extra time, as page loading takes longer
35+
return{
36+
running:false,
37+
time:performance.now()+2000,
38+
};
1839

1940
default:
2041
returntestRun;

‎src/modules/tests/test-run/run.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import parseLoaders from './parse-loaders';
55

66
exportdefaultfunctionrunTaskTests(
77
taskTests:string,dir:string,tutorial:CR.Tutorial,taskPosition:number
8-
):boolean{
8+
):number{
99
consttests:string=taskTests;
1010

1111
if(tests&&tests.length){
@@ -23,5 +23,7 @@ export default function runTaskTests(
2323
// call test runner
2424
tutorialConfig.run({testString, config, handleResult});
2525
}
26-
returntrue;
26+
// return finishing time of test
27+
// used to throttle test runs
28+
returnperformance.now();
2729
}

‎src/store.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ import {configureStore} from 'core-coderoad';
44
exportdefaultconfigureStore({
55
reducer,
66
devMode:false,
7-
throttle:{TEST_RUN:800},
87
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp