Skip to content

Commit

Permalink
Add e2e test for optimisationCacheUrl parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimKovalenkoSNF committed Sep 13, 2023
1 parent 5a17fee commit 75e4fea
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/e2e/downloadImage.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as mwoffliner from '../../src/mwoffliner.lib.js'
import { execa } from 'execa'
import rimraf from 'rimraf'
import { zimcheckAvailable, zimcheck } from '../util.js'
import 'dotenv/config.js'
import { jest } from '@jest/globals'

jest.setTimeout(200000)

const describeIf = process.env.S3_URL ? describe : describe.skip
describeIf('Check image downloading from S3 using optimisationCacheUrl parameter', () => {
const now = new Date()
const testId = `mwo-test-${+now}`

const parameters = {
mwUrl: 'https://fr.wikipedia.org',
adminEmail: 'test@kiwix.org',
outputDirectory: testId,
redis: process.env.REDIS,
articleList: 'Paris',
format: ['nodet'],
optimisationCacheUrl: process.env.S3_URL,
}

test('right scrapping from fr.wikipedia.org with optimisationCacheUrl parameter', async () => {
await execa('redis-cli flushall', { shell: true })

const outFiles = await mwoffliner.execute(parameters)

if (await zimcheckAvailable()) {
await expect(zimcheck(outFiles[0].outFile)).resolves.not.toThrowError()
} else {
console.log('Zimcheck not installed, skipping test')
}

rimraf.sync(`./${testId}`)

const redisScan = await execa('redis-cli --scan', { shell: true })
// Redis has been cleared
expect(redisScan.stdout).toEqual('')
})
})

0 comments on commit 75e4fea

Please sign in to comment.