forked from UniversalViewer/universalviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,20 @@ | ||
test.skip('Configuration options', () => {}); | ||
|
||
const puppeteer = require('puppeteer'); | ||
|
||
describe('Universal Viewer', () => { | ||
let browser; | ||
let page; | ||
|
||
beforeAll(async () => { | ||
browser = await puppeteer.launch(); | ||
page = await browser.newPage(); | ||
await page.goto('http://localhost:8080/#?xywh=-1741%2C125%2C8017%2C6807&iiifManifestId=http%3A%2F%2Fiiif.bodleian.ox.ac.uk%2Fexamples%2Fmushaf4.json'); | ||
await page.goto('http://localhost:4444/'); | ||
}); | ||
|
||
afterAll(async () => { | ||
await browser.close(); | ||
}); | ||
|
||
it('has the correct page title', async () => { | ||
const title = await page.title(); | ||
expect(title).toBe('Universal Viewer Examples'); | ||
}); | ||
|
||
it('can toggle thumbnail label truncation', async () => { | ||
await page.waitForSelector('#truncateThumbnailLabels'); | ||
|
||
const isCheckedBeforeToggle = await page.$eval('#truncateThumbnailLabels', checkbox => checkbox.checked); | ||
expect(isCheckedBeforeToggle).toBe(true); | ||
|
||
const labelOverflowBeforeToggle = await page.evaluate(() => { | ||
const label = document.querySelector('.thumbsView .thumbs .thumb .info .label'); | ||
return getComputedStyle(label).overflowX; | ||
}); | ||
expect(labelOverflowBeforeToggle).toBe('hidden'); | ||
|
||
await page.evaluate(() => { | ||
document.querySelector('#truncateThumbnailLabels').click(); | ||
}); | ||
|
||
const isCheckedAfterToggle = await page.$eval('#truncateThumbnailLabels', checkbox => checkbox.checked); | ||
expect(isCheckedAfterToggle).toBe(false); | ||
|
||
const labelOverflowAfterToggle = await page.evaluate(() => { | ||
const label = document.querySelector('.thumbsView .thumbs .thumb .info .label'); | ||
return getComputedStyle(label).overflowX; | ||
}); | ||
expect(labelOverflowAfterToggle).toBe('visible'); | ||
it('loads the viewer images', async () => { | ||
await page.waitForSelector('#thumb-0'); | ||
const imageSrc = await page.$eval('#thumb-0 img', e => e.src); | ||
expect(imageSrc).toEqual( | ||
expect.stringContaining( | ||
'https://iiif.wellcomecollection.org/image/b18035723_0001.JP2/full/90,/0/default.jpg' | ||
) | ||
); | ||
}); | ||
|
||
it('settings button is visible', async () => { | ||
|
||
await page.waitForSelector('.btn.imageBtn.settings'); | ||
|
||
const isSettingsButtonVisible = await page.evaluate(() => { | ||
const settingsButton = document.querySelector('.btn.imageBtn.settings'); | ||
const style = window.getComputedStyle(settingsButton); | ||
return style.getPropertyValue('visibility') !== 'hidden' && style.getPropertyValue('display') !== 'none'; | ||
}); | ||
|
||
expect(isSettingsButtonVisible).toBe(true); | ||
}); | ||
}); | ||
|
||
|
||
it('loads the viewer images', async () => { | ||
await page.waitForSelector('#thumb-0'); | ||
const imageSrc = await page.$eval('#thumb-0 img', e => e.src); | ||
expect(imageSrc).toEqual( | ||
expect.stringContaining( | ||
'https://iiif.wellcomecollection.org/image/b18035723_0001.JP2/full/90,/0/default.jpg' | ||
) | ||
); | ||
}); | ||
|
||
}); |