@@ -241,13 +241,14 @@ define(function (require, exports, module) {
241241 // Should show directory information for external files
242242 expect ( directorySpan . length ) . toBe ( 1 ) ;
243243
244- const displayedPath = directorySpan [ 0 ] . innerHTML ;
245- expect ( displayedPath . length ) . toBeGreaterThan ( 0 ) ;
246- expect ( displayedPath . includes ( " — " ) ) . toBe ( true ) ; // Should have the separator
244+ // Verify the title attribute contains the full display path
245+ const fullDisplayPath = directorySpan . attr ( 'title' ) ;
246+ expect ( fullDisplayPath ) . toBe ( testWindow . Phoenix . app . getDisplayPath ( externalProjectTestPath ) ) ;
247247
248- // Should contain some path information
249- const actualPath = testWindow . Phoenix . app . getDisplayPath ( externalProjectTestPath ) ;
250- expect ( actualPath . length ) . toBeGreaterThan ( 0 ) ;
248+ // Verify the displayed text contains the expected format
249+ const displayedText = directorySpan . text ( ) ;
250+ expect ( displayedText . length ) . toBeGreaterThan ( 0 ) ;
251+ expect ( displayedText . includes ( " — " ) ) . toBe ( true ) ; // Should have the separator
251252
252253 // Clean up
253254 DocumentManager . getCurrentDocument ( ) . _markClean ( ) ;
@@ -258,44 +259,46 @@ define(function (require, exports, module) {
258259 it ( "should truncate very long external file paths with ellipsis" , async function ( ) {
259260 // Create platform-appropriate test paths
260261 var isWindows = testWindow . brackets . platform === "win" ;
262+ var isMac = testWindow . brackets . platform === "mac" ;
261263 var separator = isWindows ? "\\" : "/" ;
262-
263- // Test truncation algorithm with platform-specific long path
264- var mockLongPath = isWindows ?
265- "C:\\Users\\username\\very\\long\\path\\structure\\with\\many\\nested\\directories" :
266- "/Users/username/very/long/path/structure/with/many/nested/directories" ;
267-
268- var segments = mockLongPath . split ( / [ \/ \\ ] / ) . filter ( seg => seg . length > 0 ) ;
269- expect ( segments . length ) . toBeGreaterThan ( 3 ) ; // Ensure we have a long path
270-
271- // Test the truncation logic that WorkingSetView should use
272- var rootDirName = segments [ 0 ] ? segments [ 0 ] : segments [ 1 ] ;
273- var truncated = rootDirName + separator + "…" + separator + segments [ segments . length - 1 ] ;
274-
275- // Verify truncation works correctly
276- expect ( truncated . includes ( "…" ) ) . toBe ( true ) ;
277- expect ( truncated . includes ( segments [ 0 ] ) ) . toBe ( true ) ;
278- expect ( truncated . includes ( segments [ segments . length - 1 ] ) ) . toBe ( true ) ;
279- expect ( truncated ) . not . toContain ( "very" + separator + "long" + separator + "path" ) ;
264+ var isNativeApp = testWindow . Phoenix . isNativeApp ;
265+
266+ // Define expected path formats for different environments
267+ var mockLongPath , expectedTruncatedPath ;
268+
269+ if ( isNativeApp ) {
270+ // Desktop app path formats
271+ if ( isWindows ) {
272+ mockLongPath = "C:\\Users\\TestUser\\Documents\\Very\\Long\\Project\\Structure\\Directory" ;
273+ expectedTruncatedPath = "C:" + separator + "…" + separator + "Directory" ;
274+ } else if ( isMac ) {
275+ mockLongPath = "/Users/TestUser/Documents/Very/Long/Project/Structure/Directory" ;
276+ expectedTruncatedPath = "Users" + separator + "…" + separator + "Directory" ;
277+ } else { // Linux
278+ mockLongPath = "/home/TestUser/Documents/Very/Long/Project/Structure/Directory" ;
279+ expectedTruncatedPath = "home" + separator + "…" + separator + "Directory" ;
280+ }
281+ } else {
282+ // Browser path formats
283+ if ( isWindows ) {
284+ // For default/internal projects in browser
285+ mockLongPath = "/fs/Users/TestUser/Documents/Very/Long/Project/Structure/Directory" ;
286+ expectedTruncatedPath = "fs" + separator + "…" + separator + "Directory" ;
287+ } else {
288+ // For Mac/Linux in browser
289+ mockLongPath = "/fs/home/TestUser/Documents/Very/Long/Project/Structure/Directory" ;
290+ expectedTruncatedPath = "fs" + separator + "…" + separator + "Directory" ;
291+ }
292+ }
280293
281294 // Now test the actual WorkingSetView implementation with a guaranteed long path
282295 var workingSetListItemCountBeforeTest = workingSetListItemCount ;
283296
284- // Mock Phoenix.app.getDisplayPath to return a platform-appropriate long path
297+ // Mock Phoenix.app.getDisplayPath to return our test path
285298 var originalGetDisplayPath = testWindow . Phoenix . app . getDisplayPath ;
286- var mockLongDisplayPath = isWindows ?
287- "C:\\Users\\TestUser\\Documents\\Very\\Long\\Project\\Structure\\Directory" :
288- "/Users/TestUser/Documents/Very/Long/Project/Structure/Directory" ;
289-
290- // Extract expected parts for assertions
291- var mockSegments = mockLongDisplayPath . split ( / [ \/ \\ ] / ) . filter ( seg => seg . length > 0 ) ;
292- var firstSegment = mockSegments [ 0 ] ;
293- var lastSegment = mockSegments [ mockSegments . length - 1 ] ;
294- var middleSegments = isWindows ? "Very\\Long\\Project\\Structure" : "Very/Long/Project/Structure" ;
295-
296299 testWindow . Phoenix . app . getDisplayPath = function ( path ) {
297300 if ( path . includes ( externalProjectTestPath ) ) {
298- return mockLongDisplayPath ;
301+ return mockLongPath ;
299302 }
300303 return originalGetDisplayPath . call ( this , path ) ;
301304 } ;
@@ -310,18 +313,18 @@ define(function (require, exports, module) {
310313 const directorySpan = $list . find ( ".directory" ) ;
311314 expect ( directorySpan . length ) . toBe ( 1 ) ;
312315
313- const displayedPath = directorySpan [ 0 ] . innerHTML ;
314- expect ( displayedPath . includes ( " — " ) ) . toBe ( true ) ;
316+ // Verify the title attribute contains the full display path
317+ const fullDisplayPath = directorySpan . attr ( 'title' ) ;
318+ expect ( fullDisplayPath ) . toBe ( mockLongPath ) ;
315319
316- // This is the critical test - if truncation is working, it MUST contain ellipsis
317- expect ( displayedPath . includes ( "…" ) ) . toBe ( true ) ;
320+ // Get the displayed text
321+ const displayedText = directorySpan . text ( ) ;
318322
319- // Should show first and last segments (platform-appropriate)
320- expect ( displayedPath . includes ( firstSegment ) ) . toBe ( true ) ;
321- expect ( displayedPath . includes ( lastSegment ) ) . toBe ( true ) ;
323+ // This is the critical test - if truncation is working, it MUST contain ellipsis
324+ expect ( displayedText . includes ( "…" ) ) . toBe ( true ) ;
322325
323- // Should NOT show the full middle path
324- expect ( displayedPath . includes ( middleSegments ) ) . toBe ( false ) ;
326+ // Should match our expected truncated path format
327+ expect ( displayedText . includes ( expectedTruncatedPath ) ) . toBe ( true ) ;
325328
326329 // Clean up
327330 DocumentManager . getCurrentDocument ( ) . _markClean ( ) ;
0 commit comments