Compare commits

...

1 Commits

Author SHA1 Message Date
coderabbitai[bot]
8418a14fd2 CodeRabbit Generated Unit Tests: Add unit tests 2026-05-20 04:28:55 +00:00
2 changed files with 193 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
import { describe, expect, it } from 'vitest'
import { externalLinks, getRoutes } from './routes'
describe('getRoutes', () => {
it('returns the base routes unchanged for the default locale', () => {
const routes = getRoutes()
expect(routes.home).toBe('/')
expect(routes.cloud).toBe('/cloud')
expect(routes.careers).toBe('/careers')
expect(routes.termsOfService).toBe('/terms-of-service')
expect(routes.privacyPolicy).toBe('/privacy-policy')
})
it('returns the base routes unchanged for explicit "en" locale', () => {
const routes = getRoutes('en')
expect(routes.home).toBe('/')
expect(routes.download).toBe('/download')
expect(routes.cloudPricing).toBe('/cloud/pricing')
expect(routes.termsOfService).toBe('/terms-of-service')
})
it('prefixes every route including termsOfService for zh-CN locale', () => {
const routes = getRoutes('zh-CN')
// Previously termsOfService was locale-invariant and would NOT get a prefix.
// After removing localeInvariantRouteKeys, it now receives the prefix too.
expect(routes.termsOfService).toBe('/zh-CN/terms-of-service')
})
it('prefixes all routes for zh-CN locale', () => {
const routes = getRoutes('zh-CN')
expect(routes.home).toBe('/zh-CN/')
expect(routes.cloud).toBe('/zh-CN/cloud')
expect(routes.cloudPricing).toBe('/zh-CN/cloud/pricing')
expect(routes.cloudEnterprise).toBe('/zh-CN/cloud/enterprise')
expect(routes.api).toBe('/zh-CN/api')
expect(routes.gallery).toBe('/zh-CN/gallery')
expect(routes.about).toBe('/zh-CN/about')
expect(routes.careers).toBe('/zh-CN/careers')
expect(routes.customers).toBe('/zh-CN/customers')
expect(routes.demos).toBe('/zh-CN/demos')
expect(routes.privacyPolicy).toBe('/zh-CN/privacy-policy')
expect(routes.contact).toBe('/zh-CN/contact')
expect(routes.models).toBe('/zh-CN/p/supported-models')
expect(routes.download).toBe('/zh-CN/download')
})
it('every route value in a non-en locale starts with the locale prefix', () => {
const routes = getRoutes('zh-CN')
for (const [key, value] of Object.entries(routes)) {
expect(value, `route "${key}" should start with /zh-CN`).toMatch(
/^\/zh-CN\//
)
}
})
it('en locale routes are the same reference as baseRoutes (identity check)', () => {
const a = getRoutes('en')
const b = getRoutes('en')
// Both calls return the same base object
expect(a).toBe(b)
})
it('non-en locale routes are new objects (not the base reference)', () => {
const en = getRoutes('en')
const zhCN = getRoutes('zh-CN')
expect(zhCN).not.toBe(en)
})
})
describe('externalLinks', () => {
it('does not contain cloudStatus (removed in this PR)', () => {
expect('cloudStatus' in externalLinks).toBe(false)
})
it('contains expected external link keys', () => {
expect(externalLinks.cloud).toBe('https://cloud.comfy.org')
expect(externalLinks.discord).toMatch(/discord\.com/)
expect(externalLinks.docs).toMatch(/docs\.comfy\.org/)
expect(externalLinks.blog).toMatch(/blog\.comfy\.org/)
expect(externalLinks.github).toMatch(/github\.com\/Comfy-Org/)
expect(externalLinks.platform).toMatch(/platform\.comfy\.org/)
expect(externalLinks.support).toMatch(/support\.comfy\.org/)
expect(externalLinks.apiKeys).toMatch(/platform\.comfy\.org/)
expect(externalLinks.youtube).toMatch(/youtube\.com/)
})
it('all external link values are valid https URLs', () => {
for (const [key, url] of Object.entries(externalLinks)) {
expect(url, `externalLinks.${key} should start with https://`).toMatch(
/^https:\/\//
)
}
})
})

View File

@@ -0,0 +1,98 @@
import { describe, expect, it } from 'vitest'
import type { Department, Role, RolesSnapshot } from './roles'
describe('Role interface (applyUrl rename)', () => {
it('accepts an object with applyUrl as a valid Role', () => {
const role: Role = {
id: 'abc-123',
title: 'Senior Software Engineer',
department: 'Engineering',
location: 'San Francisco',
applyUrl: 'https://jobs.ashbyhq.com/comfy-org/abc-123/application'
}
expect(role.applyUrl).toBe(
'https://jobs.ashbyhq.com/comfy-org/abc-123/application'
)
// jobUrl must not exist on a valid Role object
expect('jobUrl' in role).toBe(false)
})
it('Role object has exactly the expected keys', () => {
const role: Role = {
id: 'xyz',
title: 'Designer',
department: 'Design',
location: 'Remote',
applyUrl: 'https://jobs.ashbyhq.com/comfy-org/xyz/application'
}
const keys = Object.keys(role).sort()
expect(keys).toEqual(['applyUrl', 'department', 'id', 'location', 'title'])
})
it('Department contains roles with applyUrl', () => {
const dept: Department = {
name: 'ENGINEERING',
key: 'engineering',
roles: [
{
id: 'role-1',
title: 'Software Engineer',
department: 'Engineering',
location: 'San Francisco',
applyUrl: 'https://jobs.ashbyhq.com/comfy-org/role-1/application'
}
]
}
expect(dept.roles[0]?.applyUrl).toMatch(
/^https:\/\/jobs\.ashbyhq\.com\//
)
expect('jobUrl' in (dept.roles[0] ?? {})).toBe(false)
})
it('RolesSnapshot has fetchedAt and departments with applyUrl roles', () => {
const snapshot: RolesSnapshot = {
fetchedAt: '2026-05-20T00:00:00.000Z',
departments: [
{
name: 'DESIGN',
key: 'design',
roles: [
{
id: 'designer-1',
title: 'Senior Product Designer',
department: 'Design',
location: 'San Francisco',
applyUrl:
'https://jobs.ashbyhq.com/comfy-org/designer-1/application'
}
]
}
]
}
expect(snapshot.fetchedAt).toBe('2026-05-20T00:00:00.000Z')
expect(snapshot.departments).toHaveLength(1)
const role = snapshot.departments[0]?.roles[0]
expect(role?.applyUrl).toMatch(/\/application$/)
})
it('applyUrl can point to an /application path (regression: was jobUrl without /application)', () => {
// Previously roles used jobUrl which linked to the job description page.
// Now applyUrl links to the application form (ending in /application).
const role: Role = {
id: 'r1',
title: 'Growth Engineer',
department: 'Engineering',
location: 'San Francisco',
applyUrl:
'https://jobs.ashbyhq.com/comfy-org/f1fdde76-84ae-48c1-b0f9-9654dd8e7de5/application'
}
expect(role.applyUrl).toContain('/application')
expect(role.applyUrl).toMatch(/^https:\/\/jobs\.ashbyhq\.com\//)
})
})