blob: 467bb044cf037b8337835a301146194ddf12d4ae [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;
Marc Kupietz0f6c54d2022-12-03 15:32:40 +01007const KORAP_URL = process.env.KORAP_URL || "http://localhost:64543";
8const KORAP_LOGIN = process.env.KORAP_LOGIN || "user2";
Marc Kupietzc4077822022-12-03 15:32:40 +01009const KORAP_PWD = process.env.KORAP_PWD || "password2";
Marc Kupietz0f6c54d2022-12-03 15:32:40 +010010const KORAP_QUERIES = 'geht, [orth=geht & cmc/pos=VVFIN]'
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
Marc Kupietz0f6c54d2022-12-03 15:32:40 +010013describe('Running KorAP UI end-to-end tests on ' + KORAP_URL, () => {
Marc Kupietzc4077822022-12-03 15:32:40 +010014 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 Kupietz0f6c54d2022-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
Marc Kupietz0f6c54d2022-12-03 15:32:40 +010037 it('Can turn glimpse off',
Marc Kupietzc4077822022-12-03 15:32:40 +010038 (async () => {
Marc Kupietz5e45a2f2022-12-03 15:32:40 +010039 await korap_rc.assure_glimpse_off(page)
Marc Kupietz0f6c54d2022-12-03 15:32:40 +010040 })).timeout(10000)
Marc Kupietzc4077822022-12-03 15:32:40 +010041
Marc Kupietz0f6c54d2022-12-03 15:32:40 +010042 const expected_hits = 724
43 describe('Running searches that should have hits', () => {
44 KORAP_QUERIES.split(/[;,] */).forEach((query, i) => {
45 it('Search for "' + query + '" has hits',
46 (async () => {
47 await korap_rc.assure_glimpse_off(page)
48 const hits = await korap_rc.search(page, query)
49 hits.should.be.above(0)
50 })).timeout(20000)
51 })
52 })
Marc Kupietzc4077822022-12-03 15:32:40 +010053 it('Logout works',
54 (async () => {
Marc Kupietz5e45a2f2022-12-03 15:32:40 +010055 const logout_result = await korap_rc.logout(page)
Marc Kupietzc4077822022-12-03 15:32:40 +010056 logout_result.should.be.true
57 })).timeout(10000)
58
59})