Skip to content

Commit

Permalink
chore: change cypress to use production build
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsos committed Dec 15, 2023
1 parent 27cd666 commit 1337f45
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 81 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/account/signup/SignupAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const { t } = useI18n();
/>
<RuiTextField
id="postal"
data-cy="postal"
:model-value="modelValue.postcode"
variant="outlined"
color="primary"
Expand Down
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default defineNuxtConfig({
},

devtools: {
enabled: true,
enabled: !process.env.CI || process.env.TEST,
},

runtimeConfig: {
Expand Down
94 changes: 44 additions & 50 deletions tests/e2e/specs/pages/index.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,108 +4,102 @@ describe('Homepage test', () => {
});

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')
Expand Down
69 changes: 40 additions & 29 deletions tests/e2e/specs/pages/signup.spec.cy.ts
Original file line number Diff line number Diff line change
@@ -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();
});

Expand All @@ -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 protected]');
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();
});

Expand All @@ -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');
Expand All @@ -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')
Expand All @@ -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');
Expand All @@ -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');
});
Expand Down

0 comments on commit 1337f45

Please sign in to comment.