-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: adding e2e tests for the dapp #73
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,5 +47,13 @@ | |
"test": "yarn workspaces run test", | ||
"test:e2e": "yarn workspace offer-up-ui test:e2e", | ||
"build": "yarn workspaces run build" | ||
}, | ||
"devDependencies": { | ||
"@agoric/synpress": "^3.8.1-beta.1", | ||
"eslint-config-turbo": "^1.13.0", | ||
"eslint-plugin-chai-friendly": "^0.7.4", | ||
"eslint-plugin-cypress": "^2.15.1", | ||
"eslint-plugin-testing-library": "^6.2.0", | ||
"eslint-plugin-ui-testing": "^2.0.1" | ||
Comment on lines
+53
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are all needed by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they're required by And I was thinking the same about adding them as |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"test": "vitest spec", | ||
"test:e2e": "vitest e2e", | ||
"test:e2e": "EXTENSION=keplr synpress run --configFile=test/e2e/synpress.config.cjs", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if I missed some docs somewhere. I get an error about SECRET_WORDS ...
|
||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", | ||
"lint:fix": "yarn lint --fix", | ||
"preview": "vite preview" | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const path = require('path'); | ||
const cwd = process.cwd(); | ||
const directories = cwd.split(path.sep); | ||
directories.pop(); | ||
const updatedPath = directories.join(path.sep); | ||
const synpressPath = path.join(updatedPath, '/node_modules/@agoric/synpress'); | ||
|
||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why use .cjs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because in On line 24: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes me curious why synpress uses commonJS. But I guess it's not critical. |
||
extends: `${synpressPath}/.eslintrc.js`, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-disable ui-testing/no-disabled-tests */ | ||
|
||
describe('DAPP Offer Up E2E Test Cases', () => { | ||
context('Test commands', () => { | ||
it(`should complete Keplr setup by importing an existing wallet using 24 word phrase`, () => { | ||
cy.setupWallet().then((setupFinished) => { | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the import-24-words stuff is happening twice when I run the test. Is that by design? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dckc Yes it is by design. But it's something we are planning to remove in the next release of |
||
expect(setupFinished).to.be.true; | ||
}); | ||
cy.visit('/'); | ||
}); | ||
it(`should reject connection with wallet`, () => { | ||
const alertShown = cy.stub().as('alertShown'); | ||
cy.on('window:alert', alertShown); | ||
|
||
cy.contains('Connect Wallet').click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm struggling to get it to work. yarn test:e2e results
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried again with the right mnemonic:
but the address shown in the test is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dckc This is actually a bug in At the moment, we hardcode the mnemonic:
Adding an issue for it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added it as an over here. |
||
cy.rejectAccess().then((rejected) => { | ||
expect(rejected).to.be.true; | ||
}); | ||
cy.get('@alertShown').should( | ||
'have.been.calledOnceWith', | ||
'Request rejected' | ||
); | ||
}); | ||
it(`should accept connection with wallet`, () => { | ||
cy.contains('Connect Wallet').click(); | ||
cy.acceptAccess().then((taskCompleted) => { | ||
expect(taskCompleted).to.be.true; | ||
}); | ||
}); | ||
it(`should reject make an offer transaction`, () => { | ||
const alertShown = cy.stub().as('alertShown'); | ||
cy.on('window:alert', alertShown); | ||
|
||
cy.contains('Make an Offer').click(); | ||
cy.rejectTransaction().then((taskCompleted) => { | ||
expect(taskCompleted).to.be.true; | ||
}); | ||
|
||
cy.get('@alertShown').should( | ||
'have.been.calledOnceWith', | ||
'Offer error: Error: Request rejected' | ||
); | ||
}); | ||
it(`should confirm make an offer transaction`, () => { | ||
const alertShown = cy.stub().as('alertShown'); | ||
cy.on('window:alert', alertShown); | ||
|
||
cy.contains('Make an Offer').click(); | ||
cy.confirmTransaction().then((taskCompleted) => { | ||
expect(taskCompleted).to.be.true; | ||
}); | ||
|
||
cy.get('@alertShown').should( | ||
'have.been.calledOnceWith', | ||
'Offer accepted' | ||
); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const config = require('@agoric/synpress/synpress.config'); | ||
const { defineConfig } = require('cypress'); | ||
|
||
module.exports = defineConfig({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why .cjs? |
||
...config, | ||
e2e: { | ||
...config.e2e, | ||
baseUrl: 'http://localhost:5173', | ||
specPattern: 'test/e2e/specs/**/*spec.{js,jsx,ts,tsx}', | ||
supportFile: 'test/support.js', | ||
screenshotsFolder: 'test/e2e/screenshots', | ||
videosFolder: 'test/e2e/videos' | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@agoric/synpress/support/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These steps were removed for two reasons:
The test in the file
ui/test/App.e2e.ts
were eliminated. The test was basic and focused on checking if the UI was functional, a task already covered by the e2e tests implicitly.Including these steps was causing a failure in our CI process. This failure was due to the involvement of tests in this PR defined in the e2e folder. Currently, I am in the process of setting up proper CI for our e2e tests, as detailed in this pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized... we took out
yarn test
?!