Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Mynij-unit-tests
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
Mynij-unit-tests
Commits
e64d05bb
Commit
e64d05bb
authored
Oct 24, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
content and index import scripts
parent
42cbb881
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
1 deletion
+124
-1
download_content_random.js
download_content_random.js
+26
-1
import_content.js
import_content.js
+49
-0
import_index.js
import_index.js
+49
-0
No files found.
download_content_random.js
View file @
e64d05bb
const
puppeteer
=
require
(
'
puppeteer
'
);
const
Server
=
require
(
'
ws
'
).
Server
;
const
randomstring
=
require
(
"
randomstring
"
);
const
tmp
=
require
(
'
tmp
'
);
const
fs
=
require
(
'
fs
'
);
...
...
@@ -10,6 +11,29 @@ const args = require("yargs")
.
nargs
(
"
prom
"
,
1
)
.
argv
;
var
start
,
browser
;
function
init_server
(){
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
if
(
msg
.
includes
(
"
Start
"
)){
start
=
Date
.
now
();
}
else
if
(
msg
.
includes
(
"
Done
"
)){
var
time_spent
=
Date
.
now
()
-
start
;
console
.
log
(
msg
+
"
in
"
+
time_spent
/
1000
+
"
s
"
);
}
else
{
console
.
log
(
"
Error :
"
+
msg
);
browser
.
close
();
}
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
});
}
function
gen_rdm_string
(
length
){
return
randomstring
.
generate
({
length
:
length
,
...
...
@@ -44,8 +68,9 @@ function gen_random_content (){
}
(
async
()
=>
{
init_server
();
var
file_path
=
gen_random_content
();
var
browser
=
await
puppeteer
.
launch
({
headless
:
false
});
browser
=
await
puppeteer
.
launch
({
headless
:
false
});
var
page
=
await
browser
.
newPage
();
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/download_content.html
'
);
const
[
fileChooser
]
=
await
Promise
.
all
([
...
...
import_content.js
0 → 100644
View file @
e64d05bb
const
puppeteer
=
require
(
'
puppeteer
'
);
const
Server
=
require
(
'
ws
'
).
Server
;
const
args
=
require
(
"
yargs
"
)
.
usage
(
"
Usage : import_content.js -file file_path -u if uncompressed file
"
)
.
demandOption
([
'
file
'
])
.
alias
(
"
f
"
,
"
file
"
)
.
alias
(
"
u
"
,
"
uncompressed
"
)
.
describe
(
"
file
"
,
"
file containing the index
"
)
.
describe
(
"
uncompressed
"
,
"
to add if file is uncompressed ! For testing only !
"
)
.
nargs
(
"
file
"
,
1
)
.
nargs
(
"
u
"
,
0
)
.
argv
;
var
browser
,
start
;
function
init_server
(){
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
if
(
msg
.
includes
(
"
Done :
"
)){
var
time_spent
=
Date
.
now
()
-
start
;
console
.
log
(
msg
+
"
in
"
+
time_spent
/
1000
+
"
s
"
);
browser
.
close
();
}
else
{
console
.
log
(
"
Error :
"
+
msg
);
browser
.
close
();
}
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
});
}
(
async
()
=>
{
init_server
();
browser
=
await
puppeteer
.
launch
();
var
page
=
await
browser
.
newPage
();
if
(
args
.
uncompressed
)
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/import_content_uncompressed.html
'
);
else
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/import_content.html
'
);
start
=
Date
.
now
();
const
[
fileChooser
]
=
await
Promise
.
all
([
page
.
waitForFileChooser
(),
page
.
click
(
'
input#load
'
)
]);
await
fileChooser
.
accept
([
args
.
file
]);
})();
import_index.js
0 → 100644
View file @
e64d05bb
const
puppeteer
=
require
(
'
puppeteer
'
);
const
Server
=
require
(
'
ws
'
).
Server
;
const
args
=
require
(
"
yargs
"
)
.
usage
(
"
Usage : import_index.js -file file_path -u if uncompressed file
"
)
.
demandOption
([
'
file
'
])
.
alias
(
"
f
"
,
"
file
"
)
.
alias
(
"
u
"
,
"
uncompressed
"
)
.
describe
(
"
file
"
,
"
file containing the index
"
)
.
describe
(
"
uncompressed
"
,
"
to add if file is uncompressed ! For testing only !
"
)
.
nargs
(
"
file
"
,
1
)
.
nargs
(
"
u
"
,
0
)
.
argv
;
var
browser
,
start
;
function
init_server
(){
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
if
(
msg
.
includes
(
"
Done :
"
)){
var
time_spent
=
Date
.
now
()
-
start
;
console
.
log
(
msg
+
"
in
"
+
time_spent
/
1000
+
"
s
"
);
browser
.
close
();
}
else
{
console
.
log
(
"
Error :
"
+
msg
);
browser
.
close
();
}
});
w
.
on
(
'
close
'
,
function
()
{
ws
.
close
();
});
});
}
(
async
()
=>
{
init_server
();
browser
=
await
puppeteer
.
launch
();
var
page
=
await
browser
.
newPage
();
if
(
args
.
uncompressed
)
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/import_index_uncompressed.html
'
);
else
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/import_index.html
'
);
start
=
Date
.
now
();
const
[
fileChooser
]
=
await
Promise
.
all
([
page
.
waitForFileChooser
(),
page
.
click
(
'
input#load
'
)
]);
await
fileChooser
.
accept
([
args
.
file
]);
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment