1
1
describe ( 'Flow-Playground frontend tests' , ( ) => {
2
2
3
- let DEPLOY_BUTTON = '[data-test="deploy-button"]' ;
4
- let EXECUTE = '[data-test="execute-button"]' ;
5
- let SEND_BUTTON = '[data-test="send-button"]' ;
6
- let ACCOUNTS_LIST = '[data-test="account-list"]' ;
7
- let MONACO_EDITOR = '.monaco-editor textarea:first' ;
8
- let STATUS_MESSAGE = '[data-test="control-panel-status-message"]' ;
3
+ const DEPLOY_BUTTON = '[data-test="deploy-button"]' ;
4
+ const EXECUTE = '[data-test="execute-button"]' ;
5
+ const SEND_BUTTON = '[data-test="send-button"]' ;
6
+ const ACCOUNTS_LIST = '[data-test="account-list"]' ;
7
+ const MONACO_EDITOR = '.monaco-editor textarea:first' ;
8
+ const STATUS_MESSAGE = '[data-test="control-panel-status-message"]' ;
9
+ const selectAllKeys = Cypress . platform == 'darwin' ? '{cmd}a' : '{ctrl}a' ;
9
10
10
11
beforeEach ( ( ) => {
11
12
cy . visit ( '/' )
12
13
} )
13
14
15
+ it ( 'deploys a contract' , ( ) => {
16
+ cy . get ( ACCOUNTS_LIST ) . children ( ) . should ( 'have.length' , 5 ) . first ( ) . click ( ) ;
17
+ cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Deploy' ) . click ( ) ;
18
+ cy . get ( STATUS_MESSAGE ) . should ( 'have.text' , 'Please wait...' ) ;
19
+ cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Redeploy' ) ;
20
+ cy . get ( '[data-test="CONTRACT-response"]' ) . should ( 'include.text' , 'Deployed Contract To: 0x01' ) ;
21
+ } )
22
+
23
+ it ( 'sends a transaction' , ( ) => {
24
+ cy . get ( '[data-test="sidebar-Transaction"]' ) . click ( ) ;
25
+ cy . get ( '[data-test="editor-heading"]' ) . should ( 'include.text' , 'Transaction Template' ) ;
26
+ // Ensure action button is disabled when contract not deployed yet
27
+ cy . get ( SEND_BUTTON ) . should ( 'be.disabled' ) ;
28
+
29
+ // deploy contract
30
+ cy . get ( ACCOUNTS_LIST ) . children ( ) . first ( ) . click ( ) ;
31
+ cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Deploy' ) . click ( ) ;
32
+ cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Redeploy' ) ;
33
+
34
+ // open transaction template and successfully send transaction
35
+ cy . get ( '[data-test="sidebar-Transaction"]' ) . click ( ) ;
36
+ cy . get ( SEND_BUTTON ) . should ( 'have.text' , 'Send' ) . should ( 'be.enabled' ) . click ( ) ;
37
+ cy . get ( '[data-test="TRANSACTION-response"]' ) . should ( 'include.text' , 'Hello, World!' ) ;
38
+ } )
39
+
40
+ it ( 'executes a script' , ( ) => {
41
+ cy . get ( '[data-test="sidebar-Script"]' ) . click ( ) ;
42
+ cy . get ( '[data-test="editor-heading"]' ) . should ( 'include.text' , 'Script Template' ) ;
43
+ cy . get ( EXECUTE ) . should ( 'have.text' , 'Execute' ) . click ( ) ;
44
+ cy . get ( '[data-test="SCRIPT-response"]' ) . should ( 'include.text' , '{"type":"Int","value":"1"}' ) ;
45
+ } )
46
+
14
47
it ( 'reflects changes to imported contract after contract has been redeployed' , ( ) => {
15
48
16
49
// deploy contract
@@ -27,7 +60,10 @@ describe('Flow-Playground frontend tests', () => {
27
60
28
61
// edit contract
29
62
cy . get ( ACCOUNTS_LIST ) . children ( ) . first ( ) . click ( ) ;
30
- cy . get ( MONACO_EDITOR ) . click ( ) . focused ( ) . type ( '{cmd}a' ) . clear ( ) . type ( 'access(all) contract HelloWorld { access(all) let greeting: String init() { self.greeting = "Hello, Other World!" } access(all) fun other_hello(): String {return self.greeting}}' , { parseSpecialCharSequences : false } ) ;
63
+ cy . get ( MONACO_EDITOR ) . click ( ) . focused ( ) . type ( selectAllKeys ) . clear ( ) ;
64
+ cy . get ( MONACO_EDITOR ) . should ( 'be.empty' ) ;
65
+ cy . get ( DEPLOY_BUTTON ) . should ( 'be.disabled' ) ;
66
+ cy . get ( MONACO_EDITOR ) . click ( ) . focused ( ) . type ( 'access(all) contract HelloWorld { access(all) let greeting: String init() { self.greeting = "Hello, Other World!" } access(all) fun other_hello(): String {return self.greeting}}' , { parseSpecialCharSequences : false } ) ;
31
67
cy . get ( DEPLOY_BUTTON ) . should ( 'be.enabled' ) ;
32
68
cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Redeploy' ) . click ( ) ;
33
69
cy . get ( '[data-test="redeploy-confirm-button"]' ) . should ( 'exist' ) . click ( ) ;
@@ -38,7 +74,7 @@ describe('Flow-Playground frontend tests', () => {
38
74
// select and edit transaction
39
75
cy . get ( '[data-test="sidebar-Transaction"]' ) . click ( ) ;
40
76
cy . get ( SEND_BUTTON ) . should ( 'have.text' , 'Send' ) . should ( 'be.disabled' ) ;
41
- cy . get ( MONACO_EDITOR ) . click ( ) . focused ( ) . type ( '{cmd}a' ) . type ( 'import HelloWorld from 0x01 transaction { prepare(acct: AuthAccount) {} execute { log(HelloWorld.other_hello())}}' , { parseSpecialCharSequences : false } ) ;
77
+ cy . get ( MONACO_EDITOR ) . click ( ) . focused ( ) . type ( selectAllKeys ) . type ( 'import HelloWorld from 0x01 transaction { prepare(acct: AuthAccount) {} execute { log(HelloWorld.other_hello())}}' , { parseSpecialCharSequences : false } ) ;
42
78
43
79
44
80
// successfully send transaction
@@ -47,36 +83,4 @@ describe('Flow-Playground frontend tests', () => {
47
83
48
84
} )
49
85
50
- it ( 'deploys a contract' , ( ) => {
51
- cy . get ( ACCOUNTS_LIST ) . children ( ) . should ( 'have.length' , 5 ) . first ( ) . click ( ) ;
52
- cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Deploy' ) . click ( ) ;
53
- cy . get ( STATUS_MESSAGE ) . should ( 'have.text' , 'Please wait...' ) ;
54
- cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Redeploy' ) ;
55
- cy . get ( '[data-test="CONTRACT-response"]' ) . should ( 'include.text' , 'Deployed Contract To: 0x01' ) ;
56
- } )
57
-
58
- it ( 'executes a script' , ( ) => {
59
- cy . get ( '[data-test="sidebar-Script"]' ) . click ( ) ;
60
- cy . get ( '[data-test="editor-heading"]' ) . should ( 'include.text' , 'Script Template' ) ;
61
- cy . get ( EXECUTE ) . should ( 'have.text' , 'Execute' ) . click ( ) ;
62
- cy . get ( '[data-test="SCRIPT-response"]' ) . should ( 'include.text' , '{"type":"Int","value":"1"}' ) ;
63
- } )
64
-
65
- it ( 'sends a transaction' , ( ) => {
66
- cy . get ( '[data-test="sidebar-Transaction"]' ) . click ( ) ;
67
- cy . get ( '[data-test="editor-heading"]' ) . should ( 'include.text' , 'Transaction Template' ) ;
68
- // Ensure action button is disabled when contract not deployed yet
69
- cy . get ( SEND_BUTTON ) . should ( 'be.disabled' ) ;
70
-
71
- // deploy contract
72
- cy . get ( ACCOUNTS_LIST ) . children ( ) . first ( ) . click ( ) ;
73
- cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Deploy' ) . click ( ) ;
74
- cy . get ( DEPLOY_BUTTON ) . should ( 'have.text' , 'Redeploy' ) ;
75
-
76
- // open transaction template and successfully send transaction
77
- cy . get ( '[data-test="sidebar-Transaction"]' ) . click ( ) ;
78
- cy . get ( SEND_BUTTON ) . should ( 'have.text' , 'Send' ) . should ( 'be.enabled' ) . click ( ) ;
79
- cy . get ( '[data-test="TRANSACTION-response"]' ) . should ( 'include.text' , 'Hello, World!' ) ;
80
- } )
81
-
82
86
} )
0 commit comments