blob: 8d5a81964d840bd9507074949b6a0a52e8ea28ab [file] [log] [blame]
Marc Kupietzc4077822022-12-03 15:32:40 +01001const { doesNotMatch } = require('assert');
2const { beforeEach } = require('mocha');
3const puppeteer = require('puppeteer')
4var chai = require('chai');
5var should = chai.should();
6var assert = chai.assert;
7const KORAP_URL = process.env.KORAP_URL || "http://localhost:64543";
8const KORAP_LOGIN = process.env.KORAP_LOGIN || "user2";
9const KORAP_PWD = process.env.KORAP_PWD || "password2";
10const KORAP_QUERIES = "geht"
Marc Kupietz5e45a2f2022-12-03 15:32:40 +010011const korap_rc = require('../lib/korap_rc.js').new(KORAP_URL);
Marc Kupietzc4077822022-12-03 15:32:40 +010012
13describe('Running KorAP UI tests on ' + KORAP_URL, () => {
14 const screenshot = 'screenshot.png'
15
16 before(async () => {
17 browser = await puppeteer.launch()
18 page = await browser.newPage()
19 })
20
21 after(async () => {
22 await browser.close()
23 })
24
25 it('Login into KorAP with incorrect credentials fails',
26 (async () => {
Marc Kupietz5e45a2f2022-12-03 15:32:40 +010027 const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD + "*")
Marc Kupietzc4077822022-12-03 15:32:40 +010028 login_result.should.be.false
29 })).timeout(10000)
30
31 it('Login into KorAP with correct credentials succeeds',
32 (async () => {
Marc Kupietz5e45a2f2022-12-03 15:32:40 +010033 const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD)
Marc Kupietzc4077822022-12-03 15:32:40 +010034 login_result.should.be.true
35 })).timeout(10000)
36
37 const expected_hits = 724
38
39 it('Search for "' + KORAP_QUERIES + '" has approx. ' + expected_hits + ' hits',
40 (async () => {
Marc Kupietz5e45a2f2022-12-03 15:32:40 +010041 await korap_rc.assure_glimpse_off(page)
42 const hits = await korap_rc.search(page, KORAP_QUERIES)
Marc Kupietzc4077822022-12-03 15:32:40 +010043 await page.screenshot({ path: screenshot })
44 hits.should.be.approximately(expected_hits, 10)
45 })).timeout(20000)
46
47 it('Logout works',
48 (async () => {
Marc Kupietz5e45a2f2022-12-03 15:32:40 +010049 const logout_result = await korap_rc.logout(page)
Marc Kupietzc4077822022-12-03 15:32:40 +010050 logout_result.should.be.true
51 })).timeout(10000)
52
53})