Skip to content

Commit

Permalink
Added test to check if media files are not downloading from hidden el…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
pavel-karatsiuba authored and kelson42 committed Feb 18, 2023
1 parent e350e43 commit 08d56d8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/e2e/treatMedia.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as mwoffliner from '../../src/mwoffliner.lib.js'
import { execa } from 'execa'
import rimraf from 'rimraf'
import { zimdumpAvailable, zimdump } from '../util.js'
import 'dotenv/config'
import { jest } from '@jest/globals'

jest.setTimeout(20000)

describe('treatment test', () => {
const now = new Date()
const testId = `mwo-test-${+now}`

const articleList = 'Read_my_lips:_no_new_taxes'
const parameters = {
mwUrl: 'https://en.wikipedia.org',
adminEmail: '[email protected]',
articleList,
outputDirectory: testId,
redis: process.env.REDIS,
}

test('media file from hidden element should not be downloaded', async () => {
await execa('redis-cli flushall', { shell: true })

const outFiles = await mwoffliner.execute(parameters)
// Created 1 output
expect(outFiles).toHaveLength(1)

if (await zimdumpAvailable()) {
await expect(zimdump(`list --url "I/George_Bush_1988_No_New_Taxes.ogg" ${outFiles[0].outFile}`)).rejects.toThrow('Entry not found')
} else {
console.log('Zimdump not installed, skipping test')
}

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

0 comments on commit 08d56d8

Please sign in to comment.