generated from lkhrs/eleventy-simple
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test a post with images and lightbox
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { test, expect, Page } from '@playwright/test'; | ||
|
||
let siteURL; | ||
|
||
test.beforeEach(async ({page, baseURL}) => { | ||
await page.goto('/'); | ||
siteURL = baseURL; | ||
}); | ||
|
||
|
||
/* | ||
Navigate to '{baseUrl}/eleventy-satisfactory/post-with-an-image/' | ||
On post { | ||
props({ | ||
'Clickable Image': `figure a`, | ||
'Lightbox': `.sl-wrapper` | ||
}) | ||
} | ||
Scroll To '1st Clickable Image' | ||
Click '1st Clickable Image' | ||
Verify 'Lightbox' is visible | ||
Verify at page '{baseUrl}/eleventy-satisfactory/post-with-an-image/' | ||
Type '[Escape]' into 'Lightbox' | ||
Scroll To '3rd Clickable Image' | ||
Wait '5' secs | ||
Click '3rd Clickable Image' | ||
Verify 'Lightbox' is visible | ||
Verify at page '{baseUrl}/eleventy-satisfactory/post-with-an-image/' | ||
*/ | ||
|
||
test.describe('Post with images', () => { | ||
|
||
test('Clicking an image produces a lightbox', async ({ page }) => { | ||
await page.goto('post-with-an-image/'); | ||
let clickableImages = await page.locator('figure a'); | ||
clickableImages.nth(0).scrollIntoViewIfNeeded(); | ||
await clickableImages.nth(0).click(); | ||
let lightbox = await page.locator('.sl-wrapper'); | ||
await expect(lightbox).toBeVisible(); | ||
|
||
// Ensure the URL is reset when lightbox is closed | ||
expect.soft(await page).toHaveURL('post-with-an-image/#pid=1'); | ||
await page.keyboard.press('Escape'); | ||
expect(lightbox).not.toBeVisible(); | ||
expect(await page).toHaveURL(siteURL + 'post-with-an-image/'); | ||
|
||
clickableImages.nth(2).scrollIntoViewIfNeeded(); | ||
await clickableImages.nth(2).click(); | ||
await expect(lightbox).toBeVisible(); | ||
await page.keyboard.press('Escape'); | ||
expect(await page).toHaveURL(siteURL + 'post-with-an-image/'); | ||
}); | ||
}); |