mirror of
https://github.com/langgenius/dify.git
synced 2026-03-21 06:18:27 +08:00
Merge remote-tracking branch 'origin/main' into feat/model-plugins-implementing
This commit is contained in:
@ -79,6 +79,23 @@ describe('check-components-diff-coverage helpers', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('should report the first changed line inside a multi-line uncovered statement', () => {
|
||||
const entry = {
|
||||
s: { 0: 0 },
|
||||
statementMap: {
|
||||
0: { start: { line: 10 }, end: { line: 14 } },
|
||||
},
|
||||
}
|
||||
|
||||
const coverage = getChangedStatementCoverage(entry, new Set([13, 14]))
|
||||
|
||||
expect(coverage).toEqual({
|
||||
covered: 0,
|
||||
total: 1,
|
||||
uncoveredLines: [13],
|
||||
})
|
||||
})
|
||||
|
||||
it('should fail changed lines when a source file has no coverage entry', () => {
|
||||
const coverage = getChangedStatementCoverage(undefined, new Set([42, 43]))
|
||||
|
||||
@ -118,6 +135,36 @@ describe('check-components-diff-coverage helpers', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('should report the first changed line inside a multi-line uncovered branch arm', () => {
|
||||
const entry = {
|
||||
b: {
|
||||
0: [0, 0],
|
||||
},
|
||||
branchMap: {
|
||||
0: {
|
||||
line: 30,
|
||||
loc: { start: { line: 30 }, end: { line: 35 } },
|
||||
locations: [
|
||||
{ start: { line: 31 }, end: { line: 34 } },
|
||||
{ start: { line: 35 }, end: { line: 38 } },
|
||||
],
|
||||
type: 'if',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const coverage = getChangedBranchCoverage(entry, new Set([33]))
|
||||
|
||||
expect(coverage).toEqual({
|
||||
covered: 0,
|
||||
total: 2,
|
||||
uncoveredBranches: [
|
||||
{ armIndex: 0, line: 33 },
|
||||
{ armIndex: 1, line: 35 },
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it('should ignore changed lines with valid pragma reasons and report invalid pragmas', () => {
|
||||
const sourceCode = [
|
||||
'const a = 1',
|
||||
|
||||
Binary file not shown.
24
web/app/components/billing/pricing/header.module.css
Normal file
24
web/app/components/billing/pricing/header.module.css
Normal file
@ -0,0 +1,24 @@
|
||||
.instrumentSerif {
|
||||
font-family: "Instrument Serif", serif;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Instrument Serif";
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("./InstrumentSerif-Italic-Latin.woff2") format("woff2");
|
||||
unicode-range:
|
||||
U+0000-00FF,
|
||||
U+0100-024F,
|
||||
U+0259,
|
||||
U+0300-036F,
|
||||
U+1E00-1EFF,
|
||||
U+2010-205E,
|
||||
U+20A0-20CF,
|
||||
U+2113,
|
||||
U+2212,
|
||||
U+2C60-2C7F,
|
||||
U+A720-A7FF;
|
||||
}
|
||||
@ -1,8 +1,9 @@
|
||||
import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { DialogDescription, DialogTitle } from '@/app/components/base/ui/dialog'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import Button from '../../base/button'
|
||||
import DifyLogo from '../../base/logo/dify-logo'
|
||||
import styles from './header.module.css'
|
||||
|
||||
type HeaderProps = {
|
||||
onClose: () => void
|
||||
@ -20,13 +21,18 @@ const Header = ({
|
||||
<div className="py-[5px]">
|
||||
<DifyLogo className="h-[27px] w-[60px]" />
|
||||
</div>
|
||||
<DialogTitle className="m-0 bg-billing-plan-title-bg bg-clip-text px-1.5 font-instrument text-[37px] italic leading-[1.2] text-transparent">
|
||||
<span
|
||||
className={cn(
|
||||
'bg-billing-plan-title-bg bg-clip-text px-1.5 text-[37px] leading-[1.2] text-transparent',
|
||||
styles.instrumentSerif,
|
||||
)}
|
||||
>
|
||||
{t('plansCommon.title.plans', { ns: 'billing' })}
|
||||
</DialogTitle>
|
||||
</span>
|
||||
</div>
|
||||
<DialogDescription className="m-0 text-text-tertiary system-sm-regular">
|
||||
<p className="text-text-tertiary system-sm-regular">
|
||||
{t('plansCommon.title.description', { ns: 'billing' })}
|
||||
</DialogDescription>
|
||||
</p>
|
||||
<Button
|
||||
variant="secondary"
|
||||
className="absolute bottom-[40.5px] right-[-18px] z-10 size-9 rounded-full p-2"
|
||||
|
||||
@ -2,14 +2,12 @@ import type { Viewport } from 'next'
|
||||
import { Agentation } from 'agentation'
|
||||
import { Provider as JotaiProvider } from 'jotai/react'
|
||||
import { ThemeProvider } from 'next-themes'
|
||||
import { Instrument_Serif } from 'next/font/google'
|
||||
import { NuqsAdapter } from 'nuqs/adapters/next/app'
|
||||
import { IS_DEV } from '@/config'
|
||||
import GlobalPublicStoreProvider from '@/context/global-public-context'
|
||||
import { TanstackQueryInitializer } from '@/context/query-client'
|
||||
import { getDatasetMap } from '@/env'
|
||||
import { getLocaleOnServer } from '@/i18n-config/server'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { ToastProvider } from './components/base/toast'
|
||||
import { TooltipProvider } from './components/base/ui/tooltip'
|
||||
import BrowserInitializer from './components/browser-initializer'
|
||||
@ -28,13 +26,6 @@ export const viewport: Viewport = {
|
||||
userScalable: false,
|
||||
}
|
||||
|
||||
const instrumentSerif = Instrument_Serif({
|
||||
weight: ['400'],
|
||||
style: ['normal', 'italic'],
|
||||
subsets: ['latin'],
|
||||
variable: '--font-instrument-serif',
|
||||
})
|
||||
|
||||
const LocaleLayout = async ({
|
||||
children,
|
||||
}: {
|
||||
@ -44,7 +35,7 @@ const LocaleLayout = async ({
|
||||
const datasetMap = getDatasetMap()
|
||||
|
||||
return (
|
||||
<html lang={locale ?? 'en'} className={cn('h-full', instrumentSerif.variable)} suppressHydrationWarning>
|
||||
<html lang={locale ?? 'en'} className="h-full" suppressHydrationWarning>
|
||||
<head>
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<meta name="theme-color" content="#1C64F2" />
|
||||
|
||||
@ -2774,6 +2774,11 @@
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
"app/components/billing/pricing/index.tsx": {
|
||||
"react-refresh/only-export-components": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"app/components/billing/pricing/plan-switcher/plan-range-switcher.tsx": {
|
||||
"react-refresh/only-export-components": {
|
||||
"count": 1
|
||||
@ -9379,4 +9384,4 @@
|
||||
"count": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ export function getChangedStatementCoverage(entry, changedLines) {
|
||||
continue
|
||||
}
|
||||
|
||||
uncoveredLines.push(statement.start.line)
|
||||
uncoveredLines.push(getFirstChangedLineInRange(statement, normalizedChangedLines))
|
||||
}
|
||||
|
||||
return {
|
||||
@ -111,6 +111,7 @@ export function getChangedStatementCoverage(entry, changedLines) {
|
||||
}
|
||||
|
||||
export function getChangedBranchCoverage(entry, changedLines) {
|
||||
const normalizedChangedLines = [...(changedLines ?? [])].sort((a, b) => a - b)
|
||||
if (!entry) {
|
||||
return {
|
||||
covered: 0,
|
||||
@ -141,7 +142,7 @@ export function getChangedBranchCoverage(entry, changedLines) {
|
||||
const location = locations[armIndex] ?? branch.loc ?? branch
|
||||
uncoveredBranches.push({
|
||||
armIndex,
|
||||
line: getLocationStartLine(location) ?? branch.line ?? 1,
|
||||
line: getFirstChangedLineInRange(location, normalizedChangedLines, branch.line ?? 1),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -247,6 +248,20 @@ function rangeIntersectsChangedLines(location, changedLines) {
|
||||
return false
|
||||
}
|
||||
|
||||
function getFirstChangedLineInRange(location, changedLines, fallbackLine = 1) {
|
||||
const startLine = getLocationStartLine(location)
|
||||
const endLine = getLocationEndLine(location) ?? startLine
|
||||
if (!startLine || !endLine)
|
||||
return startLine ?? fallbackLine
|
||||
|
||||
for (const lineNumber of changedLines) {
|
||||
if (lineNumber >= startLine && lineNumber <= endLine)
|
||||
return lineNumber
|
||||
}
|
||||
|
||||
return startLine ?? fallbackLine
|
||||
}
|
||||
|
||||
function getLocationStartLine(location) {
|
||||
return location?.start?.line ?? location?.line ?? null
|
||||
}
|
||||
|
||||
@ -338,8 +338,8 @@ function buildSummary({
|
||||
}
|
||||
|
||||
lines.push(`Changed source files checked: ${changedSourceFiles.length}`)
|
||||
lines.push(`Changed statement coverage: ${percentage(diffTotals.statements.covered, diffTotals.statements.total).toFixed(2)}%`)
|
||||
lines.push(`Changed branch coverage: ${percentage(diffTotals.branches.covered, diffTotals.branches.total).toFixed(2)}%`)
|
||||
lines.push(`Changed statement coverage: ${formatDiffPercent(diffTotals.statements)}`)
|
||||
lines.push(`Changed branch coverage: ${formatDiffPercent(diffTotals.branches)}`)
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
@ -113,9 +113,6 @@ const config = {
|
||||
2: '0.02',
|
||||
8: '0.08',
|
||||
},
|
||||
fontFamily: {
|
||||
instrument: ['var(--font-instrument-serif)', 'serif'],
|
||||
},
|
||||
fontSize: {
|
||||
'2xs': '0.625rem',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user