11import type { File , Task } from '@vitest/runner'
22import type { Params } from './params'
3- import { client , config , findById } from './client'
3+ import { browserState , client , config , findById } from './client'
44import { testRunState } from './client/state'
5+ import { viewport } from './browser'
56import { activeFileId , lineNumber , selectedTest , viewMode } from './params'
67
78export const currentModule = ref < File > ( )
@@ -22,7 +23,13 @@ export const mainSizes = useLocalStorage<[left: number, right: number]>(
2223)
2324export const detailSizes = useLocalStorage < [ left : number , right : number ] > (
2425 'vitest-ui_splitpanes-detailSizes' ,
25- [ 33 , 67 ] ,
26+ [
27+ // @ts -expect-error "browserState" is not initialised yet
28+ window . __vitest_browser_runner__ ?. provider === 'webdriverio'
29+ ? ( ( viewport . value [ 0 ] / window . outerWidth ) * 100 )
30+ : 33 ,
31+ 67 ,
32+ ] ,
2633)
2734
2835// live sizes of panels in percentage
@@ -125,14 +132,45 @@ export function hideRightPanel() {
125132 detailSizes . value = [ 100 , 0 ]
126133}
127134
135+ function calculateBrowserPanel ( ) {
136+ // we don't scale webdriverio provider because it doesn't support scaling
137+ // TODO: find a way to make this universal - maybe show browser separetly(?)
138+ if ( browserState ?. provider === 'webdriverio' ) {
139+ const parentWindow = window . outerWidth * ( panels . details . size / 100 )
140+ // 40 is 20px padding for each sice
141+ const tabWidth = ( ( viewport . value [ 0 ] + 20 ) / parentWindow ) * 100
142+ return tabWidth
143+ }
144+ return 33
145+ }
146+
128147export function showRightPanel ( ) {
129- panels . details . browser = 33
130- panels . details . main = 67
131- detailSizes . value = [ 33 , 67 ]
148+ panels . details . browser = calculateBrowserPanel ( )
149+ panels . details . main = 100 - panels . details . browser
150+ detailSizes . value = [
151+ panels . details . browser ,
152+ panels . details . main ,
153+ ]
132154}
133155
134156export function showNavigationPanel ( ) {
135157 panels . navigation = 33
136158 panels . details . size = 67
137159 mainSizes . value = [ 33 , 67 ]
138160}
161+
162+ export function updateBrowserPanel ( ) {
163+ // we don't need to change the size of the browser panel if the right
164+ // panel is hidden
165+ if ( panels . details . main === 0 ) {
166+ return
167+ }
168+
169+ panels . details . browser = calculateBrowserPanel ( )
170+ panels . details . main = 100 - panels . details . browser
171+
172+ detailSizes . value = [
173+ panels . details . browser ,
174+ panels . details . main ,
175+ ]
176+ }
0 commit comments