mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-04 06:57:55 +00:00
- Add personal pins (My sessions), global/project pin separation, H5 running/pending and active/idle buckets, and collapsible project groups with counts and selected-row expansion. - Add local personal pin storage and list-specific display metrics. - Add Settings > Appearance list text size (80-130%) and CLI/code font size (9-17 pt), with Dynamic Type still applied. - Keep search flat and filters force groups open; shared/archived/status detail/preview-fold remain out of scope. - Bump the local build to 14. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
81 lines
3.7 KiB
Swift
81 lines
3.7 KiB
Swift
import SwiftUI
|
|
import Testing
|
|
@testable import HapiUI
|
|
|
|
@Suite("Reading typography")
|
|
struct TypographyTests {
|
|
@Test func baselineAndScaledMetricsKeepTheirHierarchy() {
|
|
let base = HapiTypography()
|
|
#expect(base.bodySize == 16)
|
|
#expect(base.codeSize == 14)
|
|
#expect(base.inlineCodeSize == 15)
|
|
#expect(base.captionSize == 12)
|
|
#expect((1...6).map(base.headingSize) == [24, 20, 18, 17, 17, 17])
|
|
let large = HapiTypography(bodyScale: 3, codeScale: 2, captionScale: 2.5, boldText: true)
|
|
#expect(large.bodySize == 48)
|
|
#expect(large.inlineCodeSize == 45)
|
|
#expect(large.bodyLineSpacing == 9)
|
|
#expect(large.codeLineSpacing == 4)
|
|
#expect(large.headingSize(3) > large.bodySize)
|
|
}
|
|
|
|
@Test @MainActor
|
|
func markdownMarginsAreBetweenBlocksNotStackedPadding() {
|
|
let paragraph = MarkdownBlockNode.paragraph(AttributedString("Body"))
|
|
let heading = MarkdownBlockNode.heading(level: 2, AttributedString("Heading"))
|
|
#expect(MarkdownBlockListView.spacing(before: heading, after: nil) == 0)
|
|
#expect(MarkdownBlockListView.spacing(before: paragraph, after: nil) == 0)
|
|
#expect(MarkdownBlockListView.spacing(before: heading, after: paragraph) == 24)
|
|
#expect(MarkdownBlockListView.spacing(before: heading, after: heading) == 24)
|
|
#expect(MarkdownBlockListView.spacing(before: paragraph, after: heading) == 8)
|
|
#expect(MarkdownBlockListView.spacing(before: paragraph, after: paragraph) == 12)
|
|
}
|
|
|
|
@Test func codeFontOverrideUsesTheProvidedSize() {
|
|
var values = EnvironmentValues()
|
|
#expect(values.hapiCodeFontSize == nil)
|
|
values.hapiCodeFontSize = 17
|
|
#expect(values.hapiCodeFontSize == 17)
|
|
|
|
let typography = HapiTypography()
|
|
#expect(typography.codeFont(size: nil) == typography.codeFont)
|
|
#expect(typography.codeFont(size: 17) != typography.codeFont(size: 13))
|
|
}
|
|
|
|
@Test func conversationRhythmDoesNotMistakeHistoryForANewTurn() {
|
|
#expect(TranscriptRowRole.user.spacing(after: nil) == 12)
|
|
#expect(TranscriptRowRole.user.spacing(after: .history) == 12)
|
|
#expect(TranscriptRowRole.user.spacing(after: .content) == 24)
|
|
#expect(TranscriptRowRole.user.spacing(after: .user) == 8)
|
|
#expect(TranscriptRowRole.tool.spacing(after: .user) == 16)
|
|
#expect(TranscriptRowRole.content.spacing(after: .user) == 16)
|
|
#expect(TranscriptRowRole.tool.spacing(after: .tool) == 8)
|
|
#expect(TranscriptRowRole.content.spacing(after: .tool) == 12)
|
|
}
|
|
|
|
@Test func readingWidthsFitSmallScreensAndCapTablets() {
|
|
#expect(HapiReadingLayout.contentWidth(in: 320) == 288)
|
|
#expect(HapiReadingLayout.contentWidth(in: 390) == 358)
|
|
#expect(HapiReadingLayout.contentWidth(in: 507) == 475)
|
|
#expect(HapiReadingLayout.contentWidth(in: 768) == 720)
|
|
#expect(HapiReadingLayout.contentWidth(in: 1024) == 720)
|
|
#expect(HapiReadingLayout.contentWidth(in: 0) == 1)
|
|
}
|
|
|
|
@Test func inlineCodeIsNeutralButLinksStillWin() {
|
|
var source = AttributedString("code")
|
|
source.inlinePresentationIntent = .code
|
|
let typography = HapiTypography(bodyScale: 2)
|
|
for theme in [HapiTheme.light, .dark, .oled] {
|
|
let styled = hapiStyledText(source, theme: theme, typography: typography)
|
|
#expect(styled.font == typography.inlineCodeFont)
|
|
#expect(styled.foregroundColor == theme.textPrimary)
|
|
source.link = URL(string: "https://example.com")
|
|
let linked = hapiStyledText(source, theme: theme, typography: typography)
|
|
#expect(linked.foregroundColor == theme.link)
|
|
#expect(linked.underlineStyle == .single)
|
|
source.link = nil
|
|
}
|
|
}
|
|
}
|