mirror of
https://github.com/iflytek/skillhub.git
synced 2026-11-17 09:31:39 +00:00
fix(analytics): preserve release Web defaults in optional edge
Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
This commit is contained in:
parent
900faf7d18
commit
238b784110
3 changed files with 43 additions and 1 deletions
|
|
@ -25,8 +25,10 @@ services:
|
|||
ports: ["127.0.0.1:8300:3000"]
|
||||
edge:
|
||||
image: nginx:1.30.6-alpine
|
||||
# Docker Desktop/OrbStack provide this name; native Linux needs this mapping.
|
||||
extra_hosts: ["host.docker.internal:host-gateway"]
|
||||
environment:
|
||||
SKILLHUB_WEB_UPSTREAM: ${SKILLHUB_WEB_UPSTREAM:-host.docker.internal:8080}
|
||||
SKILLHUB_WEB_UPSTREAM: ${SKILLHUB_WEB_UPSTREAM:-host.docker.internal:80}
|
||||
UMAMI_UPSTREAM: umami:3000
|
||||
NGINX_ENVSUBST_FILTER: ^(SKILLHUB_WEB_UPSTREAM|UMAMI_UPSTREAM)$$
|
||||
volumes:
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ upstream skillhub_analytics_umami { server ${UMAMI_UPSTREAM}; }
|
|||
server {
|
||||
listen 8081;
|
||||
server_name localhost;
|
||||
# Preserve the standard Web upload limit on every application proxy route.
|
||||
client_max_body_size 100M;
|
||||
|
||||
# Install ONLY the three .mjs files here, not declarations or other files.
|
||||
# A single versioned prefix serves the entry AND its relative imports.
|
||||
|
|
|
|||
|
|
@ -15,6 +15,44 @@ afterEach(() => { document.head.replaceChildren(); vi.useRealTimers(); vi.restor
|
|||
const website = '4398de8e-40df-4483-9eea-ed213643525f'
|
||||
const intent = { id: 'skill.example.open', event: 'click' }
|
||||
|
||||
describe('optional edge deployment defaults', () => {
|
||||
const nginx = readFileSync('../docs/examples/analytics/nginx.conf', 'utf8')
|
||||
const compose = readFileSync('../docs/examples/analytics/compose.yaml', 'utf8')
|
||||
|
||||
it('inherits the standard 100 MiB limit on all proxied application routes', () => {
|
||||
// Tokenize quoted strings as units so braces/semicolons in responses do not
|
||||
// affect scope. Track blocks instead of accepting a location-only limit.
|
||||
const tokens = nginx.replace(/#.*$/gm, '').match(/"[^"\n]*"|'[^'\n]*'|[{};]|[^\s{};]+/g) ?? []
|
||||
const blocks: string[] = [], statement: string[] = []
|
||||
const limits: Array<{ scope: string[]; value: string }> = []
|
||||
for (const token of tokens) {
|
||||
if (token === '{') { blocks.push(statement.join(' ')); statement.length = 0 }
|
||||
else if (token === '}') { blocks.pop(); statement.length = 0 }
|
||||
else if (token === ';') {
|
||||
if (statement[0] === 'client_max_body_size') limits.push({ scope: [...blocks], value: statement[1] })
|
||||
statement.length = 0
|
||||
} else statement.push(token)
|
||||
}
|
||||
expect(limits).toContainEqual({ scope: ['server'], value: '100M' })
|
||||
// A collector-only restriction is allowed; application locations must inherit.
|
||||
expect(limits.filter(limit => limit.scope.some(scope => scope.startsWith('location') && !scope.includes('/_skillhub-umami/')))).toEqual([])
|
||||
expect(limits.filter(limit => limit.scope.length === 1)).toEqual([{ scope: ['server'], value: '100M' }])
|
||||
})
|
||||
|
||||
it('defaults to the release Web entry, not the development port', () => {
|
||||
const release = readFileSync('../compose.release.yml', 'utf8')
|
||||
expect(release).toContain('${WEB_PORT:-80}:80')
|
||||
expect(compose).toContain('SKILLHUB_WEB_UPSTREAM: ${SKILLHUB_WEB_UPSTREAM:-host.docker.internal:80}')
|
||||
expect(compose).not.toContain('host.docker.internal:8080')
|
||||
})
|
||||
|
||||
it('maps the host gateway on native Linux for the edge service', () => {
|
||||
const edge = compose.split('\n edge:\n')[1]
|
||||
expect(edge).toBeDefined()
|
||||
expect(edge).toContain('extra_hosts: ["host.docker.internal:host-gateway"]')
|
||||
})
|
||||
})
|
||||
|
||||
describe('product ID grammar parity', () => {
|
||||
it.each([4, 5, 6])('accepts a published %i-segment ID in rules and the final payload', segments => {
|
||||
const id = publishedIds.find(id => id.split('.').length === segments)!
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue