Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 18b1ace1
authored
Jan 05, 2020
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring tests up-to-date
1 parent
6ce404d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
53 deletions
test/test.js
test/test.js
View file @
18b1ace
...
@@ -12,43 +12,34 @@ var execSync = require('child_process').execSync,
...
@@ -12,43 +12,34 @@ var execSync = require('child_process').execSync,
path
=
require
(
'path'
),
path
=
require
(
'path'
),
util
=
require
(
'util'
),
util
=
require
(
'util'
),
superagent
=
require
(
'superagent'
),
superagent
=
require
(
'superagent'
),
webdriver
=
require
(
'selenium-webdriver'
);
{
Builder
,
By
,
until
}
=
require
(
'selenium-webdriver'
),
{
Options
}
=
require
(
'selenium-webdriver/chrome'
);
var
by
=
webdriver
.
By
,
until
=
webdriver
.
until
;
if
(
!
process
.
env
.
USERNAME
||
!
process
.
env
.
PASSWORD
)
{
if
(
!
process
.
env
.
USERNAME
||
!
process
.
env
.
PASSWORD
)
{
console
.
log
(
'USERNAME and PASSWORD env vars need to be set'
);
console
.
log
(
'USERNAME and PASSWORD env vars need to be set'
);
process
.
exit
(
1
);
process
.
exit
(
1
);
}
}
const
EXEC_OPTIONS
=
{
cwd
:
path
.
resolve
(
__dirname
,
'..'
),
stdio
:
'inherit'
};
describe
(
'Application life cycle test'
,
function
()
{
describe
(
'Application life cycle test'
,
function
()
{
this
.
timeout
(
0
);
this
.
timeout
(
0
);
var
browser
;
const
EXEC_OPTIONS
=
{
cwd
:
path
.
resolve
(
__dirname
,
'..'
),
stdio
:
'inherit'
};
const
LOCATION
=
'test'
;
const
TEST_TIMEOUT
=
10000
;
const
TEST_FILE_NAME_0
=
'index.html'
;
const
TEST_FILE_NAME_1
=
'test.txt'
;
before
(
function
(
done
)
{
var
app
;
browser
=
new
webdriver
.
Builder
()
var
browser
;
.
forBrowser
(
'chrome'
)
// .setChromeOptions(new chrome.Options().addArguments(['no-sandbox', 'headless']))
.
build
();
done
();
before
(
function
()
{
browser
=
new
Builder
().
forBrowser
(
'chrome'
).
setChromeOptions
(
new
Options
().
windowSize
({
width
:
1280
,
height
:
1024
})).
build
();
});
});
after
(
function
(
done
)
{
after
(
function
()
{
browser
.
quit
();
browser
.
quit
();
done
();
});
});
var
LOCATION
=
'test'
;
var
TEST_TIMEOUT
=
10000
;
var
TEST_FILE_NAME_0
=
'index.html'
;
var
TEST_FILE_NAME_1
=
'test.txt'
;
var
app
;
function
waitForElement
(
elem
)
{
function
waitForElement
(
elem
)
{
return
browser
.
wait
(
until
.
elementLocated
(
elem
),
TEST_TIMEOUT
).
then
(
function
()
{
return
browser
.
wait
(
until
.
elementLocated
(
elem
),
TEST_TIMEOUT
).
then
(
function
()
{
return
browser
.
wait
(
until
.
elementIsVisible
(
browser
.
findElement
(
elem
)),
TEST_TIMEOUT
);
return
browser
.
wait
(
until
.
elementIsVisible
(
browser
.
findElement
(
elem
)),
TEST_TIMEOUT
);
...
@@ -60,12 +51,12 @@ describe('Application life cycle test', function () {
...
@@ -60,12 +51,12 @@ describe('Application life cycle test', function () {
browser
.
manage
().
deleteAllCookies
();
browser
.
manage
().
deleteAllCookies
();
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/_admin'
);
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/_admin'
);
waitForElement
(
b
y
.
id
(
'loginUsernameInput'
)).
then
(
function
()
{
waitForElement
(
B
y
.
id
(
'loginUsernameInput'
)).
then
(
function
()
{
browser
.
findElement
(
b
y
.
id
(
'loginUsernameInput'
)).
sendKeys
(
process
.
env
.
USERNAME
);
browser
.
findElement
(
B
y
.
id
(
'loginUsernameInput'
)).
sendKeys
(
process
.
env
.
USERNAME
);
browser
.
findElement
(
b
y
.
id
(
'loginPasswordInput'
)).
sendKeys
(
process
.
env
.
PASSWORD
);
browser
.
findElement
(
B
y
.
id
(
'loginPasswordInput'
)).
sendKeys
(
process
.
env
.
PASSWORD
);
browser
.
findElement
(
b
y
.
id
(
'loginSubmitButton'
)).
click
();
browser
.
findElement
(
B
y
.
id
(
'loginSubmitButton'
)).
click
();
waitForElement
(
b
y
.
id
(
'burgerMenuButton'
)).
then
(
function
()
{
waitForElement
(
B
y
.
id
(
'burgerMenuButton'
)).
then
(
function
()
{
done
();
done
();
});
});
});
});
...
@@ -74,16 +65,16 @@ describe('Application life cycle test', function () {
...
@@ -74,16 +65,16 @@ describe('Application life cycle test', function () {
function
logout
(
done
)
{
function
logout
(
done
)
{
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/_admin'
);
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/_admin'
);
waitForElement
(
b
y
.
id
(
'burgerMenuButton'
)).
then
(
function
()
{
waitForElement
(
B
y
.
id
(
'burgerMenuButton'
)).
then
(
function
()
{
browser
.
findElement
(
b
y
.
id
(
'burgerMenuButton'
)).
click
();
browser
.
findElement
(
B
y
.
id
(
'burgerMenuButton'
)).
click
();
// wait for open animation
// wait for open animation
browser
.
sleep
(
5000
);
browser
.
sleep
(
5000
);
waitForElement
(
b
y
.
id
(
'logoutButton'
)).
then
(
function
()
{
waitForElement
(
B
y
.
id
(
'logoutButton'
)).
then
(
function
()
{
browser
.
findElement
(
b
y
.
id
(
'logoutButton'
)).
click
();
browser
.
findElement
(
B
y
.
id
(
'logoutButton'
)).
click
();
waitForElement
(
b
y
.
id
(
'loginUsernameInput'
)).
then
(
function
()
{
waitForElement
(
B
y
.
id
(
'loginUsernameInput'
)).
then
(
function
()
{
done
();
done
();
});
});
});
});
...
@@ -93,7 +84,7 @@ describe('Application life cycle test', function () {
...
@@ -93,7 +84,7 @@ describe('Application life cycle test', function () {
function
checkFileIsListed
(
name
,
done
)
{
function
checkFileIsListed
(
name
,
done
)
{
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/_admin'
);
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/_admin'
);
waitForElement
(
b
y
.
xpath
(
'//*[text()="'
+
name
+
'"]'
)).
then
(
function
()
{
waitForElement
(
B
y
.
xpath
(
'//*[text()="'
+
name
+
'"]'
)).
then
(
function
()
{
done
();
done
();
});
});
}
}
...
@@ -101,7 +92,7 @@ describe('Application life cycle test', function () {
...
@@ -101,7 +92,7 @@ describe('Application life cycle test', function () {
function
checkFileIsPresent
(
done
)
{
function
checkFileIsPresent
(
done
)
{
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/'
+
TEST_FILE_NAME_0
);
browser
.
get
(
'https://'
+
app
.
fqdn
+
'/'
+
TEST_FILE_NAME_0
);
waitForElement
(
b
y
.
xpath
(
'//*[text()="test"]'
)).
then
(
function
()
{
waitForElement
(
B
y
.
xpath
(
'//*[text()="test"]'
)).
then
(
function
()
{
done
();
done
();
});
});
}
}
...
@@ -109,7 +100,7 @@ describe('Application life cycle test', function () {
...
@@ -109,7 +100,7 @@ describe('Application life cycle test', function () {
function
checkIndexFileIsServedUp
(
done
)
{
function
checkIndexFileIsServedUp
(
done
)
{
browser
.
get
(
'https://'
+
app
.
fqdn
);
browser
.
get
(
'https://'
+
app
.
fqdn
);
waitForElement
(
b
y
.
xpath
(
'//*[text()="test"]'
)).
then
(
function
()
{
waitForElement
(
B
y
.
xpath
(
'//*[text()="test"]'
)).
then
(
function
()
{
done
();
done
();
});
});
}
}
...
@@ -135,19 +126,13 @@ describe('Application life cycle test', function () {
...
@@ -135,19 +126,13 @@ describe('Application life cycle test', function () {
done
();
done
();
}
}
xit
(
'build app'
,
function
()
{
xit
(
'build app'
,
function
()
{
execSync
(
'cloudron build'
,
EXEC_OPTIONS
);
});
execSync
(
'cloudron build'
,
EXEC_OPTIONS
);
});
it
(
'install app'
,
function
()
{
it
(
'install app'
,
function
()
{
execSync
(
`cloudron install --location
${
LOCATION
}
`
,
EXEC_OPTIONS
);
});
execSync
(
'cloudron install --new --wait --location '
+
LOCATION
,
EXEC_OPTIONS
);
});
it
(
'can get app information'
,
function
()
{
it
(
'can get app information'
,
function
()
{
var
inspect
=
JSON
.
parse
(
execSync
(
'cloudron inspect'
));
var
inspect
=
JSON
.
parse
(
execSync
(
'cloudron inspect'
));
app
=
inspect
.
apps
.
filter
(
function
(
a
)
{
return
a
.
location
===
LOCATION
;
})[
0
];
app
=
inspect
.
apps
.
filter
(
function
(
a
)
{
return
a
.
location
===
LOCATION
;
})[
0
];
expect
(
app
).
to
.
be
.
an
(
'object'
);
expect
(
app
).
to
.
be
.
an
(
'object'
);
});
});
...
@@ -159,20 +144,14 @@ describe('Application life cycle test', function () {
...
@@ -159,20 +144,14 @@ describe('Application life cycle test', function () {
it
(
'file is served up'
,
checkIndexFileIsServedUp
);
it
(
'file is served up'
,
checkIndexFileIsServedUp
);
it
(
'can upload second file'
,
uploadFile
.
bind
(
null
,
TEST_FILE_NAME_1
));
it
(
'can upload second file'
,
uploadFile
.
bind
(
null
,
TEST_FILE_NAME_1
));
it
(
'file is listed'
,
checkFileIsListed
.
bind
(
null
,
TEST_FILE_NAME_1
));
it
(
'file is listed'
,
checkFileIsListed
.
bind
(
null
,
TEST_FILE_NAME_1
));
it
(
'can delete second file with cli'
,
function
(
done
)
{
it
(
'can delete second file with cli'
,
function
()
{
execSync
(
path
.
join
(
__dirname
,
'/../cli/surfer.js'
)
+
' del '
+
TEST_FILE_NAME_1
,
{
stdio
:
'inherit'
}
);
execSync
(
path
.
join
(
__dirname
,
'/../cli/surfer.js'
)
+
' del '
+
TEST_FILE_NAME_1
,
{
stdio
:
'inherit'
}
);
done
();
});
});
it
(
'second file is gone'
,
checkFileIsGone
.
bind
(
null
,
TEST_FILE_NAME_1
));
it
(
'second file is gone'
,
checkFileIsGone
.
bind
(
null
,
TEST_FILE_NAME_1
));
it
(
'can logout'
,
logout
);
it
(
'can logout'
,
logout
);
it
(
'backup app'
,
function
()
{
it
(
'backup app'
,
function
()
{
execSync
(
`cloudron backup create --app
${
app
.
id
}
`
,
EXEC_OPTIONS
);
});
execSync
(
'cloudron backup create --app '
+
app
.
id
,
EXEC_OPTIONS
);
it
(
'restore app'
,
function
()
{
execSync
(
`cloudron restore --app
${
app
.
id
}
`
,
EXEC_OPTIONS
);
});
});
it
(
'restore app'
,
function
()
{
execSync
(
'cloudron restore --app '
+
app
.
id
,
EXEC_OPTIONS
);
});
it
(
'can login'
,
login
);
it
(
'can login'
,
login
);
it
(
'file is listed'
,
checkFileIsListed
.
bind
(
null
,
TEST_FILE_NAME_0
));
it
(
'file is listed'
,
checkFileIsListed
.
bind
(
null
,
TEST_FILE_NAME_0
));
...
@@ -186,10 +165,12 @@ describe('Application life cycle test', function () {
...
@@ -186,10 +165,12 @@ describe('Application life cycle test', function () {
// ensure we don't hit NXDOMAIN in the mean time
// ensure we don't hit NXDOMAIN in the mean time
browser
.
get
(
'about:blank'
).
then
(
function
()
{
browser
.
get
(
'about:blank'
).
then
(
function
()
{
execSync
(
'cloudron configure --location '
+
LOCATION
+
'2 --app '
+
app
.
id
,
EXEC_OPTIONS
);
execSync
(
`cloudron configure --location
${
LOCATION
}
2 --app
${
app
.
id
}
`
,
EXEC_OPTIONS
);
var
inspect
=
JSON
.
parse
(
execSync
(
'cloudron inspect'
));
var
inspect
=
JSON
.
parse
(
execSync
(
'cloudron inspect'
));
app
=
inspect
.
apps
.
filter
(
function
(
a
)
{
return
a
.
location
===
LOCATION
+
'2'
;
})[
0
];
app
=
inspect
.
apps
.
filter
(
function
(
a
)
{
return
a
.
location
===
LOCATION
+
'2'
;
})[
0
];
expect
(
app
).
to
.
be
.
an
(
'object'
);
expect
(
app
).
to
.
be
.
an
(
'object'
);
done
();
done
();
});
});
});
});
...
@@ -203,7 +184,7 @@ describe('Application life cycle test', function () {
...
@@ -203,7 +184,7 @@ describe('Application life cycle test', function () {
it
(
'uninstall app'
,
function
(
done
)
{
it
(
'uninstall app'
,
function
(
done
)
{
// ensure we don't hit NXDOMAIN in the mean time
// ensure we don't hit NXDOMAIN in the mean time
browser
.
get
(
'about:blank'
).
then
(
function
()
{
browser
.
get
(
'about:blank'
).
then
(
function
()
{
execSync
(
'cloudron uninstall --app '
+
app
.
id
,
EXEC_OPTIONS
);
execSync
(
`cloudron uninstall --app
${
app
.
id
}
`
,
EXEC_OPTIONS
);
done
();
done
();
});
});
});
});
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment