Skip to content

Commit 9efb78b

Browse files
committed
PRNG included. Closes #4
1 parent f636733 commit 9efb78b

File tree

4 files changed

+48
-12
lines changed

4 files changed

+48
-12
lines changed

cypress/integration/monkey/monkey.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
//Imports
1+
//Import
22
require('cypress-plugin-tab');
3-
var fs = require('fs');
43

5-
const url = Cypress.env('baseUrl') || "https://uniandes.edu.co/";
4+
const url = Cypress.config('baseUrl') || "https://uniandes.edu.co/";
65
const appName = Cypress.env('appName')|| "your app";
76
const events = Cypress.env('events')|| 100;
87
const delay = Cypress.env('delay') || 100;
8+
const seed = Cypress.env('seed') || 12;
99

1010
const pct_clicks = Cypress.env('pctClicks') || 19;
1111
const pct_scrolls = Cypress.env('pctScroll') || 17;
@@ -14,12 +14,29 @@ const pct_keys = Cypress.env('pctKeys') || 16;
1414
const pct_spkeys = Cypress.env('pctSpKeys') || 16;
1515
const pct_pgnav = Cypress.env('pctPgNav') || 16;
1616

17+
/*
18+
Bob Jenkins Small Fast, aka smallprng pseudo random number generator is the chosen selection for introducing seeding in the tester
19+
Credits of the implementation to bryc's answer in this stackoverflow post: https://stackoverflow.com/a/47593316
20+
*/
21+
function jsf32(a, b, c, d) {
22+
return function() {
23+
a |= 0; b |= 0; c |= 0; d |= 0;
24+
var t = a - (b << 27 | b >>> 5) | 0;
25+
a = b ^ (c << 17 | c >>> 15);
26+
b = c + d | 0;
27+
c = d + t | 0;
28+
d = a + t | 0;
29+
return (d >>> 0) / 4294967296;
30+
}
31+
}
32+
33+
var random = jsf32(0xF1AE533D, seed, seed, seed);
1734

1835
function getRandomInt(min, max) {
1936
min = Math.ceil(min);
2037
max = Math.floor(max);
21-
return Math.floor(Math.random() * (max - min)) + min;
22-
};
38+
return Math.floor(random() * (max - min)) + min;
39+
}
2340

2441
function fullPath(el){
2542
var names = [];

cypress/integration/monkey/smart-monkey.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//Imports
22
require('cypress-plugin-tab');
3-
var fs = require('fs');
43
var faker = require('faker');
54

65
const url = Cypress.config('baseUrl') || "https://uniandes.edu.co/";
76
const appName = Cypress.env('appName')|| "your app";
87
const events = Cypress.env('events')|| 100;
98
const delay = Cypress.env('delay') || 100;
9+
const seed = Cypress.env('seed') || 12;
1010

1111
const pct_clicks = Cypress.env('pctClicks') || 12;
1212
const pct_scrolls = Cypress.env('pctScroll') || 12;
@@ -17,12 +17,29 @@ const pct_pgnav = Cypress.env('pctPgNav') || 12;
1717
const pct_browserChaos = Cypress.env('pctBwChaos') || 12;
1818
const pct_actions = Cypress.env('pctActions') || 16;
1919

20+
/*
21+
Bob Jenkins Small Fast, aka smallprng pseudo random number generator is the chosen selection for introducing seeding in the tester
22+
Credits of the implementation to bryc's answer in this stackoverflow post: https://stackoverflow.com/a/47593316
23+
*/
24+
function jsf32(a, b, c, d) {
25+
return function() {
26+
a |= 0; b |= 0; c |= 0; d |= 0;
27+
var t = a - (b << 27 | b >>> 5) | 0;
28+
a = b ^ (c << 17 | c >>> 15);
29+
b = c + d | 0;
30+
c = d + t | 0;
31+
d = a + t | 0;
32+
return (d >>> 0) / 4294967296;
33+
}
34+
}
35+
36+
var random = jsf32(0xF1AE533D, seed, seed, seed);
2037

2138
function getRandomInt(min, max) {
2239
min = Math.ceil(min);
2340
max = Math.floor(max);
24-
return Math.floor(Math.random() * (max - min)) + min;
25-
};
41+
return Math.floor(random() * (max - min)) + min;
42+
}
2643

2744
function fullPath(el){
2845
var names = [];
@@ -438,7 +455,7 @@ const functions = [
438455
[spkeypress, enter],
439456
[reload, navBack, navForward],
440457
[changeViewport, clearCookies, clearLocalStorage],
441-
[fillInput, clearInput, clickRandAnchor, clickRandButton]
458+
[ clickRandAnchor, clickRandButton]
442459
];
443460

444461
describe( `${appName} under smarter monkeys`, function() {
@@ -458,7 +475,7 @@ describe( `${appName} under smarter monkeys`, function() {
458475
cy.wait(1000);
459476
//Add an event for each type of event in order to enter the else statement of randomEvent method
460477
for(let i = 0; i < events + 7; i++){
461-
fillInput();
478+
randomEvent();
462479
}
463480
}
464481
})

monkey-config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
2+
13
{
24
"projectId":"TSDL-Monkey-with-cypress",
3-
"baseUrl":"https://uniandes.edu.co/",
5+
"baseUrl":"https://caev03.github.io/",
46
"env":{
57
"appName":"App prueba",
68
"events":50,

smart-monkey-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"projectId":"TSDL-Smart-Monkey-with-cypress",
3-
"baseUrl":"https://uniandes.edu.co/",
3+
"baseUrl":"https://caev03.github.io/",
44
"env":{
55
"appName":"App prueba",
66
"events":50,

0 commit comments

Comments
 (0)