@@ -29,13 +29,17 @@ const { t } = i18next
29
29
30
30
// It renders the workspace page and waits for it be loaded
31
31
const renderWorkspacePage = async ( ) => {
32
+ console . time ( "initial render" )
32
33
jest . spyOn ( api , "getTemplate" ) . mockResolvedValueOnce ( MockTemplate )
33
34
jest . spyOn ( api , "getTemplateVersionRichParameters" ) . mockResolvedValueOnce ( [ ] )
34
35
renderWithAuth ( < WorkspacePage /> , {
35
36
route : `/@${ MockWorkspace . owner_name } /${ MockWorkspace . name } ` ,
36
37
path : "/@:username/:workspace" ,
37
38
} )
39
+ console . timeEnd ( "initial render" )
40
+ console . time ( "waitForLoaderToBeRemoved" )
38
41
await waitForLoaderToBeRemoved ( )
42
+ console . timeEnd ( "waitForLoaderToBeRemoved" )
39
43
}
40
44
41
45
/**
@@ -85,32 +89,51 @@ afterAll(() => {
85
89
} )
86
90
87
91
describe ( "WorkspacePage" , ( ) => {
88
- it ( "requests a delete job when the user presses Delete and confirms" , async ( ) => {
89
- const user = userEvent . setup ( )
90
-
92
+ it . only ( "requests a delete job when the user presses Delete and confirms" , async ( ) => {
93
+ console . time ( "render" )
94
+ const user = userEvent . setup ( { delay : 0 } )
91
95
const deleteWorkspaceMock = jest
92
96
. spyOn ( api , "deleteWorkspace" )
93
97
. mockResolvedValueOnce ( MockWorkspaceBuild )
94
98
await renderWorkspacePage ( )
99
+ console . timeEnd ( "render" )
95
100
101
+ console . time ( "open popover" )
96
102
// open the workspace action popover so we have access to all available ctas
97
103
const trigger = await screen . findByTestId ( "workspace-actions-button" )
98
104
await user . click ( trigger )
105
+ console . timeEnd ( "open popover" )
99
106
107
+ console . time ( "click on delete" )
100
108
const buttonText = t ( "actionButton.delete" , { ns : "workspacePage" } )
101
109
const button = await screen . findByText ( buttonText )
102
110
await user . click ( button )
111
+ console . timeEnd ( "click on delete" )
103
112
113
+ console . time ( "confirm dialog" )
114
+ console . time ( "first time to dialog shows up" )
104
115
const labelText = t ( "deleteDialog.confirmLabel" , {
105
116
ns : "common" ,
106
117
entity : "workspace" ,
107
118
} )
108
119
const textField = await screen . findByLabelText ( labelText )
120
+ console . timeEnd ( "first time to dialog shows up" )
121
+ console . time ( "type name" )
109
122
await user . type ( textField , MockWorkspace . name )
110
- const confirmButton = await screen . findByRole ( "button" , { name : "Delete" } )
123
+ console . timeEnd ( "type name" )
124
+ console . time ( "click on confirm" )
125
+ console . time ( "find button" )
126
+ const confirmButton = screen . getByRole ( "button" , {
127
+ name : "Delete" ,
128
+ hidden : false ,
129
+ } )
130
+ console . timeEnd ( "find button" )
131
+ console . time ( "click on confirm (Action)" )
111
132
await user . click ( confirmButton )
133
+ console . timeEnd ( "click on confirm (Action)" )
134
+ console . timeEnd ( "click on confirm" )
112
135
expect ( deleteWorkspaceMock ) . toBeCalled ( )
113
- // This test takes long to finish
136
+ console . timeEnd ( "confirm dialog" )
114
137
} , 20_000 )
115
138
116
139
it ( "requests a start job when the user presses Start" , async ( ) => {
0 commit comments