@@ -8012,19 +8012,27 @@ describe('BrowserWindow module', () => {
80128012
80138013 // FIXME(nilayarya): Figure out why these tests fail on macOS-x64
80148014 // virtualDisplay.create() is creating double displays on macOS-x64
8015- ifdescribe ( process . platform === 'darwin' && process . arch === 'arm64' ) ( 'multi-monitor tests' , ( ) => {
8015+ const testMultiMonitor =
8016+ process . platform === 'darwin' &&
8017+ process . arch === 'arm64' &&
8018+ screen . getAllDisplays ( ) . length === 1 ;
8019+
8020+ ifdescribe ( testMultiMonitor ) ( 'multi-monitor tests' , ( ) => {
80168021 const virtualDisplay = require ( '@electron-ci/virtual-display' ) ;
80178022 const primaryDisplay = screen . getPrimaryDisplay ( ) ;
80188023
8019- beforeEach ( ( ) => {
8024+ beforeEach ( async ( ) => {
80208025 virtualDisplay . forceCleanup ( ) ;
8026+ let attempts = 0 ;
8027+ while ( screen . getAllDisplays ( ) . length > 1 && attempts ++ < 20 ) await setTimeout ( 1000 ) ;
8028+ const displayCount = screen . getAllDisplays ( ) . length ;
8029+ // We expect only the primary display to be present
8030+ expect ( displayCount ) . to . equal ( 1 , `Display cleanup failed: ${ displayCount } displays remain` ) ;
80218031 } ) ;
80228032
80238033 it ( 'should restore window bounds correctly on a secondary display' , async ( ) => {
80248034 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
80258035 const targetDisplayY = primaryDisplay . bounds . y ;
8026- // We expect only the primary display to be present before the tests start
8027- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
80288036
80298037 // Create a new virtual target display to the right of the primary display
80308038 const targetDisplayId = virtualDisplay . create ( {
@@ -8068,8 +8076,6 @@ describe('BrowserWindow module', () => {
80688076 it ( 'should restore window to a visible location when saved display no longer exists' , async ( ) => {
80698077 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
80708078 const targetDisplayY = primaryDisplay . bounds . y ;
8071- // We expect only the primary display to be present before the tests start
8072- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
80738079
80748080 // Create a new virtual target display to the right of the primary display
80758081 const targetDisplayId = virtualDisplay . create ( {
@@ -8123,8 +8129,6 @@ describe('BrowserWindow module', () => {
81238129 it ( 'should fallback to nearest display when saved display no longer exists' , async ( ) => {
81248130 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
81258131 const targetDisplayY = primaryDisplay . bounds . y ;
8126- // We expect only the primary display to be present before the tests start
8127- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
81288132
81298133 // Create first virtual display to the right of primary
81308134 const middleDisplayId = virtualDisplay . create ( {
@@ -8191,8 +8195,6 @@ describe('BrowserWindow module', () => {
81918195 it ( 'should restore multiple named windows independently across displays' , async ( ) => {
81928196 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
81938197 const targetDisplayY = primaryDisplay . bounds . y ;
8194- // We expect only the primary display to be present before the tests start
8195- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
81968198
81978199 // Create a first virtual display to the right of the primary display
81988200 const targetDisplayId1 = virtualDisplay . create ( {
@@ -8306,8 +8308,6 @@ describe('BrowserWindow module', () => {
83068308 it ( 'should restore fullscreen state on correct display' , async ( ) => {
83078309 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
83088310 const targetDisplayY = primaryDisplay . bounds . y ;
8309- // We expect only the primary display to be present before the tests start
8310- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
83118311
83128312 // Create a new virtual target display to the right of the primary display
83138313 const targetDisplayId = virtualDisplay . create ( {
@@ -8355,8 +8355,6 @@ describe('BrowserWindow module', () => {
83558355 it ( 'should restore maximized state on correct display' , async ( ) => {
83568356 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
83578357 const targetDisplayY = primaryDisplay . bounds . y ;
8358- // We expect only the primary display to be present before the tests start
8359- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
83608358
83618359 // Create a new virtual target display to the right of the primary display
83628360 const targetDisplayId = virtualDisplay . create ( {
@@ -8410,8 +8408,6 @@ describe('BrowserWindow module', () => {
84108408 it ( 'should restore kiosk state on correct display' , async ( ) => {
84118409 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
84128410 const targetDisplayY = primaryDisplay . bounds . y ;
8413- // We expect only the primary display to be present before the tests start
8414- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
84158411
84168412 // Create a new virtual target display to the right of the primary display
84178413 const targetDisplayId = virtualDisplay . create ( {
@@ -8459,8 +8455,6 @@ describe('BrowserWindow module', () => {
84598455 it ( 'should maintain same bounds when target display resolution increases' , async ( ) => {
84608456 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
84618457 const targetDisplayY = primaryDisplay . bounds . y ;
8462- // We expect only the primary display to be present before the tests start
8463- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
84648458
84658459 // Create initial virtual display
84668460 const targetDisplayId = virtualDisplay . create ( {
@@ -8513,9 +8507,6 @@ describe('BrowserWindow module', () => {
85138507 it ( 'should reposition and resize window when target display resolution decreases' , async ( ) => {
85148508 const targetDisplayX = primaryDisplay . bounds . x + primaryDisplay . bounds . width ;
85158509 const targetDisplayY = primaryDisplay . bounds . y ;
8516- // We expect only the primary display to be present before the tests start
8517- expect ( screen . getAllDisplays ( ) . length ) . to . equal ( 1 ) ;
8518-
85198510 // Create initial virtual display with high resolution
85208511 const targetDisplayId = virtualDisplay . create ( {
85218512 width : 2560 ,
0 commit comments