diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 460ee5db..b9afd7e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -108,10 +108,13 @@ jobs: - name: Run tests ✅ run: pnpm run test + - name: Set .env + run: cp .env.test .env + - name: Run cypress tests uses: cypress-io/github-action@v5 with: - start: pnpm run dev --dotenv .env.test --host 127.0.0.1 + start: pnpm run start browser: chrome wait-on: 'http://127.0.0.1:3000' install: false diff --git a/components/account/signup/SignupAddress.vue b/components/account/signup/SignupAddress.vue index 7455246f..32d1f99d 100644 --- a/components/account/signup/SignupAddress.vue +++ b/components/account/signup/SignupAddress.vue @@ -142,6 +142,7 @@ const { t } = useI18n(); /> { }); it('checks our dashboard hero buttons!', () => { - const freeButton = cy - .get('button') + cy.get('button') .contains('button', 'Start now for free') - .first(); + .first() + .should('be.visible'); - const premiumButton = cy - .get('button') + cy.get('button') .contains('button', 'Get Premium') - .first(); - - expect(freeButton).to.exist; - expect(premiumButton).to.exist; + .first() + .should('be.visible'); }); it('checks our dashboard app download links!', () => { - const freeButton = cy.get('button').contains('Start now for free').first(); - - freeButton.click(); + cy.get('button').contains('Start now for free').first().click(); cy.url().should('include', '/download'); - const downloadTitle = cy - .get('div') - .contains('h6', 'Download rotki') - .first(); + cy.get('div').contains('h6', 'Download rotki').first().should('be.visible'); - const downloadDesc = cy - .get('div') + cy.get('div') .contains( 'h3', 'Download now and start using across all major Operating Systems', ) - .first(); - - const linuxLink = cy.get('h6').contains('LINUX').first(); - const macSiliconLink = cy.get('h6').contains('MAC apple silicon').first(); - const macIntelLink = cy.get('h6').contains('MAC intel').first(); - const windowsLink = cy.get('h6').contains('WINDOWS').first(); - const version = cy.get('p').contains('Latest Release: v').first(); - - expect(downloadTitle).to.exist; - expect(downloadDesc).to.exist; - expect(linuxLink).to.exist; - expect(macSiliconLink).to.exist; - expect(macIntelLink).to.exist; - expect(windowsLink).to.exist; - expect(version).to.exist; - - const linuxButton = linuxLink + .first() + .should('be.visible'); + + cy.get('h6').contains('LINUX').first().as('linuxLink'); + cy.get('h6').contains('MAC apple silicon').first().as('appleSiliconLink'); + cy.get('h6').contains('MAC intel').first().as('appleIntelLink'); + cy.get('h6').contains('WINDOWS').first().as('windowsLink'); + + cy.get('@linuxLink').should('exist'); + cy.get('@appleSiliconLink').should('exist'); + cy.get('@appleIntelLink').should('exist'); + cy.get('@windowsLink').should('exist'); + cy.get('p').contains('Latest Release: v').first().should('exist'); + + cy.get('@linuxLink') .parent() .parent() .find('div button') .contains('Download') - .parent('button'); + .parent('button') + .as('linuxButton'); + + cy.get('@linuxButton').should('exist'); - expect(linuxButton).to.exist; - linuxButton + cy.get('@linuxButton') .should('be.enabled') .parent('a') .should('have.attr', 'href') .and('include', 'rotki-linux') .and('include', '.AppImage'); - const macSiliconButton = macSiliconLink + cy.get('@appleSiliconLink') .parent() .parent() .find('div button') .contains('Download') - .parent('button'); + .parent('button') + .as('appleSiliconButton'); - expect(macSiliconButton).to.exist; - macSiliconButton + cy.get('@appleSiliconButton').should('exist'); + cy.get('@appleSiliconButton') .should('be.enabled') .parent('a') .should('have.attr', 'href') .and('include', 'rotki-darwin_arm') .and('include', '.dmg'); - const macIntelButton = macIntelLink + cy.get('@appleIntelLink') .parent() .parent() .find('div button') .contains('Download') - .parent('button'); + .parent('button') + .as('appleIntelButton'); - expect(macIntelButton).to.exist; - macIntelButton + cy.get('@appleIntelButton'); + cy.get('@appleIntelButton') .should('be.enabled') .parent('a') .should('have.attr', 'href') .and('include', 'rotki-darwin_x') .and('include', '.dmg'); - const windowsButton = windowsLink + cy.get('@windowsLink') .parent() .parent() .find('div button') .contains('Download') - .parent('button'); + .parent('button') + .as('windowsButton'); - expect(windowsButton).to.exist; - windowsButton + cy.get('@windowsButton').should('exist'); + cy.get('@windowsButton') .should('be.enabled') .parent('a') .should('have.attr', 'href') diff --git a/tests/e2e/specs/pages/signup.spec.cy.ts b/tests/e2e/specs/pages/signup.spec.cy.ts index 9cee2830..64eb3116 100644 --- a/tests/e2e/specs/pages/signup.spec.cy.ts +++ b/tests/e2e/specs/pages/signup.spec.cy.ts @@ -1,10 +1,20 @@ describe('Signup test', () => { - it('successfully loads', () => { + before(() => { cy.visit('/signup').wait(3000); }); + beforeEach(() => { + cy.intercept('/webapi/countries', { + body: { + result: [{ name: 'Country', code: 'CT' }], + }, + }); + }); + it('show introduction page', () => { - cy.contains('Important Note'); + cy.contains('Important Note').should('be.visible'); + cy.get('[data-cy=next-button]').should('be.visible'); + cy.get('[data-cy=next-button]').should('be.enabled'); cy.get('[data-cy=next-button]').click(); }); @@ -15,17 +25,17 @@ describe('Signup test', () => { cy.get('input#password-confirmation').first().as('confirmPasswordInput'); cy.get('button[data-cy=next-button]').first().as('nextButton'); - expect(cy.get('@usernameInput')).to.exist; - expect(cy.get('@emailInput')).to.exist; - expect(cy.get('@passwordInput')).to.exist; - expect(cy.get('@confirmPasswordInput')).to.exist; - expect(cy.get('@nextButton').should('be.disabled')); + cy.get('@usernameInput').should('exist'); + cy.get('@emailInput').should('exist'); + cy.get('@passwordInput').should('exist'); + cy.get('@confirmPasswordInput').should('exist'); + cy.get('@nextButton').should('be.disabled'); cy.get('@usernameInput').type('username'); cy.get('@emailInput').type('email@gmail.com'); cy.get('@passwordInput').type('p455w0rD'); cy.get('@confirmPasswordInput').type('p455w0rD'); - expect(cy.get('@nextButton').should('be.enabled')); + cy.get('@nextButton').should('be.enabled'); cy.get('@nextButton').click(); }); @@ -36,11 +46,11 @@ describe('Signup test', () => { cy.get('input#vat-id').first().as('vatIdInput'); cy.get('button[data-cy=next-button]').first().as('nextButton'); - expect(cy.get('@firstNameInput')).to.exist; - expect(cy.get('@lastNameInput')).to.exist; - expect(cy.get('@companyNameInput')).to.exist; - expect(cy.get('@vatIdInput')).to.exist; - expect(cy.get('@nextButton').should('be.disabled')); + cy.get('@firstNameInput').should('exist'); + cy.get('@lastNameInput').should('exist'); + cy.get('@companyNameInput').should('exist'); + cy.get('@vatIdInput').should('exist'); + cy.get('@nextButton').should('be.disabled'); cy.get('@firstNameInput').type('First'); cy.get('@lastNameInput').type('Last'); @@ -52,7 +62,7 @@ describe('Signup test', () => { cy.get('input#address-2').first().as('address2Input'); cy.get('input#city').first().as('cityInput'); cy.get('input#postal').first().as('postalInput'); - cy.get('#country input').first().as('countryInput'); + cy.get('input#country').first().as('countryInput'); cy.get('div#signup-captcha').first().as('captcha'); cy.get('input#tos').first().as('tosInput'); cy.get('button') @@ -61,14 +71,14 @@ describe('Signup test', () => { .as('submitButton'); cy.get('button[data-cy=submit-button]').first().as('submitButton'); - expect(cy.get('@address1Input')).to.exist; - expect(cy.get('@address2Input')).to.exist; - expect(cy.get('@cityInput')).to.exist; - expect(cy.get('@postalInput')).to.exist; - expect(cy.get('@countryInput')).to.exist; - expect(cy.get('@captcha')).to.exist; - expect(cy.get('@tosInput')).to.exist; - expect(cy.get('@submitButton').should('be.disabled')); + cy.get('@address1Input').should('exist'); + cy.get('@address2Input').should('exist'); + cy.get('@cityInput').should('exist'); + cy.get('@postalInput').should('exist'); + cy.get('@countryInput').should('exist'); + cy.get('@captcha').should('exist'); + cy.get('@tosInput').should('exist'); + cy.get('@submitButton').should('be.disabled'); cy.get('@address1Input').type('Address first line'); cy.get('@address2Input').type('Address second line'); @@ -80,18 +90,19 @@ describe('Signup test', () => { it('checks signup postal input field for valid inputs!', () => { cy.get('input#postal').first().as('postalInput'); cy.get('@postalInput').type('12345'); - cy.get('#postal .details .text-rui-error').should('not.exist'); + cy.get('[data-cy=postal] .details .text-rui-error').should('not.exist'); cy.get('@postalInput').clear().type('ABC-40'); - cy.get('#postal .details .text-rui-error').should('not.exist'); + cy.get('[data-cy=postal] .details .text-rui-error').should('not.exist'); cy.get('@postalInput').clear().type('ABC-40 224'); - cy.get('#postal .details .text-rui-error').should('not.exist'); + cy.get('[data-cy=postal] .details .text-rui-error').should('not.exist'); cy.get('@postalInput').clear().type('12@345'); - cy.get('#postal .details .text-rui-error').first().as('postalError'); - expect(cy.get('@postalError')).to.exist; + cy.get('[data-cy=postal] .details .text-rui-error') + .first() + .as('postalError'); cy.get('@postalInput').clear().type('12#345'); - expect(cy.get('@postalError')).to.exist; + cy.get('@postalError').should('exist'); cy.get('@postalInput').clear().type('.'); - expect(cy.get('@postalError')).to.exist; + cy.get('@postalError').should('exist'); cy.get('@postalInput').clear().type('105102'); cy.get('#postal .details .text-rui-error').should('not.exist'); });