@@ -35,7 +35,7 @@ const defaultMemorySettings = {
35
35
currTimeUnit : 'HOURS' ,
36
36
} ;
37
37
38
- const renderConfiguration = ( overrides = { } ) => {
38
+ const renderConfiguration = ( overrides = { } ) =>
39
39
render (
40
40
< MemoryRouter >
41
41
< Configuration
@@ -48,7 +48,6 @@ const renderConfiguration = (overrides = {}) => {
48
48
/>
49
49
</ MemoryRouter >
50
50
) ;
51
- } ;
52
51
53
52
const getWindowSizeConfigurations = ( ) => screen . getAllByRole ( 'combobox' ) ;
54
53
const getTopNSizeConfiguration = ( ) => screen . getByRole ( 'spinbutton' ) ;
@@ -60,31 +59,13 @@ describe('Configuration Component', () => {
60
59
} ) ;
61
60
62
61
it ( 'renders with default settings' , ( ) => {
63
- renderConfiguration ( ) ;
64
- // main header
65
- expect (
66
- screen . getByRole ( 'heading' , { name : / T o p n q u e r i e s m o n i t o r i n g c o n f i g u r a t i o n s e t t i n g s / i } )
67
- ) . toBeInTheDocument ( ) ;
68
- // section headers
69
- expect ( screen . getByRole ( 'heading' , { name : / M e t r i c T y p e / i } ) ) . toBeInTheDocument ( ) ;
70
- expect ( screen . getByRole ( 'heading' , { name : / E n a b l e d / i } ) ) . toBeInTheDocument ( ) ;
71
- expect ( screen . getByRole ( 'heading' , { name : / V a l u e o f N / i } ) ) . toBeInTheDocument ( ) ;
72
- expect ( screen . getByRole ( 'heading' , { name : / W i n d o w s i z e / i } ) ) . toBeInTheDocument ( ) ;
73
- // Check values for window size configurations
74
- const selectBoxes = getWindowSizeConfigurations ( ) ;
75
- expect ( selectBoxes [ 0 ] ) . toHaveValue ( 'latency' ) ;
76
- expect ( selectBoxes [ 1 ] ) . toHaveValue ( '10' ) ;
77
- expect ( selectBoxes [ 2 ] ) . toHaveValue ( 'MINUTES' ) ;
78
- // Check the value for top n size configurations
79
- expect ( getTopNSizeConfiguration ( ) ) . toHaveValue ( 5 ) ;
80
- // Check the value for enabled switch
81
- const enableBox = getEnableToggle ( ) ;
82
- expect ( enableBox ) . toBeInTheDocument ( ) ;
83
- expect ( enableBox ) . toBeChecked ( ) ;
62
+ const { container } = renderConfiguration ( ) ;
63
+ expect ( container ) . toMatchSnapshot ( 'should match default settings snapshot' ) ;
84
64
} ) ;
85
65
66
+ // The following tests test the interactions on the frontend with Mocks.
86
67
it ( 'updates state when toggling metrics and enables Save button when changes are made' , ( ) => {
87
- renderConfiguration ( ) ;
68
+ const { container } = renderConfiguration ( ) ;
88
69
// before toggling the metric
89
70
expect ( getWindowSizeConfigurations ( ) [ 0 ] ) . toHaveValue ( 'latency' ) ;
90
71
expect ( getEnableToggle ( ) ) . toBeChecked ( ) ;
@@ -100,6 +81,7 @@ describe('Configuration Component', () => {
100
81
fireEvent . click ( getEnableToggle ( ) ) ;
101
82
expect ( getEnableToggle ( ) ) . toBeChecked ( ) ;
102
83
expect ( screen . getByText ( 'Save' ) ) . toBeEnabled ( ) ;
84
+ expect ( container ) . toMatchSnapshot ( 'should match settings snapshot after toggling' ) ;
103
85
} ) ;
104
86
105
87
it ( 'validates topNSize and windowSize inputs and disables Save button for invalid input' , ( ) => {
0 commit comments