1
- /*eslint eslint-comments/disable-enable-pair: error -- Remove after bottlenecks or causes of timeouts for testing have been figured out */
2
1
import { screen , waitFor } from "@testing-library/react" ;
3
2
import userEvent from "@testing-library/user-event" ;
4
3
import * as API from "api/api" ;
@@ -46,55 +45,44 @@ type FillAndSubmitConfig = {
46
45
: never ] ?: TemplateScheduleFormValues [ Key ] | undefined ;
47
46
} ;
48
47
49
- /*eslint-disable no-console -- Start benchmarks */
50
48
const fillAndSubmitForm = async ( {
51
49
default_ttl_ms,
52
50
max_ttl_ms,
53
51
failure_ttl_ms,
54
52
time_til_dormant_ms,
55
53
time_til_dormant_autodelete_ms,
56
54
} : FillAndSubmitConfig ) => {
57
- console . time ( "form - full function" ) ;
58
55
const user = userEvent . setup ( ) ;
59
56
60
- console . time ( "form - ttl" ) ;
61
57
if ( default_ttl_ms ) {
62
58
const defaultTtlField = await screen . findByLabelText (
63
59
"Default autostop (hours)" ,
64
60
) ;
65
61
await user . clear ( defaultTtlField ) ;
66
62
await user . type ( defaultTtlField , default_ttl_ms . toString ( ) ) ;
67
63
}
68
- console . timeEnd ( "form - ttl" ) ;
69
64
70
- console . time ( "form - max_ttl" ) ;
71
65
if ( max_ttl_ms ) {
72
66
const maxTtlField = await screen . findByLabelText ( "Max lifetime (hours)" ) ;
73
67
74
68
await user . clear ( maxTtlField ) ;
75
69
await user . type ( maxTtlField , max_ttl_ms . toString ( ) ) ;
76
70
}
77
- console . timeEnd ( "form - max_ttl" ) ;
78
71
79
- console . time ( "form - failure_ttl" ) ;
80
72
if ( failure_ttl_ms ) {
81
73
const failureTtlField = screen . getByRole ( "checkbox" , {
82
74
name : / F a i l u r e C l e a n u p / i,
83
75
} ) ;
84
76
await user . type ( failureTtlField , failure_ttl_ms . toString ( ) ) ;
85
77
}
86
- console . timeEnd ( "form - failure_ttl" ) ;
87
78
88
- console . time ( "form - dormant" ) ;
89
79
if ( time_til_dormant_ms ) {
90
80
const inactivityTtlField = screen . getByRole ( "checkbox" , {
91
81
name : / D o r m a n c y T h r e s h o l d / i,
92
82
} ) ;
93
83
await user . type ( inactivityTtlField , time_til_dormant_ms . toString ( ) ) ;
94
84
}
95
- console . timeEnd ( "form - dormant" ) ;
96
85
97
- console . time ( "form - auto-delete" ) ;
98
86
if ( time_til_dormant_autodelete_ms ) {
99
87
const dormancyAutoDeletionField = screen . getByRole ( "checkbox" , {
100
88
name : / D o r m a n c y A u t o - D e l e t i o n / i,
@@ -104,24 +92,16 @@ const fillAndSubmitForm = async ({
104
92
time_til_dormant_autodelete_ms . toString ( ) ,
105
93
) ;
106
94
}
107
- console . timeEnd ( "form - auto-delete" ) ;
108
95
109
- console . time ( "form - submit" ) ;
110
96
const submitButton = await screen . findByText (
111
97
FooterFormLanguage . defaultSubmitLabel ,
112
98
) ;
113
99
await user . click ( submitButton ) ;
114
- console . timeEnd ( "form - submit" ) ;
115
100
116
- console . time ( "form - confirm" ) ;
117
101
// User needs to confirm dormancy and auto-deletion fields.
118
102
const confirmButton = await screen . findByTestId ( "confirm-button" ) ;
119
103
await user . click ( confirmButton ) ;
120
- console . timeEnd ( "form - confirm" ) ;
121
-
122
- console . timeEnd ( "form - full function" ) ;
123
104
} ;
124
- /*eslint-enable no-console -- End benchmarks */
125
105
126
106
describe ( "TemplateSchedulePage" , ( ) => {
127
107
beforeEach ( ( ) => {
@@ -142,7 +122,7 @@ describe("TemplateSchedulePage", () => {
142
122
143
123
await fillAndSubmitForm ( validFormValues ) ;
144
124
await waitFor ( ( ) => expect ( API . updateTemplateMeta ) . toBeCalledTimes ( 1 ) ) ;
145
- } , 15_000 ) ;
125
+ } ) ;
146
126
147
127
test ( "default and max ttl is converted to and from hours" , async ( ) => {
148
128
await renderTemplateSchedulePage ( ) ;
0 commit comments