Skip to content

Commit a428d38

Browse files
committed
added conditional for os
1 parent 09cce79 commit a428d38

File tree

1 file changed

+44
-40
lines changed

1 file changed

+44
-40
lines changed

cypress/e2e/playground.cy.ts

+44-40
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,49 @@
11
describe('Flow-Playground frontend tests', () => {
22

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';
910

1011
beforeEach(() => {
1112
cy.visit('/')
1213
})
1314

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+
1447
it('reflects changes to imported contract after contract has been redeployed', () => {
1548

1649
// deploy contract
@@ -27,7 +60,10 @@ describe('Flow-Playground frontend tests', () => {
2760

2861
// edit contract
2962
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});
3167
cy.get(DEPLOY_BUTTON).should('be.enabled');
3268
cy.get(DEPLOY_BUTTON).should('have.text', 'Redeploy').click();
3369
cy.get('[data-test="redeploy-confirm-button"]').should('exist').click();
@@ -38,7 +74,7 @@ describe('Flow-Playground frontend tests', () => {
3874
// select and edit transaction
3975
cy.get('[data-test="sidebar-Transaction"]').click();
4076
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});
4278

4379

4480
// successfully send transaction
@@ -47,36 +83,4 @@ describe('Flow-Playground frontend tests', () => {
4783

4884
})
4985

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-
8286
})

0 commit comments

Comments
 (0)