| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 1 | const https = require('https'); |
| Marc Kupietz | d0ee97e | 2025-12-04 15:46:14 +0100 | [diff] [blame] | 2 | const crypto = require('crypto'); |
| Marc Kupietz | 490b053 | 2024-09-05 09:36:21 +0200 | [diff] [blame] | 3 | const puppeteer = require('puppeteer-extra'); |
| 4 | puppeteer.use(require('puppeteer-extra-plugin-user-preferences')({ |
| 5 | userPrefs: { |
| 6 | safebrowsing: { |
| 7 | enabled: false, |
| 8 | enhanced: false |
| 9 | } |
| 10 | } |
| 11 | })); |
| Marc Kupietz | 55fc316 | 2022-12-04 16:25:49 +0100 | [diff] [blame] | 12 | const chai = require('chai'); |
| Marc Kupietz | 4c5a7a5 | 2022-12-04 16:56:30 +0100 | [diff] [blame] | 13 | const { afterEach } = require('mocha'); |
| Marc Kupietz | 55fc316 | 2022-12-04 16:25:49 +0100 | [diff] [blame] | 14 | const assert = chai.assert; |
| 15 | const should = chai.should(); |
| Marc Kupietz | 7f1666a | 2024-07-12 18:35:31 +0200 | [diff] [blame] | 16 | var slack = null; |
| Marc Kupietz | 55fc316 | 2022-12-04 16:25:49 +0100 | [diff] [blame] | 17 | |
| Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 18 | const KORAP_URL = process.env.KORAP_URL || "http://localhost:64543"; |
| Marc Kupietz | bfb2301 | 2025-06-03 15:47:10 +0200 | [diff] [blame] | 19 | const KORAP_LOGIN = 'KORAP_USERNAME' in process.env ? process.env.KORAP_USERNAME : 'KORAP_LOGIN' in process.env ? process.env.KORAP_LOGIN : "user2" |
| 20 | const KORAP_PWD = process.env.KORAP_PWD || process.env.KORAP_PASSWORD || "password2"; |
| Marc Kupietz | 2698238 | 2022-12-04 19:02:57 +0100 | [diff] [blame] | 21 | const KORAP_QUERIES = process.env.KORAP_QUERIES || 'geht, [orth=geht & cmc/pos=VVFIN]' |
| Marc Kupietz | c8ffb2b | 2025-06-12 16:44:23 +0200 | [diff] [blame] | 22 | const KORAP_MIN_TOKENS_IN_CORPUS = parseInt(process.env.KORAP_MIN_TOKENS_IN_CORPUS || "100000", 10); |
| Marc Kupietz | 5a73a4d | 2022-12-04 14:09:58 +0100 | [diff] [blame] | 23 | const korap_rc = require('../lib/korap_rc.js').new(KORAP_URL) |
| 24 | |
| Marc Kupietz | 7f1666a | 2024-07-12 18:35:31 +0200 | [diff] [blame] | 25 | const slack_webhook = process.env.SLACK_WEBHOOK_URL; |
| Marc Kupietz | d0ee97e | 2025-12-04 15:46:14 +0100 | [diff] [blame] | 26 | const nc_talk_url = process.env.NC_TALK_URL || 'https://cloud.ids-mannheim.de'; |
| 27 | const nc_talk_conversation = process.env.NC_TALK_CONVERSATION; |
| 28 | const nc_talk_secret = process.env.NC_TALK_SECRET; |
| Marc Kupietz | 4d335a3 | 2024-09-04 16:13:48 +0200 | [diff] [blame] | 29 | |
| Marc Kupietz | 7f1666a | 2024-07-12 18:35:31 +0200 | [diff] [blame] | 30 | if (slack_webhook) { |
| 31 | slack = require('slack-notify')(slack_webhook); |
| 32 | } |
| 33 | |
| Marc Kupietz | d0ee97e | 2025-12-04 15:46:14 +0100 | [diff] [blame] | 34 | // Function to send message to Nextcloud Talk |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 35 | async function sendToNextcloudTalk(message, silent = false, screenshotPath = null) { |
| Marc Kupietz | d0ee97e | 2025-12-04 15:46:14 +0100 | [diff] [blame] | 36 | if (!nc_talk_conversation || !nc_talk_secret) { |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | try { |
| 41 | const axios = require('axios'); |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 42 | const fs = require('fs'); |
| 43 | const sharp = require('sharp'); |
| 44 | |
| 45 | let fullMessage = message; |
| 46 | const MAX_MESSAGE_LENGTH = 32000; // Nextcloud Talk message size limit |
| 47 | |
| 48 | // If a screenshot path is provided, try to embed it |
| 49 | if (screenshotPath && fs.existsSync(screenshotPath)) { |
| 50 | try { |
| 51 | // First, try to resize the image to reduce size |
| 52 | const resizedBuffer = await sharp(screenshotPath) |
| 53 | .resize(800, null, { // Resize to max width of 800px, maintain aspect ratio |
| 54 | withoutEnlargement: true, |
| 55 | fit: 'inside' |
| 56 | }) |
| 57 | .png({ quality: 80, compressionLevel: 9 }) |
| 58 | .toBuffer(); |
| 59 | |
| 60 | const base64Image = resizedBuffer.toString('base64'); |
| 61 | const dataUri = `data:image/png;base64,${base64Image}`; |
| 62 | const messageWithImage = `${message}\n\n`; |
| 63 | |
| 64 | // Check if the message with image fits within the limit |
| 65 | if (messageWithImage.length <= MAX_MESSAGE_LENGTH) { |
| 66 | fullMessage = messageWithImage; |
| 67 | console.log(`Screenshot will be embedded (message size: ${messageWithImage.length} chars)`); |
| 68 | } else { |
| 69 | console.log(`Screenshot too large (${messageWithImage.length} chars), sending text-only notification`); |
| 70 | fullMessage = `${message}\n\n_Screenshot available locally but too large to embed (${Math.round(messageWithImage.length / 1024)}KB)_`; |
| 71 | } |
| 72 | } catch (imageError) { |
| 73 | console.error('Failed to process screenshot for Nextcloud Talk:', imageError.message); |
| 74 | fullMessage = `${message}\n\n_Screenshot available locally but could not be processed_`; |
| 75 | } |
| 76 | } |
| Marc Kupietz | d0ee97e | 2025-12-04 15:46:14 +0100 | [diff] [blame] | 77 | |
| 78 | // Generate random header and signature |
| 79 | const randomHeader = crypto.randomBytes(32).toString('hex'); |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 80 | const messageToSign = randomHeader + fullMessage; |
| Marc Kupietz | d0ee97e | 2025-12-04 15:46:14 +0100 | [diff] [blame] | 81 | const signature = crypto.createHmac('sha256', nc_talk_secret) |
| 82 | .update(messageToSign) |
| 83 | .digest('hex'); |
| 84 | |
| 85 | // Send the message |
| 86 | await axios.post( |
| 87 | `${nc_talk_url}/ocs/v2.php/apps/spreed/api/v1/bot/${nc_talk_conversation}/message`, |
| 88 | { |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 89 | message: fullMessage, |
| Marc Kupietz | d0ee97e | 2025-12-04 15:46:14 +0100 | [diff] [blame] | 90 | silent: silent |
| 91 | }, |
| 92 | { |
| 93 | headers: { |
| 94 | 'Content-Type': 'application/json', |
| 95 | 'Accept': 'application/json', |
| 96 | 'OCS-APIRequest': 'true', |
| 97 | 'X-Nextcloud-Talk-Bot-Random': randomHeader, |
| 98 | 'X-Nextcloud-Talk-Bot-Signature': signature |
| 99 | } |
| 100 | } |
| 101 | ); |
| 102 | console.log('Message sent to Nextcloud Talk successfully'); |
| 103 | } catch (error) { |
| 104 | console.error('Failed to send message to Nextcloud Talk:', error.message); |
| 105 | } |
| 106 | } |
| 107 | |
| Marc Kupietz | 5a73a4d | 2022-12-04 14:09:58 +0100 | [diff] [blame] | 108 | function ifConditionIt(title, condition, test) { |
| Marc Kupietz | 55fc316 | 2022-12-04 16:25:49 +0100 | [diff] [blame] | 109 | return condition ? it(title, test) : it.skip(title + " (skipped)", test) |
| Marc Kupietz | 5a73a4d | 2022-12-04 14:09:58 +0100 | [diff] [blame] | 110 | } |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 111 | |
| Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 112 | describe('Running KorAP UI end-to-end tests on ' + KORAP_URL, () => { |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 113 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 114 | let browser; |
| 115 | let page; |
| 116 | |
| 117 | |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 118 | before(async () => { |
| Marc Kupietz | 69e0280 | 2023-11-08 14:37:22 +0100 | [diff] [blame] | 119 | browser = await puppeteer.launch({ |
| Marc Kupietz | bfb2301 | 2025-06-03 15:47:10 +0200 | [diff] [blame] | 120 | headless: "shell", |
| 121 | args: [ |
| 122 | '--no-sandbox', |
| 123 | '--disable-setuid-sandbox', |
| 124 | '--disable-dev-shm-usage', |
| 125 | '--disable-accelerated-2d-canvas', |
| 126 | '--no-first-run', |
| 127 | '--no-zygote', |
| 128 | '--disable-gpu' |
| 129 | ] |
| Marc Kupietz | 69e0280 | 2023-11-08 14:37:22 +0100 | [diff] [blame] | 130 | }) |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 131 | page = await browser.newPage() |
| Marc Kupietz | 4c5a7a5 | 2022-12-04 16:56:30 +0100 | [diff] [blame] | 132 | await page.setViewport({ |
| Marc Kupietz | 9e0f519 | 2025-03-09 12:12:16 +0100 | [diff] [blame] | 133 | width: 1980, |
| Marc Kupietz | 4c5a7a5 | 2022-12-04 16:56:30 +0100 | [diff] [blame] | 134 | height: 768, |
| 135 | deviceScaleFactor: 1, |
| Marc Kupietz | 964e777 | 2025-06-03 15:02:30 +0200 | [diff] [blame] | 136 | }); |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 137 | |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 138 | }) |
| 139 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 140 | after(async function() { |
| 141 | if (browser && typeof browser.close === 'function') { |
| 142 | await browser.close(); |
| 143 | } |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 144 | }) |
| 145 | |
| Marc Kupietz | 4c5a7a5 | 2022-12-04 16:56:30 +0100 | [diff] [blame] | 146 | afterEach(async function () { |
| 147 | if (this.currentTest.state == "failed") { |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 148 | // Only take screenshot if it's not one of the initial connectivity/SSL tests |
| 149 | const initialTestTitles = [ |
| 150 | 'should be reachable', |
| 151 | 'should have a valid SSL certificate' |
| 152 | ]; |
| 153 | let screenshotPath = null; |
| 154 | |
| 155 | if (!initialTestTitles.includes(this.currentTest.title) && page) { |
| 156 | screenshotPath = "failed_" + this.currentTest.title.replaceAll(/[ &\/]/g, "_") + '.png'; |
| 157 | await page.screenshot({ path: screenshotPath }); |
| 158 | } |
| 159 | |
| 160 | // Send notification to Slack |
| Marc Kupietz | 7f1666a | 2024-07-12 18:35:31 +0200 | [diff] [blame] | 161 | if (slack) { |
| Marc Kupietz | 8f7c204 | 2025-06-24 09:55:03 +0200 | [diff] [blame] | 162 | try { |
| Marc Kupietz | 8f7c204 | 2025-06-24 09:55:03 +0200 | [diff] [blame] | 163 | slack.alert({ |
| 164 | text: `🚨 Test on ${KORAP_URL} failed: *${this.currentTest.title}*`, |
| 165 | attachments: [{ |
| 166 | color: 'danger', |
| 167 | fields: [{ |
| 168 | title: 'Failed Test', |
| 169 | value: this.currentTest.title, |
| 170 | short: false |
| 171 | }, { |
| 172 | title: 'URL', |
| 173 | value: KORAP_URL, |
| 174 | short: true |
| 175 | }] |
| 176 | }] |
| 177 | }); |
| 178 | } catch (slackError) { |
| 179 | console.error('Failed to send notification to Slack:', slackError.message); |
| 180 | } |
| 181 | } |
| 182 | |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 183 | // Upload screenshot to Slack if available |
| 184 | if (screenshotPath) { |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 185 | const slackToken = process.env.SLACK_TOKEN; |
| 186 | if (slackToken) { |
| 187 | try { |
| 188 | const { WebClient } = require('@slack/web-api'); |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 189 | const fs = require('fs'); |
| 190 | const web = new WebClient(slackToken); |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 191 | const channelId = process.env.SLACK_CHANNEL_ID || 'C07CM4JS48H'; |
| Marc Kupietz | 8f7c204 | 2025-06-24 09:55:03 +0200 | [diff] [blame] | 192 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 193 | const result = await web.files.uploadV2({ |
| 194 | channel_id: channelId, |
| 195 | file: fs.createReadStream(screenshotPath), |
| 196 | filename: screenshotPath, |
| 197 | title: `Screenshot: ${this.currentTest.title}`, |
| 198 | initial_comment: `📸 Screenshot of failed test: ${this.currentTest.title} on ${KORAP_URL}` |
| 199 | }); |
| Marc Kupietz | 8f7c204 | 2025-06-24 09:55:03 +0200 | [diff] [blame] | 200 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 201 | } catch (uploadError) { |
| 202 | console.error('Failed to upload screenshot to Slack:', uploadError.message); |
| 203 | } |
| Marc Kupietz | 8f7c204 | 2025-06-24 09:55:03 +0200 | [diff] [blame] | 204 | } |
| Marc Kupietz | 7f1666a | 2024-07-12 18:35:31 +0200 | [diff] [blame] | 205 | } |
| Marc Kupietz | 65dea51 | 2025-12-04 17:55:57 +0100 | [diff] [blame^] | 206 | |
| 207 | // Send notification to Nextcloud Talk with screenshot |
| 208 | if (nc_talk_conversation && nc_talk_secret) { |
| 209 | try { |
| 210 | const message = `🚨 Test on ${KORAP_URL} failed: **${this.currentTest.title}**`; |
| 211 | await sendToNextcloudTalk(message, false, screenshotPath); |
| 212 | } catch (ncError) { |
| 213 | console.error('Failed to send notification to Nextcloud Talk:', ncError.message); |
| 214 | } |
| 215 | } |
| Marc Kupietz | 4c5a7a5 | 2022-12-04 16:56:30 +0100 | [diff] [blame] | 216 | } |
| Marc Kupietz | 964e777 | 2025-06-03 15:02:30 +0200 | [diff] [blame] | 217 | }) |
| Marc Kupietz | 4c5a7a5 | 2022-12-04 16:56:30 +0100 | [diff] [blame] | 218 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 219 | it('should be reachable', function (done) { |
| 220 | let doneCalled = false; |
| 221 | const url = new URL(KORAP_URL); |
| 222 | const httpModule = url.protocol === 'https:' ? https : require('http'); |
| Marc Kupietz | 5a73a4d | 2022-12-04 14:09:58 +0100 | [diff] [blame] | 223 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 224 | const req = httpModule.request({ |
| 225 | method: 'HEAD', |
| 226 | hostname: url.hostname, |
| 227 | port: url.port || (url.protocol === 'https:' ? 443 : 80), |
| 228 | path: url.pathname, |
| 229 | timeout: 5000 |
| 230 | }, res => { |
| 231 | if (!doneCalled) { |
| 232 | doneCalled = true; |
| 233 | if (res.statusCode >= 200 && res.statusCode < 400) { |
| 234 | done(); |
| 235 | } else { |
| 236 | done(new Error(`Server is not reachable. Status code: ${res.statusCode}`)); |
| 237 | } |
| 238 | } |
| 239 | }); |
| 240 | req.on('timeout', () => { |
| 241 | if (!doneCalled) { |
| 242 | doneCalled = true; |
| 243 | req.destroy(); |
| 244 | done(new Error('Request to server timed out.')); |
| 245 | } |
| 246 | }); |
| 247 | req.on('error', err => { |
| 248 | if (!doneCalled) { |
| 249 | doneCalled = true; |
| 250 | done(err); |
| 251 | } |
| 252 | }); |
| 253 | req.end(); |
| 254 | }); |
| Marc Kupietz | 5a73a4d | 2022-12-04 14:09:58 +0100 | [diff] [blame] | 255 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 256 | it('should have a valid SSL certificate', function (done) { |
| 257 | let doneCalled = false; |
| 258 | const url = new URL(KORAP_URL); |
| 259 | if (url.protocol !== 'https:') { |
| 260 | return this.skip(); |
| 261 | } |
| 262 | const req = https.request({ |
| 263 | method: 'HEAD', |
| 264 | hostname: url.hostname, |
| 265 | port: url.port || 443, |
| 266 | path: url.pathname, |
| 267 | timeout: 5000 |
| 268 | }, res => { |
| 269 | if (!doneCalled) { |
| 270 | doneCalled = true; |
| 271 | const cert = res.socket.getPeerCertificate(); |
| 272 | if (cert && cert.valid_to) { |
| 273 | const validTo = new Date(cert.valid_to); |
| 274 | if (validTo > new Date()) { |
| 275 | done(); |
| 276 | } else { |
| 277 | done(new Error(`SSL certificate expired on ${validTo.toDateString()}`)); |
| 278 | } |
| 279 | } else if (res.socket.isSessionReused()){ |
| 280 | done(); |
| 281 | } |
| 282 | else { |
| 283 | done(new Error('Could not retrieve SSL certificate information.')); |
| 284 | } |
| 285 | } |
| 286 | }); |
| 287 | req.on('timeout', () => { |
| 288 | if (!doneCalled) { |
| 289 | doneCalled = true; |
| 290 | req.destroy(); |
| 291 | done(new Error('Request to server timed out.')); |
| 292 | } |
| 293 | }); |
| 294 | req.on('error', err => { |
| 295 | if (!doneCalled) { |
| 296 | doneCalled = true; |
| 297 | if (err.code === 'CERT_HAS_EXPIRED') { |
| 298 | done(new Error('SSL certificate has expired.')); |
| 299 | } else { |
| 300 | done(err); |
| 301 | } |
| 302 | } |
| 303 | }); |
| 304 | req.end(); |
| 305 | }); |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 306 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 307 | describe('UI Tests', function() { |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 308 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 309 | before(function() { |
| 310 | // Check the state of the parent suite's tests |
| 311 | const initialTests = this.test.parent.parent.tests; |
| 312 | if (initialTests[0].state === 'failed' || initialTests[1].state === 'failed') { |
| 313 | this.skip(); |
| 314 | } |
| 315 | }); |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 316 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 317 | |
| Marc Kupietz | c8ffb2b | 2025-06-12 16:44:23 +0200 | [diff] [blame] | 318 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 319 | it('KorAP UI is up and running', async function () { |
| 320 | try { |
| 321 | await page.goto(KORAP_URL, { waitUntil: 'domcontentloaded' }); |
| 322 | await page.waitForSelector("#q-field", { visible: true }); |
| 323 | const query_field = await page.$("#q-field") |
| 324 | assert.isNotNull(query_field, "#q-field not found. Kalamar not running?"); |
| 325 | } catch (error) { |
| 326 | throw new Error(`Failed to load KorAP UI or find query field: ${error.message}`); |
| 327 | } |
| Marc Kupietz | 0f6c54d | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 328 | }) |
| Marc Kupietz | 5a73a4d | 2022-12-04 14:09:58 +0100 | [diff] [blame] | 329 | |
| Marc Kupietz | c407782 | 2022-12-03 15:32:40 +0100 | [diff] [blame] | 330 | |
| Marc Kupietz | 93d7f70 | 2025-06-27 15:41:48 +0200 | [diff] [blame] | 331 | ifConditionIt('Login into KorAP with incorrect credentials fails', |
| 332 | KORAP_LOGIN != "", |
| 333 | (async () => { |
| 334 | const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD + "*") |
| 335 | login_result.should.be.false |
| 336 | })) |
| 337 | |
| 338 | ifConditionIt('Login into KorAP with correct credentials succeeds', |
| 339 | KORAP_LOGIN != "", |
| 340 | (async () => { |
| 341 | const login_result = await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD) |
| 342 | login_result.should.be.true |
| 343 | })) |
| 344 | |
| 345 | it('Can turn glimpse off', |
| 346 | (async () => { |
| 347 | await korap_rc.assure_glimpse_off(page) |
| 348 | })) |
| 349 | |
| 350 | it('Corpus statistics show sufficient tokens', |
| 351 | (async () => { |
| 352 | const tokenCount = await korap_rc.check_corpus_statistics(page, KORAP_MIN_TOKENS_IN_CORPUS); |
| 353 | console.log(`Found ${tokenCount} tokens in corpus, minimum required: ${KORAP_MIN_TOKENS_IN_CORPUS}`); |
| 354 | tokenCount.should.be.above(KORAP_MIN_TOKENS_IN_CORPUS - 1, |
| 355 | `Corpus should have at least ${KORAP_MIN_TOKENS_IN_CORPUS} tokens, but found ${tokenCount}`); |
| 356 | })).timeout(90000) |
| 357 | |
| 358 | describe('Running searches that should have hits', () => { |
| 359 | |
| 360 | before(async () => { await korap_rc.login(page, KORAP_LOGIN, KORAP_PWD) }) |
| 361 | |
| 362 | KORAP_QUERIES.split(/[;,] */).forEach((query, i) => { |
| 363 | it('Search for "' + query + '" has hits', |
| 364 | (async () => { |
| 365 | await korap_rc.assure_glimpse_off(page) |
| 366 | const hits = await korap_rc.search(page, query) |
| 367 | hits.should.be.above(0) |
| 368 | })).timeout(20000) |
| 369 | }) |
| 370 | }) |
| 371 | |
| 372 | ifConditionIt('Logout works', |
| 373 | KORAP_LOGIN != "", |
| 374 | (async () => { |
| 375 | const logout_result = await korap_rc.logout(page) |
| 376 | logout_result.should.be.true |
| 377 | })).timeout(15000) |
| 378 | }); |
| 379 | }); |