@@ -5,6 +5,7 @@ const testRoute = '/inputs';
5
5
test ( 'inputs can be interacted with' , async ( { page } ) => {
6
6
await page . goto ( testRoute ) ;
7
7
8
+ // Grab the input elements for testing
8
9
const textField = page . locator ( '#text-test' ) ;
9
10
const checkBox = page . locator ( '#checkbox-test' ) ;
10
11
@@ -20,8 +21,10 @@ test('inputs can be interacted with', async ({ page }) => {
20
21
await textField . press ( 'B' ) ;
21
22
await textField . press ( 'C' ) ;
22
23
24
+ // Chcek that the value has changed
23
25
await expect ( textField ) . toHaveValue ( 'TestABC' ) ;
24
26
27
+ // Clear the input
25
28
await textField . press ( 'Backspace' ) ;
26
29
await textField . press ( 'Backspace' ) ;
27
30
await textField . press ( 'Backspace' ) ;
@@ -31,22 +34,47 @@ test('inputs can be interacted with', async ({ page }) => {
31
34
await textField . press ( 'Backspace' ) ;
32
35
await textField . press ( 'Backspace' ) ;
33
36
37
+ // Check that it was cleared
38
+ await expect ( textField ) . toHaveValue ( '' ) ;
39
+
34
40
await textField . press ( '1' ) ;
35
41
await textField . press ( 'Space' ) ;
36
42
await textField . press ( '2' ) ;
37
43
38
44
await expect ( textField ) . toHaveValue ( '1 2' ) ;
39
45
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' ) ;
43
47
// Check if the checkbox is checked
44
- const isChecked = await checkbox . isChecked ( ) ;
48
+ const isChecked = await checkBox . isChecked ( ) ;
45
49
await expect ( isChecked ) . toBe ( true ) ;
46
50
// Click the checkbox
47
51
await checkBox . click ( ) ;
48
52
49
- const isNowChecked = await checkbox . isChecked ( ) ;
53
+ const isNowChecked = await checkBox . isChecked ( ) ;
54
+
50
55
// Check the current value of the chebox
51
56
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);' ) ;
52
80
} ) ;
0 commit comments