@@ -1775,6 +1775,254 @@ define(function (require, exports, module) {
17751775 } ) ;
17761776 } ) ;
17771777
1778+ describe ( "Number of Tabs Preference" , function ( ) {
1779+ beforeEach ( async function ( ) {
1780+ // Enable the tab bar feature with default settings
1781+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : - 1 } ) ;
1782+
1783+ // Close all files to start with a clean state
1784+ await testWindow . closeAllFiles ( ) ;
1785+ } ) ;
1786+
1787+ afterEach ( async function ( ) {
1788+ // Reset preferences to default
1789+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : - 1 } ) ;
1790+ } ) ;
1791+
1792+ it ( "should show all tabs when numberOfTabs is set to -1" , async function ( ) {
1793+ // Create several test files
1794+ const testFiles = [ ] ;
1795+ for ( let i = 0 ; i < 10 ; i ++ ) {
1796+ const filePath = SpecRunnerUtils . getTempDirectory ( ) + `/number-test-${ i } .js` ;
1797+ testFiles . push ( filePath ) ;
1798+ await jsPromise ( SpecRunnerUtils . createTextFile ( filePath , `// Number test file ${ i } ` , FileSystem ) ) ;
1799+ }
1800+
1801+ // Open all the test files
1802+ for ( const filePath of testFiles ) {
1803+ await awaitsForDone (
1804+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath } ) ,
1805+ `Open file ${ filePath } `
1806+ ) ;
1807+ }
1808+
1809+ // Wait for all tabs to appear
1810+ await awaitsFor (
1811+ function ( ) {
1812+ return getTabCount ( ) >= testFiles . length ;
1813+ } ,
1814+ "All tabs to appear" ,
1815+ 1000
1816+ ) ;
1817+
1818+ // Verify all tabs are shown
1819+ expect ( getTabCount ( ) ) . toBe ( testFiles . length ) ;
1820+
1821+ // Clean up - close all the test files
1822+ for ( const filePath of testFiles ) {
1823+ const fileToClose = FileSystem . getFileForPath ( filePath ) ;
1824+ const promise = CommandManager . execute ( Commands . FILE_CLOSE , { file : fileToClose } ) ;
1825+ testWindow . brackets . test . Dialogs . cancelModalDialogIfOpen (
1826+ testWindow . brackets . test . DefaultDialogs . DIALOG_ID_SAVE_CLOSE ,
1827+ testWindow . brackets . test . DefaultDialogs . DIALOG_BTN_DONTSAVE
1828+ ) ;
1829+ await awaitsForDone ( promise , `Close file ${ filePath } ` ) ;
1830+ }
1831+ } ) ;
1832+
1833+ it ( "should limit the number of tabs shown when numberOfTabs is set to a positive value" , async function ( ) {
1834+ // Set the preference to show only 5 tabs
1835+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : 5 } ) ;
1836+
1837+ // Create several test files
1838+ const testFiles = [ ] ;
1839+ for ( let i = 0 ; i < 10 ; i ++ ) {
1840+ const filePath = SpecRunnerUtils . getTempDirectory ( ) + `/number-test-${ i } .js` ;
1841+ testFiles . push ( filePath ) ;
1842+ await jsPromise ( SpecRunnerUtils . createTextFile ( filePath , `// Number test file ${ i } ` , FileSystem ) ) ;
1843+ }
1844+
1845+ // Open all the test files
1846+ for ( const filePath of testFiles ) {
1847+ await awaitsForDone (
1848+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath } ) ,
1849+ `Open file ${ filePath } `
1850+ ) ;
1851+ }
1852+
1853+ // Wait for tabs to appear
1854+ await awaitsFor (
1855+ function ( ) {
1856+ return getTabCount ( ) > 0 ;
1857+ } ,
1858+ "Tabs to appear" ,
1859+ 1000
1860+ ) ;
1861+
1862+ // Verify only 5 tabs are shown
1863+ expect ( getTabCount ( ) ) . toBe ( 5 ) ;
1864+
1865+ // Clean up - close all the test files
1866+ for ( const filePath of testFiles ) {
1867+ const fileToClose = FileSystem . getFileForPath ( filePath ) ;
1868+ const promise = CommandManager . execute ( Commands . FILE_CLOSE , { file : fileToClose } ) ;
1869+ testWindow . brackets . test . Dialogs . cancelModalDialogIfOpen (
1870+ testWindow . brackets . test . DefaultDialogs . DIALOG_ID_SAVE_CLOSE ,
1871+ testWindow . brackets . test . DefaultDialogs . DIALOG_BTN_DONTSAVE
1872+ ) ;
1873+ await awaitsForDone ( promise , `Close file ${ filePath } ` ) ;
1874+ }
1875+ } ) ;
1876+
1877+ it ( "should hide the tab bar when numberOfTabs is set to 0" , async function ( ) {
1878+ // First open some files with the default setting
1879+ const testFiles = [ ] ;
1880+ for ( let i = 0 ; i < 3 ; i ++ ) {
1881+ const filePath = SpecRunnerUtils . getTempDirectory ( ) + `/number-test-${ i } .js` ;
1882+ testFiles . push ( filePath ) ;
1883+ await jsPromise ( SpecRunnerUtils . createTextFile ( filePath , `// Number test file ${ i } ` , FileSystem ) ) ;
1884+ }
1885+
1886+ // Open all the test files
1887+ for ( const filePath of testFiles ) {
1888+ await awaitsForDone (
1889+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath } ) ,
1890+ `Open file ${ filePath } `
1891+ ) ;
1892+ }
1893+
1894+ // Wait for tabs to appear
1895+ await awaitsFor (
1896+ function ( ) {
1897+ return getTabCount ( ) > 0 ;
1898+ } ,
1899+ "Tabs to appear" ,
1900+ 1000
1901+ ) ;
1902+
1903+ // Verify tab bar is visible
1904+ expect ( $ ( "#phoenix-tab-bar" ) . is ( ":visible" ) ) . toBe ( true ) ;
1905+
1906+ // Now set numberOfTabs to 0
1907+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : 0 } ) ;
1908+
1909+ // Wait for tab bar to disappear
1910+ await awaitsFor (
1911+ function ( ) {
1912+ return ! $ ( "#phoenix-tab-bar" ) . is ( ":visible" ) ;
1913+ } ,
1914+ "Tab bar to disappear" ,
1915+ 1000
1916+ ) ;
1917+
1918+ // Verify tab bar is hidden
1919+ expect ( $ ( "#phoenix-tab-bar" ) . is ( ":visible" ) ) . toBe ( false ) ;
1920+
1921+ // Clean up - close all the test files
1922+ for ( const filePath of testFiles ) {
1923+ const fileToClose = FileSystem . getFileForPath ( filePath ) ;
1924+ const promise = CommandManager . execute ( Commands . FILE_CLOSE , { file : fileToClose } ) ;
1925+ testWindow . brackets . test . Dialogs . cancelModalDialogIfOpen (
1926+ testWindow . brackets . test . DefaultDialogs . DIALOG_ID_SAVE_CLOSE ,
1927+ testWindow . brackets . test . DefaultDialogs . DIALOG_BTN_DONTSAVE
1928+ ) ;
1929+ await awaitsForDone ( promise , `Close file ${ filePath } ` ) ;
1930+ }
1931+ } ) ;
1932+
1933+ it ( "should apply numberOfTabs preference to both panes" , async function ( ) {
1934+ // Set up split pane layout
1935+ MainViewManager . setLayoutScheme ( 1 , 2 ) ;
1936+
1937+ // Set the preference to show only 3 tabs
1938+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : 3 } ) ;
1939+
1940+ // Create test files for first pane
1941+ const firstPaneFiles = [ ] ;
1942+ for ( let i = 0 ; i < 5 ; i ++ ) {
1943+ const filePath = SpecRunnerUtils . getTempDirectory ( ) + `/first-pane-${ i } .js` ;
1944+ firstPaneFiles . push ( filePath ) ;
1945+ await jsPromise ( SpecRunnerUtils . createTextFile ( filePath , `// First pane file ${ i } ` , FileSystem ) ) ;
1946+ }
1947+
1948+ // Create test files for second pane
1949+ const secondPaneFiles = [ ] ;
1950+ for ( let i = 0 ; i < 5 ; i ++ ) {
1951+ const filePath = SpecRunnerUtils . getTempDirectory ( ) + `/second-pane-${ i } .js` ;
1952+ secondPaneFiles . push ( filePath ) ;
1953+ await jsPromise ( SpecRunnerUtils . createTextFile ( filePath , `// Second pane file ${ i } ` , FileSystem ) ) ;
1954+ }
1955+
1956+ // Open files in first pane
1957+ for ( const filePath of firstPaneFiles ) {
1958+ await awaitsForDone (
1959+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath , paneId : "first-pane" } ) ,
1960+ `Open file ${ filePath } in first pane`
1961+ ) ;
1962+ }
1963+
1964+ // Open files in second pane
1965+ for ( const filePath of secondPaneFiles ) {
1966+ await awaitsForDone (
1967+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath , paneId : "second-pane" } ) ,
1968+ `Open file ${ filePath } in second pane`
1969+ ) ;
1970+ }
1971+
1972+ // Wait for both tab bars to appear
1973+ await awaitsFor (
1974+ function ( ) {
1975+ return $ ( "#phoenix-tab-bar" ) . is ( ":visible" ) && $ ( "#phoenix-tab-bar-2" ) . is ( ":visible" ) ;
1976+ } ,
1977+ "Both tab bars to appear" ,
1978+ 1000
1979+ ) ;
1980+
1981+ // Verify each pane shows only 3 tabs
1982+ expect ( $ ( "#phoenix-tab-bar" ) . find ( ".tab" ) . length ) . toBe ( 3 ) ;
1983+ expect ( $ ( "#phoenix-tab-bar-2" ) . find ( ".tab" ) . length ) . toBe ( 3 ) ;
1984+
1985+ // Change preference to show all tabs
1986+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : - 1 } ) ;
1987+
1988+ // Wait for all tabs to appear
1989+ await awaitsFor (
1990+ function ( ) {
1991+ return (
1992+ $ ( "#phoenix-tab-bar" ) . find ( ".tab" ) . length === 5 &&
1993+ $ ( "#phoenix-tab-bar-2" ) . find ( ".tab" ) . length === 5
1994+ ) ;
1995+ } ,
1996+ "All tabs to appear in both panes" ,
1997+ 1000
1998+ ) ;
1999+
2000+ // Verify all tabs are shown in both panes
2001+ expect ( $ ( "#phoenix-tab-bar" ) . find ( ".tab" ) . length ) . toBe ( 5 ) ;
2002+ expect ( $ ( "#phoenix-tab-bar-2" ) . find ( ".tab" ) . length ) . toBe ( 5 ) ;
2003+
2004+ // Change preference to hide tab bars
2005+ PreferencesManager . set ( "tabBar.options" , { showTabBar : true , numberOfTabs : 0 } ) ;
2006+
2007+ // Wait for both tab bars to disappear
2008+ await awaitsFor (
2009+ function ( ) {
2010+ return ! $ ( "#phoenix-tab-bar" ) . is ( ":visible" ) && ! $ ( "#phoenix-tab-bar-2" ) . is ( ":visible" ) ;
2011+ } ,
2012+ "Both tab bars to disappear" ,
2013+ 1000
2014+ ) ;
2015+
2016+ // Verify both tab bars are hidden
2017+ expect ( $ ( "#phoenix-tab-bar" ) . is ( ":visible" ) ) . toBe ( false ) ;
2018+ expect ( $ ( "#phoenix-tab-bar-2" ) . is ( ":visible" ) ) . toBe ( false ) ;
2019+
2020+ // Clean up - close all files and reset to single pane
2021+ await testWindow . closeAllFiles ( ) ;
2022+ MainViewManager . setLayoutScheme ( 1 , 1 ) ;
2023+ } ) ;
2024+ } ) ;
2025+
17782026 describe ( "Split Panes" , function ( ) {
17792027 beforeEach ( async function ( ) {
17802028 // Enable the tab bar feature
0 commit comments