@@ -116,6 +116,136 @@ function tests(context, compare) {
116116 `${ context } -restore-workspace-is-symmetric-with-addviewer.txt`
117117 ) ;
118118 } ) ;
119+
120+ test . describe ( "Toggle master/detail" , ( ) => {
121+ test ( "restore a blank view removes master panel" , async ( { page } ) => {
122+ const config = {
123+ detail : {
124+ main : {
125+ type : "tab-area" ,
126+ widgets : [ "PERSPECTIVE_GENERATED_ID_1" ] ,
127+ currentIndex : 0 ,
128+ } ,
129+ } ,
130+ master : { widgets : [ "PERSPECTIVE_GENERATED_ID_0" ] , sizes : [ 1 ] } ,
131+ viewers : {
132+ PERSPECTIVE_GENERATED_ID_0 : {
133+ table : "superstore" ,
134+ } ,
135+ PERSPECTIVE_GENERATED_ID_1 : {
136+ table : "superstore" ,
137+ } ,
138+ } ,
139+ } ;
140+
141+ const empty_config = {
142+ detail : { } ,
143+ viewers : { } ,
144+ } ;
145+
146+ const x = await page . evaluate ( async ( config ) => {
147+ const workspace = document . getElementById ( "workspace" ) ;
148+ await workspace . restore ( config ) ;
149+ await workspace . flush ( ) ;
150+ return workspace . outerHTML ;
151+ } , config ) ;
152+
153+ test . expect ( x ) . toEqual (
154+ '<perspective-workspace id="workspace"><perspective-viewer slot="PERSPECTIVE_GENERATED_ID_1" table="superstore" theme="Pro Light"><perspective-viewer-datagrid style="position: absolute; inset: 0px; opacity: 1;" class="edit-mode-allowed" data-edit-mode="READ_ONLY"></perspective-viewer-datagrid><perspective-viewer-datagrid-toolbar slot="plugin-settings"></perspective-viewer-datagrid-toolbar></perspective-viewer><perspective-viewer slot="PERSPECTIVE_GENERATED_ID_0" table="superstore" class="workspace-master-widget" selectable="" theme="Pro Light"><perspective-viewer-datagrid style="position: absolute; inset: 0px; opacity: 1;" data-edit-mode="READ_ONLY"></perspective-viewer-datagrid><perspective-viewer-datagrid-toolbar slot="plugin-settings"></perspective-viewer-datagrid-toolbar></perspective-viewer></perspective-workspace>'
155+ ) ;
156+
157+ await page . evaluate ( async ( config ) => {
158+ const workspace = document . getElementById ( "workspace" ) ;
159+ await workspace . restore ( config ) ;
160+ await workspace . flush ( ) ;
161+ } , empty_config ) ;
162+
163+ return compare (
164+ page ,
165+ `${ context } -restore-a-blank-view-removes-master-panel.txt`
166+ ) ;
167+ } ) ;
168+
169+ test ( "restore a view which reuses a master viewer, removes master panel" , async ( {
170+ page,
171+ } ) => {
172+ const config = {
173+ detail : {
174+ main : {
175+ type : "tab-area" ,
176+ widgets : [ "PERSPECTIVE_GENERATED_ID_1" ] ,
177+ currentIndex : 0 ,
178+ } ,
179+ } ,
180+ master : { widgets : [ "PERSPECTIVE_GENERATED_ID_0" ] , sizes : [ 1 ] } ,
181+ viewers : {
182+ PERSPECTIVE_GENERATED_ID_0 : {
183+ table : "superstore" ,
184+ title : "One" ,
185+ } ,
186+ PERSPECTIVE_GENERATED_ID_1 : {
187+ table : "superstore" ,
188+ title : "Two" ,
189+ } ,
190+ } ,
191+ } ;
192+
193+ const config2 = {
194+ detail : {
195+ main : {
196+ type : "split-area" ,
197+ orientation : "horizontal" ,
198+ children : [
199+ {
200+ type : "tab-area" ,
201+ widgets : [ "PERSPECTIVE_GENERATED_ID_0" ] ,
202+ currentIndex : 0 ,
203+ } ,
204+ {
205+ type : "tab-area" ,
206+ widgets : [ "PERSPECTIVE_GENERATED_ID_1" ] ,
207+ currentIndex : 0 ,
208+ } ,
209+ ] ,
210+ sizes : [ 0.5 , 0.5 ] ,
211+ } ,
212+ } ,
213+ master : { widgets : [ ] , sizes : [ ] } ,
214+ viewers : {
215+ PERSPECTIVE_GENERATED_ID_0 : {
216+ table : "superstore" ,
217+ title : "One" ,
218+ } ,
219+ PERSPECTIVE_GENERATED_ID_1 : {
220+ table : "superstore" ,
221+ title : "Two" ,
222+ } ,
223+ } ,
224+ } ;
225+
226+ const x = await page . evaluate ( async ( config ) => {
227+ const workspace = document . getElementById ( "workspace" ) ;
228+ await workspace . restore ( config ) ;
229+ await workspace . flush ( ) ;
230+ return workspace . outerHTML ;
231+ } , config ) ;
232+
233+ test . expect ( x ) . toEqual (
234+ '<perspective-workspace id="workspace"><perspective-viewer slot="PERSPECTIVE_GENERATED_ID_1" table="superstore" theme="Pro Light"><perspective-viewer-datagrid style="position: absolute; inset: 0px; opacity: 1;" class="edit-mode-allowed" data-edit-mode="READ_ONLY"></perspective-viewer-datagrid><perspective-viewer-datagrid-toolbar slot="plugin-settings"></perspective-viewer-datagrid-toolbar></perspective-viewer><perspective-viewer slot="PERSPECTIVE_GENERATED_ID_0" table="superstore" class="workspace-master-widget" selectable="" theme="Pro Light"><perspective-viewer-datagrid style="position: absolute; inset: 0px; opacity: 1;" data-edit-mode="READ_ONLY"></perspective-viewer-datagrid><perspective-viewer-datagrid-toolbar slot="plugin-settings"></perspective-viewer-datagrid-toolbar></perspective-viewer></perspective-workspace>'
235+ ) ;
236+
237+ await page . evaluate ( async ( config ) => {
238+ const workspace = document . getElementById ( "workspace" ) ;
239+ await workspace . restore ( config ) ;
240+ await workspace . flush ( ) ;
241+ } , config2 ) ;
242+
243+ return compare (
244+ page ,
245+ `${ context } -restore-which-reseats-master-viewer.txt`
246+ ) ;
247+ } ) ;
248+ } ) ;
119249}
120250
121251test . describe ( "Workspace restore" , ( ) => {
0 commit comments