@@ -5,6 +5,7 @@ const testRoute = '/inputs';
55test ( 'inputs can be interacted with' , async ( { page } ) => {
66 await page . goto ( testRoute ) ;
77
8+ // Grab the input elements for testing
89 const textField = page . locator ( '#text-test' ) ;
910 const checkBox = page . locator ( '#checkbox-test' ) ;
1011
@@ -20,8 +21,10 @@ test('inputs can be interacted with', async ({ page }) => {
2021 await textField . press ( 'B' ) ;
2122 await textField . press ( 'C' ) ;
2223
24+ // Chcek that the value has changed
2325 await expect ( textField ) . toHaveValue ( 'TestABC' ) ;
2426
27+ // Clear the input
2528 await textField . press ( 'Backspace' ) ;
2629 await textField . press ( 'Backspace' ) ;
2730 await textField . press ( 'Backspace' ) ;
@@ -31,22 +34,47 @@ test('inputs can be interacted with', async ({ page }) => {
3134 await textField . press ( 'Backspace' ) ;
3235 await textField . press ( 'Backspace' ) ;
3336
37+ // Check that it was cleared
38+ await expect ( textField ) . toHaveValue ( '' ) ;
39+
3440 await textField . press ( '1' ) ;
3541 await textField . press ( 'Space' ) ;
3642 await textField . press ( '2' ) ;
3743
3844 await expect ( textField ) . toHaveValue ( '1 2' ) ;
3945
40- // Select the checkbox element
41- const checkbox = await page . $ ( '#checkbox-test' ) ;
42- if ( ! checkbox ) throw new Error ( 'Checkbox not found' ) ;
46+ if ( ! checkBox ) throw new Error ( 'Checkbox not found' ) ;
4347 // Check if the checkbox is checked
44- const isChecked = await checkbox . isChecked ( ) ;
48+ const isChecked = await checkBox . isChecked ( ) ;
4549 await expect ( isChecked ) . toBe ( true ) ;
4650 // Click the checkbox
4751 await checkBox . click ( ) ;
4852
49- const isNowChecked = await checkbox . isChecked ( ) ;
53+ const isNowChecked = await checkBox . isChecked ( ) ;
54+
5055 // Check the current value of the chebox
5156 await expect ( isNowChecked ) . toBe ( false ) ;
57+
58+ // Grab the graph element
59+ const graphWrapper = page . locator ( '.svelvet-graph-wrapper' ) ;
60+
61+ // Check the transforms
62+ await expect ( graphWrapper ) . toHaveAttribute ( 'style' , 'transform: translate(0px, 0px) scale(1);' ) ;
63+
64+ // These commands should not affect the graph
65+ await textField . press ( '=' ) ;
66+ await textField . press ( '=' ) ;
67+ await textField . press ( '=' ) ;
68+
69+ await expect ( graphWrapper ) . toHaveAttribute ( 'style' , 'transform: translate(0px, 0px) scale(1);' ) ;
70+
71+ await textField . press ( '-' ) ;
72+ await textField . press ( '-' ) ;
73+
74+ await expect ( graphWrapper ) . toHaveAttribute ( 'style' , 'transform: translate(0px, 0px) scale(1);' ) ;
75+
76+ await textField . press ( '0' ) ;
77+ await textField . press ( '0' ) ;
78+
79+ await expect ( graphWrapper ) . toHaveAttribute ( 'style' , 'transform: translate(0px, 0px) scale(1);' ) ;
5280} ) ;
0 commit comments