44using PrompterOne . Core . Models . Workspace ;
55using PrompterOne . Shared . Contracts ;
66using PrompterOne . Shared . Pages ;
7+ using PrompterOne . Shared . Services ;
78using PrompterOne . Shared . Tests ;
89
910namespace PrompterOne . Web . Tests ;
@@ -140,6 +141,32 @@ public void EditorPage_MetadataRailToggleCollapsesAndExpands()
140141 } ) ;
141142 }
142143
144+ [ Test ]
145+ public async Task EditorPage_LoadUsesSessionTitle_WhenPersistedFrontMatterTitleDiffers ( )
146+ {
147+ var document = await _harness . Repository . SaveAsync (
148+ EditorMetadataTestSource . ImportedFileStemTitle ,
149+ EditorMetadataTestSource . ConflictingImportedDocument ,
150+ EditorMetadataTestSource . ImportedDocumentName ) ;
151+
152+ Services . GetRequiredService < NavigationManager > ( )
153+ . NavigateTo ( AppRoutes . EditorWithId ( document . Id ) ) ;
154+ var cut = Render < EditorPage > ( ) ;
155+
156+ cut . WaitForAssertion ( ( ) =>
157+ {
158+ var visibleSource = cut . FindByTestId ( UiTestIds . Editor . SourceInput ) . GetAttribute ( "value" ) ?? string . Empty ;
159+ var shellState = Services . GetRequiredService < AppShellService > ( ) . State ;
160+
161+ Assert . Equal (
162+ EditorMetadataTestSource . ImportedFileStemTitle ,
163+ cut . FindByTestId ( UiTestIds . Editor . Title ) . GetAttribute ( "value" ) ) ;
164+ Assert . Equal ( EditorMetadataTestSource . ImportedFileStemTitle , shellState . Title ) ;
165+ Assert . Contains ( EditorMetadataTestSource . ImportedHeading , visibleSource , StringComparison . Ordinal ) ;
166+ Assert . DoesNotContain ( EditorMetadataTestSource . TitleField , visibleSource , StringComparison . Ordinal ) ;
167+ } ) ;
168+ }
169+
143170 private static class EditorMetadataTestSource
144171 {
145172 public const string AuthorField = "author:" ;
@@ -154,11 +181,24 @@ private static class EditorMetadataTestSource
154181 public const string ProfileRsvp = "RSVP" ;
155182 public const string RetitledScript = "Renamed Product Launch" ;
156183 public const string RightChevronDirection = "right" ;
184+ public const string ImportedDocumentName = "Imported Design Review From File Name With A Long Header Title That Should Clamp Cleanly In Editor.tps.md" ;
185+ public const string ImportedFileStemTitle = "Imported Design Review From File Name With A Long Header Title That Should Clamp Cleanly In Editor" ;
186+ public const string ImportedHeading = "Converted heading should stay inside the editor body instead of becoming the shell title" ;
157187 public const string TitleField = "title:" ;
158188 public const string TitlePersistenceLine = "title: \" Renamed Product Launch\" " ;
159189 public const string TrueText = "true" ;
160190 public const string UntitledTitlePersistenceLine = "title: \" Untitled Script\" " ;
161191 public const string VersionField = "version:" ;
162192 public const string VersionPersistenceLine = "version: \" 2.0\" " ;
193+ public const string ConflictingImportedDocument =
194+ """
195+ ---
196+ title: "Converted heading should stay inside the editor body instead of becoming the shell title"
197+ ---
198+
199+ # Converted heading should stay inside the editor body instead of becoming the shell title
200+
201+ MarkItDown should convert this DOCX paragraph into Markdown for the editor.
202+ """ ;
163203 }
164204}
0 commit comments