From 79ffe508f92ef9058f75e1877a55fa153c59db8a Mon Sep 17 00:00:00 2001 From: Prachi Gauriar Date: Tue, 17 Mar 2026 18:59:43 -0400 Subject: [PATCH] Sort metadata keys on variable detail screen --- .../ConfigVariableDetailViewModel.swift | 1 + .../DevConfiguration/Resources/Localizable.xcstrings | 10 +++++----- .../ConfigVariableDetailViewModelTests.swift | 9 +++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Sources/DevConfiguration/Editor/Config Variable Detail/ConfigVariableDetailViewModel.swift b/Sources/DevConfiguration/Editor/Config Variable Detail/ConfigVariableDetailViewModel.swift index b227b98..8d19127 100644 --- a/Sources/DevConfiguration/Editor/Config Variable Detail/ConfigVariableDetailViewModel.swift +++ b/Sources/DevConfiguration/Editor/Config Variable Detail/ConfigVariableDetailViewModel.swift @@ -48,6 +48,7 @@ final class ConfigVariableDetailViewModel: ConfigVariableDetailViewModeling { self.contentTypeName = registeredVariable.contentTypeName self.variableTypeName = registeredVariable.destinationTypeName self.metadataEntries = registeredVariable.metadata.displayTextEntries + .sorted { $0.key.localizedStandardCompare($1.key) == .orderedAscending } self.isSecret = registeredVariable.isSecret self.editorControl = registeredVariable.isEditable ? registeredVariable.editorControl : nil diff --git a/Sources/DevConfiguration/Resources/Localizable.xcstrings b/Sources/DevConfiguration/Resources/Localizable.xcstrings index 59f9c35..9c241b1 100644 --- a/Sources/DevConfiguration/Resources/Localizable.xcstrings +++ b/Sources/DevConfiguration/Resources/Localizable.xcstrings @@ -1,22 +1,22 @@ { "sourceLanguage" : "en", "strings" : { - "detailView.headerSection.key" : { + "detailView.headerSection.contentType" : { "localizations" : { "en" : { "stringUnit" : { "state" : "translated", - "value" : "Key" + "value" : "Content Type" } } } }, - "detailView.headerSection.contentType" : { + "detailView.headerSection.key" : { "localizations" : { "en" : { "stringUnit" : { "state" : "translated", - "value" : "Content Type" + "value" : "Key" } } } @@ -366,7 +366,7 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "Is Editable" + "value" : "Editable" } } } diff --git a/Tests/DevConfigurationTests/Unit Tests/Editor/Config Variable Detail/ConfigVariableDetailViewModelTests.swift b/Tests/DevConfigurationTests/Unit Tests/Editor/Config Variable Detail/ConfigVariableDetailViewModelTests.swift index 8d2a528..1548882 100644 --- a/Tests/DevConfigurationTests/Unit Tests/Editor/Config Variable Detail/ConfigVariableDetailViewModelTests.swift +++ b/Tests/DevConfigurationTests/Unit Tests/Editor/Config Variable Detail/ConfigVariableDetailViewModelTests.swift @@ -60,6 +60,8 @@ struct ConfigVariableDetailViewModelTests: RandomValueGenerating { // set up var metadata = ConfigVariableMetadata() metadata.displayName = randomAlphanumericString() + metadata.requiresRelaunch = randomBool() + metadata.isEditable = randomBool() let destinationTypeName = randomAlphanumericString() let isSecret = randomBool() @@ -76,13 +78,16 @@ struct ConfigVariableDetailViewModelTests: RandomValueGenerating { let viewModel = makeViewModel(document: document, registeredVariable: variable) // expect all constant properties are set from the registered variable + let expectedMetadataEntries = metadata.displayTextEntries + .sorted { $0.key.localizedStandardCompare($1.key) == .orderedAscending } + #expect(viewModel.key == variable.key) #expect(viewModel.displayName == metadata.displayName) #expect(viewModel.contentTypeName == variable.contentTypeName) #expect(viewModel.variableTypeName == variable.destinationTypeName) - #expect(viewModel.metadataEntries == metadata.displayTextEntries) + #expect(viewModel.metadataEntries == expectedMetadataEntries) #expect(viewModel.isSecret == isSecret) - #expect(viewModel.editorControl == .textField) + #expect(viewModel.editorControl == (metadata.isEditable ? .textField : nil)) }