forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into npm-scripts-cleanup
- Loading branch information
Showing
17 changed files
with
256 additions
and
94 deletions.
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
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 |
---|---|---|
|
@@ -75,3 +75,4 @@ junit.xml | |
# Cypress | ||
cypress/screenshots | ||
cypress/videos | ||
cypress/mock |
This file was deleted.
Oops, something went wrong.
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
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,40 @@ | ||
describe('Nav Bar', () => { | ||
// Testing links which should open in a new tab is a bit tricky in Cypress. | ||
// The discussion at this page lists some of the details. | ||
// https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/testing-dom__tab-handling-links/cypress/integration/tab_handling_anchor_links_spec.js | ||
[ | ||
{ text: 'Dashboard', target: '/admin' }, | ||
{ text: 'Users', target: '/admin/users' }, | ||
{ text: 'Posts', target: '/admin/posts' }, | ||
{ text: 'Post Categories', target: '/admin/post-categories' }, | ||
{ | ||
text: 'GitHub', | ||
target: 'https://github.com/keystonejs/keystone-5', | ||
newTab: true, | ||
}, | ||
{ text: 'Graphiql', target: '/admin/graphiql', newTab: true }, | ||
{ text: 'Style Guide', target: '/admin/style-guide' }, | ||
{ text: 'Sign Out', target: '/admin/signin' }, | ||
].forEach(({ text, target, newTab = false }) => { | ||
it(`${newTab ? 'Check' : 'Click'} ${text}`, () => { | ||
cy.visit('http://localhost:3000/admin'); | ||
|
||
cy | ||
.get('nav') | ||
.contains(text) | ||
.should('have.attr', 'href', target); | ||
if (newTab) { | ||
cy | ||
.get('nav') | ||
.contains(text) | ||
.should('have.attr', 'target', '_blank'); | ||
} else { | ||
cy | ||
.get('nav') | ||
.contains(text) | ||
.click(); | ||
cy.url().should('include', target); | ||
} | ||
}); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
cypress/integration/relationship-field-re-hydration_spec.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,36 @@ | ||
describe('Testing re-hydration', () => { | ||
before(() => { | ||
cy.visit('http://localhost:3000/admin/posts'); | ||
cy.get('button[appearance="create"]').click(); | ||
cy | ||
.get('label[for="ks-input-categories"] + div div[role="button"] > svg') | ||
.click(); | ||
cy | ||
.get('label[for="ks-input-categories"] + div div[role="listbox"]') | ||
.should('not.contain', 'New Category'); | ||
}); | ||
|
||
after(() => { | ||
cy.visit('http://localhost:3000/admin/post-categories'); | ||
cy.get('a:contains("New Category"):first').click(); | ||
cy.get('button:contains("Delete"):first').click(); | ||
cy.get('body:last footer button:first').click(); | ||
}); | ||
|
||
it('Our new category should appear after we add it', () => { | ||
cy.visit('http://localhost:3000/admin/post-categories'); | ||
cy.get('button[appearance="create"]').click(); | ||
cy.get('#ks-input-name').type('New Category'); | ||
cy.get('div[class*="Dialog"] button[appearance="create"]').click(); | ||
cy.get('body').should('contain', 'New Category'); | ||
|
||
cy.get('nav a:contains("Posts")').click(); | ||
cy.get('button[appearance="create"]').click(); | ||
cy | ||
.get('label[for="ks-input-categories"] + div div[role="button"] > svg') | ||
.click(); | ||
cy | ||
.get('label[for="ks-input-categories"] + div div[role="listbox"]') | ||
.should('contain', 'New Category'); | ||
}); | ||
}); |
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,55 @@ | ||
describe('Adding data', () => { | ||
[ | ||
{ | ||
text: 'User', | ||
url: 'http://localhost:3000/admin/users', | ||
data: { | ||
'ks-input-name': 'John Doe', | ||
'ks-input-email': '[email protected]', | ||
'ks-input-password': 'password1', | ||
'ks-input-twitterId': '@johndoe', | ||
'ks-input-twitterUsername': 'John Doe', | ||
}, | ||
}, | ||
{ | ||
text: 'Post', | ||
url: 'http://localhost:3000/admin/posts', | ||
data: { | ||
'ks-input-name': 'My post', | ||
'ks-input-slug': 'mypost', | ||
}, | ||
}, | ||
{ | ||
text: 'Post Category', | ||
url: 'http://localhost:3000/admin/post-categories', | ||
data: { | ||
'ks-input-name': 'My category', | ||
'ks-input-slug': 'mycategory', | ||
}, | ||
}, | ||
].forEach(({ text, url, data }) => { | ||
it(`Adding data to ${text}`, () => { | ||
cy.visit(url); | ||
cy.get('button[appearance="create"]').click(); | ||
|
||
Object.keys(data).forEach(item => { | ||
cy.get(`#${item}`).type(data[item]); | ||
}); | ||
|
||
// Setup to track XHR requests | ||
cy.server(); | ||
// Alias the graphql request route | ||
cy.route('post', '**/admin/api').as('graphqlPost'); | ||
// Avoid accidentally mocking routes | ||
cy.server({ enable: false }); | ||
|
||
cy.get('div[class*="Dialog"] button[appearance="create"]').click(); | ||
|
||
cy.wait('@graphqlPost'); | ||
|
||
Object.keys(data).forEach(item => { | ||
cy.get(`#${item}`).should('have.value', data[item]); | ||
}); | ||
}); | ||
}); | ||
}); |
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,15 @@ | ||
describe('Test Project Smoke Tests', () => { | ||
it('Should be able to access welcome message /', () => { | ||
cy.visit('http://localhost:3000/'); | ||
|
||
cy.get('body').should('contain', 'Welcome'); | ||
}); | ||
|
||
it('Should be able to click through to admin page.', () => { | ||
cy.visit('http://localhost:3000/'); | ||
|
||
cy.contains('Open').click(); | ||
|
||
cy.url().should('include', '/admin'); | ||
}); | ||
}); |
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
Oops, something went wrong.