1
1
import page from './page-model' ;
2
- import { SERVER_NAME } from './helpers' ;
2
+ import { ReactSelector } from 'testcafe-react-selectors' ;
3
+ import { SERVER_NAME } from './helpers' ;
3
4
4
5
fixture ( 'Tags' ) . page ( SERVER_NAME ) ;
5
6
7
+ const subSection = ( name ) => console . log ( '\x1b[33m%s\x1b[0m' , ' - ' + name ) ;
8
+
6
9
test ( 'Clicking first tag updates list and only assets should be shown that are assigned to it' , async ( t ) => {
7
10
await t
8
11
// Uncollapse the tag list
@@ -19,3 +22,34 @@ test('Clicking first tag updates list and only assets should be shown that are a
19
22
. expect ( page . assetCount . innerText )
20
23
. eql ( '12 assets' ) ;
21
24
} ) ;
25
+
26
+ test ( 'Create a new tag and test validation' , async ( t ) => {
27
+ subSection ( 'Check existing tag label validation' ) ;
28
+ await t
29
+ . click ( page . assetCollections . withText ( 'All' ) )
30
+ . click ( page . collectionTree . findReact ( 'AddTagButton' ) )
31
+ . typeText ( ReactSelector ( 'CreateTagDialog' ) . findReact ( 'TextInput' ) , 'Example tag 1' )
32
+ . expect (
33
+ ReactSelector ( 'CreateTagDialog' )
34
+ . findReact ( 'TextInput' )
35
+ . withProps ( { validationerrors : [ 'This input is invalid' ] } ) . exists
36
+ )
37
+ . ok ( 'Text input should have validation errors' )
38
+ . expect ( ReactSelector ( 'CreateTagDialog' ) . findReact ( 'Button' ) . withProps ( { disabled : true } ) . exists )
39
+ . ok ( 'Create button should be disabled' )
40
+ . expect ( ReactSelector ( 'CreateTagDialog' ) . find ( 'ul li' ) . textContent )
41
+ . eql ( 'A tag with this label already exists' )
42
+ . typeText ( ReactSelector ( 'CreateTagDialog' ) . findReact ( 'TextInput' ) , '00' )
43
+ . expect ( ReactSelector ( 'CreateTagDialog' ) . find ( 'ul li' ) . exists )
44
+ . notOk ( 'The tooltip should not be visible anymore' )
45
+ . expect ( ReactSelector ( 'CreateTagDialog' ) . findReact ( 'Button' ) . withProps ( { disabled : false } ) . exists )
46
+ . ok ( 'Create button should be enabled' ) ;
47
+
48
+ subSection ( 'Check emtpy tag label validation' ) ;
49
+ await t
50
+ . typeText ( ReactSelector ( 'CreateTagDialog' ) . findReact ( 'TextInput' ) , ' ' , { replace : true } )
51
+ . expect ( ReactSelector ( 'CreateTagDialog' ) . findReact ( 'Button' ) . withProps ( { disabled : true } ) . exists )
52
+ . ok ( 'Create button should be disabled' )
53
+ . expect ( ReactSelector ( 'CreateTagDialog' ) . find ( 'ul li' ) . textContent )
54
+ . eql ( 'Please provide a tag label' ) ;
55
+ } ) ;
0 commit comments