-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
β
Added Playwright behavior tests to image api endpoints
Screenshot all 4 GET image api endpoints with complex config per viewport type (Chrome and Mobile Chrome) in preparation for migration. Also updated TailwindCSS config from .js to .ts.
- Loading branch information
Showing
10 changed files
with
74 additions
and
5 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,63 @@ | ||
import { type Page, expect, test } from '@playwright/test' | ||
|
||
const customTimeout = { timeout: 30000 } | ||
|
||
const defaultImageURL: string = | ||
'/wei/socialify/image?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
const svgImageURL: string = | ||
'/wei/socialify/svg?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
const pngImageURL: string = | ||
'/wei/socialify/png?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
// Backward compatibility route. | ||
const jpgImageURL: string = | ||
'/wei/socialify/jpg?description=1&font=Raleway&language=1&name=1&owner=1&pattern=Diagonal%20Stripes&theme=Dark' | ||
|
||
test.describe('Socialify image api', () => { | ||
test('respond consistently for default endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(defaultImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
|
||
test('respond consistently for svg endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(svgImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
|
||
test('respond consistently for png endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(pngImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
|
||
test('respond consistently for backwards-compatible jpg endpoint', async ({ | ||
page, | ||
}: { page: Page }): Promise<void> => { | ||
await page.goto(jpgImageURL, customTimeout) | ||
|
||
// Wait for the page to load/hydrate completely. | ||
await page.waitForLoadState('networkidle', customTimeout) | ||
|
||
const image = await page.screenshot() | ||
expect(image).toMatchSnapshot() | ||
}) | ||
}) |
Binary file added
BIN
+120 KB
...nd-consistently-for-backwards-compatible-jpg-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.4 KB
...respond-consistently-for-backwards-compatible-jpg-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.2 KB
...y-image-api-respond-consistently-for-default-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+59.3 KB
...ialify-image-api-respond-consistently-for-default-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+120 KB
...alify-image-api-respond-consistently-for-png-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+48.4 KB
.../Socialify-image-api-respond-consistently-for-png-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.2 KB
...alify-image-api-respond-consistently-for-svg-endpoint-1-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+59.3 KB
.../Socialify-image-api-respond-consistently-for-svg-endpoint-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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