cicd: Reduce test flake and add lots more debugging info (#290)

This commit is contained in:
James Read 2024-04-24 16:22:15 +01:00 committed by GitHub
parent a3aee3603f
commit 318d4fe0d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 5 deletions

View File

@ -0,0 +1,3 @@
logLevel: DEBUG
authHttpHeaderUsername: "X-User"

View File

@ -78,8 +78,14 @@ class OliveTinTestRunnerStartLocalProcess extends OliveTinTestRunner {
}
async stop () {
await this.ot.kill()
console.log(" OliveTin local process killed")
if ((await this.ot.exitCode) != null) {
console.log(" OliveTin local process tried stop(), but it already exited with code", this.ot.exitCode)
} else {
await this.ot.kill()
console.log(" OliveTin local process killed")
}
await new Promise((res) => setTimeout(res, 100))
}
}

View File

@ -2,7 +2,7 @@ import { describe, it, before, after } from 'mocha'
import { expect } from 'chai'
import { By, until, Condition } from 'selenium-webdriver'
//import * as waitOn from 'wait-on'
import { getRootAndWait } from '../lib/elements.js'
import { getRootAndWait, getActionButtons } from '../lib/elements.js'
describe('config: general', function () {
before(async function () {
@ -39,7 +39,7 @@ describe('config: general', function () {
it('Default buttons are rendered', async function() {
await getRootAndWait()
const buttons = await webdriver.findElement(By.id('root-group')).findElements(By.tagName('button'))
const buttons = await getActionButtons(webdriver)
expect(buttons).to.have.length(8)
})
@ -69,7 +69,7 @@ describe('config: general', function () {
})
it('Start date action (passive)', async function() {
await webdriver.get(runner.baseUrl())
await getRootAndWait()
const buttons = await webdriver.findElements(By.css('[title="date-passive"]'))

View File

@ -0,0 +1,32 @@
import { expect } from 'chai'
describe('config: trustedHeader', function () {
before(async function () {
await runner.start('trustedHeader')
})
after(async () => {
await runner.stop()
})
it('req with X-User', async () => {
const req = await fetch(runner.baseUrl() + '/api/WhoAmI', {
headers: {
"X-User": "fred",
}
})
if (!req.ok) {
console.log(req)
}
expect(req.ok, 'WhoAmI Request is ' + req.status).to.be.true
const json = await req.json()
expect(json).to.not.be.null
expect(json).to.have.own.property('authenticatedUser')
expect(json['authenticatedUser']).to.be.equal('fred')
})
})