Skip to content

Commit

Permalink
Quick fix for the forceRender test
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimKovalenkoSNF committed Nov 13, 2023
1 parent bbea9d7 commit 5c45741
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions test/e2e/forceRender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ describe('forceRender', () => {
mwActionApiPath: 'w/api.php',
}

beforeAll(async () => {
afterAll(async () => {
await execa('redis-cli flushall', { shell: true })
rimraf.sync(`./${testId}`)
const redisScan = await execa('redis-cli --scan', { shell: true })
// Redis has been cleared
expect(redisScan.stdout).toEqual('')
})

test('Scrape article from bm.wikipedia.org using WikimediaDesktop render', async () => {
Expand All @@ -33,24 +37,23 @@ describe('forceRender', () => {
} 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('')
})

test('Scrape article from bm.wikipedia.org should throw error when using VisualEditor render', async () => {
const forceRender = 'VisualEditor'
expect(async () => {
try {
await mwoffliner.execute({ ...parameters, forceRender })
}).rejects.toThrowError()
} catch (err) {
expect(err).toReturn()
}
})

test('Scrape article from bm.wikipedia.org should throw error when using wrong render', async () => {
const forceRender = 'unknownRenderName'
expect(async () => {
try {
await mwoffliner.execute({ ...parameters, forceRender })
}).rejects.toThrowError()
} catch (err) {
expect(err.message).toEqual('Unable to find specific API end-point to retrieve article HTML')
}
})
})

0 comments on commit 5c45741

Please sign in to comment.