@@ -22,7 +22,7 @@ import {
2222 LocaleService ,
2323} from '@univerjs/core' ;
2424import { DocSkeletonManagerService , RichTextEditingMutation } from '@univerjs/docs' ;
25- import { DocumentEditArea , IRenderManagerService , Path } from '@univerjs/engine-render' ;
25+ import { DocumentEditArea , IRenderManagerService , Path , Rect } from '@univerjs/engine-render' ;
2626import { BehaviorSubject , Subject } from 'rxjs' ;
2727import { afterEach , describe , expect , it , vi } from 'vitest' ;
2828import { CloseHeaderFooterCommand } from '../../commands/commands/doc-header-footer.command' ;
@@ -151,8 +151,46 @@ describe('DocHeaderFooterController', () => {
151151 controller . dispose ( ) ;
152152 } ) ;
153153
154- it ( 'draws header/footer guides while editing header or footer' , ( ) => {
154+ it ( 'covers header and footer areas while editing the document body' , ( ) => {
155+ const { controller, pageRender$ } = createController ( { editArea : DocumentEditArea . BODY } ) ;
156+ const rectSpy = vi . spyOn ( Rect , 'drawWith' ) . mockImplementation ( ( ) => undefined ) ;
157+ const pathSpy = vi . spyOn ( Path , 'drawWith' ) . mockImplementation ( ( ) => undefined ) ;
158+ const textSpy = vi . spyOn ( TextBubbleShape , 'drawWith' ) . mockImplementation ( ( ) => undefined ) ;
159+ const ctx = createCtx ( ) ;
160+
161+ pageRender$ . next ( {
162+ ctx,
163+ pageLeft : 12 ,
164+ pageTop : 24 ,
165+ page : {
166+ pageWidth : 200 ,
167+ pageHeight : 300 ,
168+ marginTop : 30 ,
169+ marginBottom : 40 ,
170+ } ,
171+ } ) ;
172+
173+ expect ( ctx . translate ) . toHaveBeenCalledWith ( 11.5 , 23.5 ) ;
174+ expect ( rectSpy ) . toHaveBeenCalledTimes ( 2 ) ;
175+ expect ( rectSpy . mock . calls [ 0 ] [ 1 ] ) . toMatchObject ( {
176+ width : 200 ,
177+ height : 30 ,
178+ fill : 'alpha(white, 0.5)' ,
179+ } ) ;
180+ expect ( rectSpy . mock . calls [ 1 ] [ 1 ] ) . toMatchObject ( {
181+ width : 200 ,
182+ height : 40 ,
183+ fill : 'alpha(white, 0.5)' ,
184+ } ) ;
185+ expect ( pathSpy ) . not . toHaveBeenCalled ( ) ;
186+ expect ( textSpy ) . not . toHaveBeenCalled ( ) ;
187+
188+ controller . dispose ( ) ;
189+ } ) ;
190+
191+ it ( 'covers the body and draws header/footer guides while editing header or footer' , ( ) => {
155192 const { controller, pageRender$ } = createController ( { editArea : DocumentEditArea . HEADER } ) ;
193+ const rectSpy = vi . spyOn ( Rect , 'drawWith' ) . mockImplementation ( ( ) => undefined ) ;
156194 const pathSpy = vi . spyOn ( Path , 'drawWith' ) . mockImplementation ( ( ) => undefined ) ;
157195 const textSpy = vi . spyOn ( TextBubbleShape , 'drawWith' ) . mockImplementation ( ( ) => undefined ) ;
158196 const ctx = createCtx ( ) ;
@@ -169,6 +207,11 @@ describe('DocHeaderFooterController', () => {
169207 } ,
170208 } ) ;
171209
210+ expect ( rectSpy ) . toHaveBeenCalledWith ( ctx , expect . objectContaining ( {
211+ top : 30 ,
212+ width : 200 ,
213+ height : 230 ,
214+ } ) ) ;
172215 expect ( pathSpy ) . toHaveBeenCalledTimes ( 2 ) ;
173216 expect ( pathSpy ) . toHaveBeenCalledWith ( ctx , expect . objectContaining ( { stroke : 'primary.600' } ) ) ;
174217 expect ( textSpy ) . toHaveBeenCalledWith ( ctx , expect . objectContaining ( {
0 commit comments