mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem - kb home and topic heroes stay blank on load because their canvases wait for react dom and hydration - the guide lists fade in row by row so the rows show late (i liked it at first but now doesn't feel right) ## Solution - changes the heroes to start from a small head script so the first frame does not wait for react - changes the heroes to hydrate only the home search button so a hydration mismatch cannot remove the running canvases - removes the stagger from the guide lists - moves the `GlyphLines` canvas code and `toOpaque`, now `flattenColor` into modules without react <!-- ## Preview links If relevant, include links to changed pages for easy review access. Copy the preview base URL from the Vercel bot comment on this PR. Use the following table as an example template. | Site | Live | Preview | Search for | | -------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- | | WWW | [/blog/your-post](https://supabase.com/blog/your-post) | [/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post) | unique phrase from the change | | Docs | [/docs/guides/your-page](https://supabase.com/docs/guides/your-page) | [/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page) | unique phrase from the change | | Studio | [/dashboard](https://supabase.com/dashboard) | [/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard) | unique phrase from the change | | Design system | [/design-system](https://supabase.com/design-system) | [/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system) | unique phrase from the change | | UI library | [/library](https://supabase.com/library) | [/library](https://ui-library-git-branch-name-supabase.vercel.app/library) | unique phrase from the change | | Knowledge base | [/kb/guides/your-page](https://supabase.com/kb/guides/your-page) | [/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page) | unique phrase from the change | --> <!-- ## Additional context Optionally add any other context or screenshots. --> ## Review instructions 1. open [/kb](https://kb-git-antlio-kb-hero-refacto-supabase.vercel.app/kb) now rings should show faster vs prod 2. open [/kb/topics/auth](https://kb-git-antlio-kb-hero-refacto-supabase.vercel.app/kb/topics/auth), reload, and make sure that the grid lines and shapes show directly after the title ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
73 lines
2.7 KiB
TypeScript
73 lines
2.7 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
|
|
const GUIDE = '/kb/guides/migrate-from-heroku'
|
|
|
|
test('home page links to guides', async ({ page }) => {
|
|
const response = await page.goto('/kb')
|
|
expect(response?.ok()).toBeTruthy()
|
|
await expect(page.locator('a[href^="/kb/guides/"]').first()).toBeVisible()
|
|
})
|
|
|
|
for (const { path, canvas } of [
|
|
{ path: '/kb', canvas: '[data-warp-canvas]' },
|
|
{ path: '/kb/topics/migration', canvas: '[data-frame-glyphs]' },
|
|
]) {
|
|
test(`hero on ${path} draws without react`, async ({ page }) => {
|
|
await page.route('**/_astro/client.*.js', (route) => route.abort())
|
|
await page.goto(path)
|
|
await expect(page.locator(canvas)).toHaveAttribute('width', /^[1-9]/)
|
|
await expect
|
|
.poll(() =>
|
|
page.locator(canvas).evaluate(
|
|
(element: HTMLCanvasElement) =>
|
|
element
|
|
.getContext('2d')
|
|
?.getImageData(0, 0, element.width, element.height)
|
|
.data.some((value, index) => index % 4 === 3 && value > 0) ?? false
|
|
)
|
|
)
|
|
.toBe(true)
|
|
})
|
|
}
|
|
|
|
test('topic page links to a guide that renders', async ({ page }) => {
|
|
await page.goto('/kb/topics/migration')
|
|
await page.locator('a[href^="/kb/guides/"]').first().click()
|
|
await expect(page).toHaveURL(/\/kb\/guides\//)
|
|
await expect(page.locator('main article h1')).toBeVisible()
|
|
})
|
|
|
|
test('troubleshooting article renders', async ({ page }) => {
|
|
await page.goto('/kb/topics/troubleshooting')
|
|
await page.locator('a[href^="/kb/troubleshooting/"]').first().click()
|
|
await expect(page).toHaveURL(/\/kb\/troubleshooting\//)
|
|
await expect(page.locator('main article h1')).toBeVisible()
|
|
})
|
|
|
|
test('guide is available as markdown via .md and Accept header', async ({ request }) => {
|
|
for (const response of [
|
|
await request.get(`${GUIDE}.md`),
|
|
await request.get(GUIDE, { headers: { Accept: 'text/markdown' } }),
|
|
]) {
|
|
expect(response.ok()).toBeTruthy()
|
|
expect(response.headers()['content-type']).toContain('text/markdown')
|
|
expect(await response.text()).toMatch(/^# /)
|
|
}
|
|
})
|
|
|
|
test('markdown sitemap lists guides', async ({ request }) => {
|
|
const response = await request.get('/kb/sitemap.md')
|
|
expect(response.ok()).toBeTruthy()
|
|
expect(await response.text()).toContain('/kb/guides/')
|
|
})
|
|
|
|
test('search API returns results and rejects a missing query', async ({ request, baseURL }) => {
|
|
test.skip(baseURL !== 'https://supabase.com', 'Search is only configured in production')
|
|
|
|
const results = await request.get('/kb/api/search?q=auth&limit=1')
|
|
expect(results.ok()).toBeTruthy()
|
|
expect(await results.json()).toEqual([expect.objectContaining({ title: expect.any(String) })])
|
|
|
|
expect((await request.get('/kb/api/search')).status()).toBe(400)
|
|
})
|