mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem Describe what went wrong or what need emerged to justify this bug fix, feature, or change. Link any relevant issues here. ## Solution Provide a brief description of the change and the key choices you made when architecting the solution. Feel free to include screenshots if it includes visual changes. <!-- ## 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 Provide a clear numbered procedure that the PR reviewer can walk through. 1. For example, `Open the live and preview links side-by-side.` 2. For example, `See the issue is fixed.` ## Checklist Check all before review: - [ ] 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)
80 lines
2.8 KiB
TypeScript
80 lines
2.8 KiB
TypeScript
import { load } from 'cheerio'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
const REFERENCE_DOCS_URL = 'https://supabase.com/docs/reference'
|
|
// For dev testing: comment out above and uncomment below
|
|
// const REFERENCE_DOCS_URL = 'http://localhost:3001/docs/reference'
|
|
|
|
describe('prod smoke test: crawler pages return correct data', () => {
|
|
/**
|
|
* No special tricks required to spoof the user agent. Tests are correctly
|
|
* detected as coming from bots. If they ever aren't, the `h1` test will fail
|
|
* as a different `h1` is served to non-bots.
|
|
*/
|
|
|
|
it('metadata: title, description, canonical, image', async () => {
|
|
const result = await fetch(REFERENCE_DOCS_URL + '/javascript/rangelte')
|
|
const text = await result.text()
|
|
|
|
const $ = load(text)
|
|
const title = $('title').text()
|
|
expect(title).toBe('JavaScript: rangeLte | Supabase Docs')
|
|
|
|
const metaDescription = $('meta[name="description"]')
|
|
expect(metaDescription.attr('content')).toBe('Supabase API reference for JavaScript: rangeLte')
|
|
|
|
const canonical = $('link[rel="canonical"]')
|
|
expect(canonical.attr('href')).toBe(
|
|
'https://supabase.com/docs/reference/javascript/using-filters-rangelte'
|
|
)
|
|
|
|
const ogImage = $('meta[name="og:image"]')
|
|
expect(ogImage.attr('content')).toBe('https://supabase.com/docs/img/supabase-og-image.png')
|
|
|
|
const twitterImage = $('meta[name="twitter:image"]')
|
|
expect(twitterImage.attr('content')).toBe('https://supabase.com/docs/img/supabase-og-image.png')
|
|
})
|
|
|
|
it('markdown pages', async () => {
|
|
const result = await fetch(REFERENCE_DOCS_URL + '/javascript/introduction')
|
|
const text = await result.text()
|
|
|
|
const $ = load(text)
|
|
const h1 = $('h1').text()
|
|
expect(h1).toBe('JavaScript: Introduction')
|
|
|
|
const firstPara = $('h1').next().text()
|
|
expect(/JavaScript library/.test(firstPara)).toBe(true)
|
|
expect(/supabase-js/.test(firstPara)).toBe(true)
|
|
})
|
|
|
|
it('function pages', async () => {
|
|
const result = await fetch(REFERENCE_DOCS_URL + '/javascript/rangelte')
|
|
const text = await result.text()
|
|
|
|
const $ = load(text)
|
|
const h1 = $('h1').text()
|
|
expect(h1).toBe('JavaScript: rangeLte')
|
|
|
|
const description = $('h1').next().text()
|
|
expect(description).toBe(
|
|
'Only relevant for range columns. Match only rows where every element in column is either contained in range or less than any element in range.'
|
|
)
|
|
|
|
const headings = [] as Array<string | undefined>
|
|
$('h2').map(function () {
|
|
headings.push($(this).attr('id'))
|
|
})
|
|
|
|
expect(headings.includes('parameters')).toBe(true)
|
|
expect(headings.includes('examples')).toBe(true)
|
|
})
|
|
})
|
|
|
|
describe('prod smoke test: ref pages without crawler versions', async () => {
|
|
it('returns 200', async () => {
|
|
const result = await fetch(REFERENCE_DOCS_URL + '/api/v1-deploy-a-function')
|
|
expect(result.status).toBe(200)
|
|
})
|
|
})
|