-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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(Example): add cypress tests #1565
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a6a5065
test(Example): add cypress for e2e tests
timdeschryver 39ec9ed
build: add the example cypress tests to the CI pipeline
timdeschryver 42b42fe
build: add bazelignore
timdeschryver 1de99b5
build: tell Bazel not to try to build rxjs under cypress node_modules
brandonroberts 2d7e8b5
build: pin listr packages to RxJS 6.x compatible version
brandonroberts b3ac354
Revert "build: tell Bazel not to try to build rxjs under cypress node…
brandonroberts 332d098
type: spaces instead of tabs
timdeschryver f668487
build: preprocess cypress files
timdeschryver 0c2957e
style: group example scripts
timdeschryver 83c5784
example: remove example-app-e2e tests
timdeschryver 163dc75
build: move e2e tests to its own build step
timdeschryver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const express = require('express'); | ||
const path = require('path'); | ||
|
||
const CONTEXT = `/${process.env.CONTEXT || 'platform/example-app'}`; | ||
const PORT = process.env.PORT || 4000; | ||
const DIST = path.join(__dirname, '../projects/example-app/dist'); | ||
|
||
const app = express(); | ||
|
||
app.use(CONTEXT, express.static(DIST)); | ||
app.use('/', express.static(DIST)); | ||
app.listen(PORT, () => | ||
console.log(`App running on http://localhost:${PORT}${CONTEXT}`) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"baseUrl": "http://localhost:4200", | ||
"fixturesFolder": "fixtures", | ||
"integrationFolder": "integration", | ||
"pluginsFile": "plugins/index.js", | ||
"supportFile": "support/index.js", | ||
"screenshotsFolder": "screenshots", | ||
"videosFolder": "videos", | ||
"video": false | ||
} |
71 changes: 71 additions & 0 deletions
71
projects/example-app-cypress/integration/round-trip.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
context('Full round trip', () => { | ||
before(() => { | ||
window.indexedDB.deleteDatabase('books_app'); | ||
cy.visit('/'); | ||
}); | ||
|
||
it('shows a message when the credentials are wrong', () => { | ||
cy.get('[placeholder=Username]').type('wronguser'); | ||
cy.get('[placeholder=Password]').type('supersafepassword'); | ||
cy.get('[type="submit"]').click(); | ||
|
||
cy.contains('Invalid username or password').should('be.visible'); | ||
}); | ||
|
||
it('is possible to login', () => { | ||
cy.get('[placeholder=Username]') | ||
.clear() | ||
.type('test'); | ||
cy.get('[type="submit"]').click(); | ||
}); | ||
|
||
it('is possible to search for books', () => { | ||
cy.contains('My Collection'); | ||
cy.contains('menu').click(); | ||
cy.contains('Browse Books').click(); | ||
|
||
cy.get('[placeholder="Search for a book"]').type('The Alchemist'); | ||
cy.get('bc-book-preview') | ||
.its('length') | ||
.should('be.gte', 1); | ||
}); | ||
|
||
it('is possible to add books', () => { | ||
cy.get('bc-book-preview') | ||
.eq(2) | ||
.click(); | ||
|
||
cy.contains('Add Book to Collection').click(); | ||
cy.contains('Add Book to Collection').should('not.exist'); | ||
}); | ||
|
||
it('is possible to remove books', () => { | ||
cy.go('back'); | ||
|
||
cy.get('bc-book-preview') | ||
.eq(4) | ||
.click(); | ||
|
||
cy.contains('Add Book to Collection').click(); | ||
cy.contains('Remove Book from Collection').click(); | ||
cy.contains('Remove Book from Collection').should('not.exist'); | ||
}); | ||
|
||
it('is possible to show the collection', () => { | ||
cy.contains('menu').click(); | ||
cy.contains('My Collection').click(); | ||
|
||
cy.get('bc-book-preview') | ||
.its('length') | ||
.should('be', 1); | ||
}); | ||
|
||
it('is possible to sign out', () => { | ||
cy.contains('menu').click(); | ||
cy.contains('Sign Out').click(); | ||
cy.contains('OK').click(); | ||
|
||
cy.get('[placeholder=Username]').should('exist'); | ||
cy.get('[placeholder=Password]').should('exist'); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
projects/example-app-cypress/plugins/cy-ts-preprocessor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const wp = require('@cypress/webpack-preprocessor'); | ||
|
||
const webpackOptions = { | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: [/node_modules/], | ||
use: [ | ||
{ | ||
loader: 'ts-loader', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const options = { | ||
webpackOptions, | ||
}; | ||
|
||
module.exports = wp(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const cypressTypeScriptPreprocessor = require('./cy-ts-preprocessor'); | ||
|
||
module.exports = on => { | ||
on('file:preprocessor', cypressTypeScriptPreprocessor); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"baseUrl": "../../node_modules", | ||
"target": "es5", | ||
"experimentalDecorators": true, | ||
"skipLibCheck": true, | ||
"noImplicitAny": false, | ||
"lib": ["es6", "dom"], | ||
"types": ["cypress"] | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Move this into the group with the other
example:
scripts