-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1780 from openzim/treatment-sequence
Treat hidden DOM elements before treating media files.
- Loading branch information
Showing
2 changed files
with
51 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`) | ||
}) | ||
}) |