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