Commit c7a742ea authored by Johannes Zellner's avatar Johannes Zellner

Fixup tests for new UI

The current update test will fail, since it reuses the same functions,
which are now tailored for the new UI
parent 030a9c4d
......@@ -21,6 +21,8 @@ selenium.promise.USE_PROMISE_MANAGER = false
const VPN_TCP_PORT = 7333
const DEVICE_NAME = 'test_DeV1ce-3'
if (!process.env.CLOUDRON_USERNAME || !process.env.CLOUDRON_PASSWORD) {
console.log('CLOUDRON_USERNAME and CLOUDRON_PASSWORD env vars need to be set')
process.exit(1)
......@@ -65,40 +67,39 @@ describe('Application life cycle test', function () {
.then(() => console.log('Cookies deleted'))
.then(() => browser.get('https://' + app.fqdn))
.then(() => console.log('Page loaded'))
.then(() => waitForElement(by.id('loginButton')))
.then(() => browser.wait(until.elementLocated(by.id('loginUsername')), TEST_TIMEOUT))
.then(() => console.log('Login page loaded'))
.then(() => browser.findElement(by.id('loginUsername')).sendKeys(username))
.then(() => browser.findElement(by.id('loginPassword')).sendKeys(password))
.then(() => browser.findElement(by.id('loginButton')).click())
.then(() => console.log('Login clicked'))
.then(() => browser.wait(() => browser.getCurrentUrl().then(url => url.indexOf('/api/v1/session/login') !== -1), TEST_TIMEOUT))
.then(() => browser.wait(until.elementLocated(by.id('inputUsername')), TEST_TIMEOUT))
.then(() => console.log('Login page loaded'))
.then(() => browser.findElement(by.id('inputUsername')).sendKeys(username))
.then(() => browser.findElement(by.id('inputPassword')).sendKeys(password))
.then(() => browser.findElement(by.tagName('form')).submit())
.then(() => console.log('Login submitted'))
.then(() => browser.wait(until.elementLocated(by.id('logoutButton')), TEST_TIMEOUT))
.then(() => console.log('Logged in'))
}
function logout () {
console.log('Logging out...')
browser.get('https://' + app.fqdn)
return browser.findElement(by.id('logoutButton')).click()
return waitForElement(by.id('logoutButton'))
.then(() => browser.findElement(by.id('logoutButton')).click())
.then(() => waitForElement(by.id('loginButton')))
.then(() => console.log('Logged out'))
}
function createDevice (name) {
console.log('Creating device...')
return browser.findElement(by.xpath('//button[text()="New Device"]')).click()
.then(() => waitForElement(by.xpath('//input[@id="createKeyData"]')))
.then(() => browser.findElement(by.xpath('//input[@id="createKeyData"]')).sendKeys(name))
.then(() => browser.findElement(by.xpath('//button[text()="Create"]')).click())
return waitForElement(by.id('newDeviceButton'))
.then(() => browser.findElement(by.id('newDeviceButton')).click())
.then(() => console.log('Open Dialog'))
.then(() => waitForElement(by.xpath('/html/body/div[2]/div/div[2]/div/div[1]/input')))
.then(() => browser.findElement(by.xpath('/html/body/div[2]/div/div[2]/div/div[1]/input')).sendKeys(name))
.then(() => browser.findElement(by.xpath('/html/body/div[2]/div/div[3]/button[2]')).click())
.then(() => console.log('Device created'))
}
function checkDeviceExists (name) {
return browser.wait(until.elementLocated(by.xpath(`//tr/td[text()="${name}"]`)), TEST_TIMEOUT)
return browser.wait(until.elementLocated(by.xpath(`//div[text()="${name}"]`)), TEST_TIMEOUT)
}
function checkVpn (done) {
......@@ -122,8 +123,8 @@ describe('Application life cycle test', function () {
it('can get app information', getAppInfo)
it('can login', login)
it('can create device', () => createDevice('testdevice'))
it('device exists', () => checkDeviceExists('testdevice'))
it('can create device', () => createDevice(DEVICE_NAME))
it('device exists', () => checkDeviceExists(DEVICE_NAME))
it('check vpn', checkVpn)
it('can logout', logout)
......@@ -132,7 +133,7 @@ describe('Application life cycle test', function () {
})
it('can login', login)
it('device exists', () => checkDeviceExists('testdevice'))
it('device exists', () => checkDeviceExists(DEVICE_NAME))
it('check vpn', checkVpn)
it('can logout', logout)
......@@ -145,7 +146,7 @@ describe('Application life cycle test', function () {
})
it('can login', login)
it('device exists', () => checkDeviceExists('testdevice'))
it('device exists', () => checkDeviceExists(DEVICE_NAME))
it('check vpn', checkVpn)
it('can logout', logout)
......@@ -158,7 +159,7 @@ describe('Application life cycle test', function () {
it('can get new app information', getAppInfo)
it('can login', login)
it('device exists', () => checkDeviceExists('testdevice'))
it('device exists', () => checkDeviceExists(DEVICE_NAME))
it('check vpn', checkVpn)
it('can logout', logout)
......@@ -176,8 +177,8 @@ describe('Application life cycle test', function () {
it('can get app information', getAppInfo)
it('can login', login)
it('can create device', () => createDevice('testdevice'))
it('device exists', () => checkDeviceExists('testdevice'))
it('can create device', () => createDevice(DEVICE_NAME))
it('device exists', () => checkDeviceExists(DEVICE_NAME))
it('can logout', logout)
it('can update', function () {
......@@ -185,7 +186,7 @@ describe('Application life cycle test', function () {
})
it('can login', login)
it('device exists', () => checkDeviceExists('testdevice'))
it('device exists', () => checkDeviceExists(DEVICE_NAME))
it('check vpn', checkVpn)
it('can logout', logout)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment