-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): Successfully serve static assets like
favicon.png
(#10455)
- Loading branch information
1 parent
ba09dd3
commit 1313276
Showing
8 changed files
with
82 additions
and
2 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,7 @@ | ||
import { test } from '@playwright/test' | ||
|
||
import { runTestCases } from '../../shared/staticAssets' | ||
|
||
test.describe('Static assets', async () => { | ||
await runTestCases() | ||
}) |
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,7 @@ | ||
import { test } from '@playwright/test' | ||
|
||
import { runTestCases } from '../../shared/staticAssets' | ||
|
||
test.describe('Static assets', async () => { | ||
await runTestCases() | ||
}) |
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,7 @@ | ||
import { test } from '@playwright/test' | ||
|
||
import { runTestCases } from '../../shared/staticAssets' | ||
|
||
test.describe('Static assets', async () => { | ||
await runTestCases() | ||
}) |
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,7 @@ | ||
import { test } from '@playwright/test' | ||
|
||
import { runTestCases } from '../../shared/staticAssets' | ||
|
||
test.describe('Static assets', async () => { | ||
await runTestCases() | ||
}) |
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,34 @@ | ||
import type { Page } from '@playwright/test' | ||
import { expect, test } from '@playwright/test' | ||
|
||
async function checkRobotsTxt(page: Page) { | ||
const response = await page.goto('/robots.txt') | ||
expect(response.ok()).toBe(true) | ||
expect(response.headers()['content-type']).toContain('text/plain') | ||
|
||
const content = await response.text() | ||
expect(content).toContain('User-agent: *') | ||
} | ||
|
||
async function checkFaviconPng(page: Page) { | ||
const response = await page.goto('/favicon.png') | ||
expect(response.ok()).toBe(true) | ||
expect(response.headers()['content-type']).toContain('image/png') | ||
|
||
const content = await response.text() | ||
expect(content).toContain('PNG') | ||
} | ||
|
||
type StaticAssetTestCase = [string, (page: Page) => Promise<void>] | ||
const staticAssetTests: StaticAssetTestCase[] = [ | ||
['check robots.txt', checkRobotsTxt], | ||
['check favicon.png', checkFaviconPng], | ||
] | ||
|
||
export async function runTestCases() { | ||
for (const [name, testFn] of staticAssetTests) { | ||
test(name, async ({ page }) => { | ||
await testFn(page) | ||
}) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tasks/smoke-tests/streaming-ssr-dev/tests/staticAssets.spec.ts
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,7 @@ | ||
import { test } from '@playwright/test' | ||
|
||
import { runTestCases } from '../../shared/staticAssets' | ||
|
||
test.describe('Static assets', async () => { | ||
await runTestCases() | ||
}) |
7 changes: 7 additions & 0 deletions
7
tasks/smoke-tests/streaming-ssr-prod/tests/staticAssets.spec.ts
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,7 @@ | ||
import { test } from '@playwright/test' | ||
|
||
import { runTestCases } from '../../shared/staticAssets' | ||
|
||
test.describe('Static assets', async () => { | ||
await runTestCases() | ||
}) |