Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 1 | const { doesNotMatch } = require('assert'); |
| 2 | const { beforeEach } = require('mocha'); |
| 3 | const puppeteer = require('puppeteer') |
| 4 | var chai = require('chai'); |
| 5 | var should = chai.should(); |
| 6 | var assert = chai.assert; |
Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame^] | 7 | const KORAP_URL = process.env.KORAP_URL || "http://localhost:64543"; |
| 8 | const KORAP_LOGIN = process.env.KORAP_LOGIN || "user2"; |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 9 | const KORAP_PWD = process.env.KORAP_PWD || "password2"; |
Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame^] | 10 | const KORAP_QUERIES = 'geht, [orth=geht & cmc/pos=VVFIN]' |
Marc Kupietz | 5e45a2f | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 11 | const korap_rc = require('../lib/korap_rc.js').new(KORAP_URL); |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 12 | |
Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame^] | 13 | describe('Running KorAP UI end-to-end tests on ' + KORAP_URL, () => { |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 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 Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame^] | 27 | const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD + "*") |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 28 | login_result.should.be.false |
| 29 | })).timeout(10000) |
| 30 | |
| 31 | it('Login into KorAP with correct credentials succeeds', |
| 32 | (async () => { |
Marc Kupietz | 5e45a2f | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 33 | const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD) |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 34 | login_result.should.be.true |
| 35 | })).timeout(10000) |
| 36 | |
Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame^] | 37 | it('Can turn glimpse off', |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 38 | (async () => { |
Marc Kupietz | 5e45a2f | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 39 | await korap_rc.assure_glimpse_off(page) |
Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame^] | 40 | })).timeout(10000) |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 41 | |
Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame^] | 42 | 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 Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 53 | it('Logout works', |
| 54 | (async () => { |
Marc Kupietz | 5e45a2f | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 55 | const logout_result = await korap_rc.logout(page) |
Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 56 | logout_result.should.be.true |
| 57 | })).timeout(10000) |
| 58 | |
| 59 | }) |