Clean up code
Change-Id: I286c0dc736af9a9b9b18dba3a6354e0e4cf5ae1d
diff --git a/test/korap-ui.js b/test/korap-ui.js
index bb5e293..79bd0b0 100644
--- a/test/korap-ui.js
+++ b/test/korap-ui.js
@@ -1,20 +1,19 @@
-const { beforeEach } = require('mocha');
const puppeteer = require('puppeteer')
-var chai = require('chai');
-const { expect, assert } = require('chai');
-var should = chai.should();
+const chai = require('chai');
+const assert = chai.assert;
+const should = chai.should();
+
const KORAP_URL = process.env.KORAP_URL || "http://localhost:64543";
-const KORAP_LOGIN = (process.env.KORAP_LOGIN || process.env.KORAP_LOGIN == "" ? process.env.KORAP_LOGIN : "user2")
+const KORAP_LOGIN = 'KORAP_LOGIN' in process.env ? process.env.KORAP_LOGIN : "user2"
const KORAP_PWD = process.env.KORAP_PWD || "password2";
const KORAP_QUERIES = 'geht, [orth=geht & cmc/pos=VVFIN]'
const korap_rc = require('../lib/korap_rc.js').new(KORAP_URL)
function ifConditionIt(title, condition, test) {
- return condition ? it(title, test) : it.skip(title, test)
+ return condition ? it(title, test) : it.skip(title + " (skipped)", test)
}
describe('Running KorAP UI end-to-end tests on ' + KORAP_URL, () => {
- const screenshot = 'screenshot.png'
before(async () => {
browser = await puppeteer.launch()
@@ -30,7 +29,7 @@
await await page.goto(KORAP_URL);
const query_field = await page.$("#q-field")
assert.isNotNull(query_field, "#q-field not found. Kalamar not running?");
- })).timeout(10000)
+ }))
ifConditionIt('Login into KorAP with incorrect credentials fails',
@@ -38,21 +37,24 @@
(async () => {
const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD + "*")
login_result.should.be.false
- })).timeout(10000)
+ }))
ifConditionIt('Login into KorAP with correct credentials succeeds',
KORAP_LOGIN != "",
(async () => {
const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD)
login_result.should.be.true
- })).timeout(10000)
+ }))
it('Can turn glimpse off',
(async () => {
await korap_rc.assure_glimpse_off(page)
- })).timeout(10000)
+ }))
describe('Running searches that should have hits', () => {
+
+ before(async () => { await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD) })
+
KORAP_QUERIES.split(/[;,] */).forEach((query, i) => {
it('Search for "' + query + '" has hits',
(async () => {
@@ -68,6 +70,6 @@
(async () => {
const logout_result = await korap_rc.logout(page)
logout_result.should.be.true
- })).timeout(10000)
+ }))
-})
\ No newline at end of file
+})