1
+ describe ( 'Test Code Snippet Extension on load' , ( ) => {
2
+ beforeEach ( ( ) => {
3
+ cy . visit ( 'http://localhost:8888/lab' )
4
+ } )
5
+
6
+ // it('Create code snippet settings on load', () => {
7
+ // cy.get('.jp-PluginList > ul > li').eq(1).should('have.attr', 'data-id', 'jupyterlab-code-snippets:snippets')
8
+ // })
9
+
10
+ it ( 'Create default snippets in the beginning' , ( ) => {
11
+ cy . get ( '.jp-codeSnippetsContainer' ) . find ( '.jp-codeSnippet-item' ) . should ( 'have.length' , 3 )
12
+ } )
13
+ } )
14
+
15
+ describe ( 'Test Code Snippet Manipulation' , ( ) => {
16
+ beforeEach ( ( ) => {
17
+ cy . visit ( 'http://localhost:8888/lab' )
18
+ } )
19
+
20
+ it ( 'Create a new code snippet' , ( ) => {
21
+ // adding a snippet
22
+ cy . get ( '.jp-Notebook' ) . rightclick ( )
23
+ . get ( '.lm-Menu-itemLabel' ) . eq ( 13 ) . click ( )
24
+ . wait ( 500 )
25
+ . get ( '.jp-codeSnippet-dialog-input' ) . eq ( 0 ) . click ( ) . type ( "test" ) . should ( 'have.value' , 'test' )
26
+ . wait ( 500 )
27
+ . get ( '.jp-codeSnippet-dialog-input' ) . eq ( 1 ) . click ( ) . type ( "testing with cypress" ) . should ( 'have.value' , 'testing with cypress' )
28
+ . wait ( 500 )
29
+ . get ( '.jp-codeSnippet-dialog-input' ) . eq ( 2 ) . click ( ) . type ( "Python" ) . should ( 'have.value' , 'Python' )
30
+ . get ( '.jp-mod-accept' ) . click ( ) ;
31
+
32
+ cy . get ( '.lm-Widget' ) . eq ( 0 ) . click ( { force : true } ) ;
33
+
34
+ // checking the snippet
35
+ cy . get ( '.jp-codeSnippetsContainer' ) . find ( '.jp-codeSnippet-item' ) . should ( 'have.length' , 4 ) ;
36
+ } )
37
+
38
+ it ( 'Delete a new code snippet' , ( ) => {
39
+ // delete snippet
40
+ cy . get ( '.jp-codeSnippet-item #0 > .jp-codeSnippetsContainer-button' ) . click ( )
41
+ . get ( '.jp-codeSnippet-more-options-delete' ) . click ( )
42
+ . get ( '.jp-mod-accept' ) . click ( )
43
+
44
+ // checking the snippet
45
+ cy . get ( '.jp-codeSnippetsContainer' ) . find ( '.jp-codeSnippet-item' ) . should ( 'have.length' , 3 ) ;
46
+ } )
47
+
48
+ it ( 'Renaming a snippet' , ( ) => {
49
+ cy . wait ( 500 )
50
+ // rename snippet
51
+ cy . get ( '.jp-codeSnippet-item #0 > .jp-codeSnippetsContainer-name > span' ) . eq ( 1 ) . dblclick ( )
52
+ . get ( '#jp-codeSnippet-rename' ) . type ( 'new_test' )
53
+
54
+ cy . wait ( 500 )
55
+ // rename with duplicate name
56
+ cy . get ( '.jp-codeSnippet-item #1 > .jp-codeSnippetsContainer-name > span' ) . eq ( 1 ) . dblclick ( )
57
+ . get ( '#jp-codeSnippet-rename' ) . type ( 'new_test' )
58
+ . get ( '.lm-StackedPanel' ) . eq ( 0 ) . click ( { force :true } )
59
+ . get ( '.jp-mod-accept' ) . click ( )
60
+
61
+ } )
62
+
63
+ it ( 'Create a new code snippet from scratch' , ( ) => {
64
+ cy . get ( '.jp-createSnippetBtn' ) . click ( ) . get ( '.jp-codeSnippet-editor-name' ) . type ( 'create_test' ) . should ( 'have.value' , 'create_test' )
65
+ . get ( '.jp-codeSnippet-editor-description' ) . type ( 'testing' ) . should ( 'have.value' , 'testing' )
66
+ . get ( '.saveBtn' ) . click ( )
67
+ } )
68
+
69
+ it . only ( 'Edit a snippet' , ( ) => {
70
+ cy . get ( '.jp-codeSnippet-item #0 > .jp-codeSnippetsContainer-button' ) . click ( )
71
+ . get ( '.jp-codeSnippet-more-options-edit' ) . click ( )
72
+ . wait ( 500 )
73
+ . get ( '.jp-codeSnippet-editor-name' ) . clear ( ) . type ( 'test_editing' ) . should ( 'have.value' , 'test_editing' )
74
+ . wait ( 500 )
75
+ . get ( '.jp-codeSnippet-editor-name' ) . clear ( ) . type ( 'test_editing' ) . should ( 'have.value' , 'test_editing' )
76
+ . get ( '.saveBtn' ) . click ( )
77
+
78
+ cy . get ( '.jp-codeSnippet-item #0 > .jp-codeSnippetsContainer-name > span' ) . eq ( 1 ) . contains ( 'test_editing' )
79
+ } )
80
+ // it.only('moving a snippet', () => {
81
+ // cy.visit('http://localhost:8888/lab')
82
+
83
+ // cy.wait(500)
84
+ // cy.get('.jp-codeSnippet-drag-hover').eq(0)
85
+ // .dragTo(':nth-child(3) > .jp-codeSnippet-metadata')
86
+ // .get('.jp-codeSnippet-item #1 > .jp-codeSnippetsContainer-name > span').eq(1).contains('test')
87
+ // })
88
+ } )
0 commit comments