generated from KevinBatdorf/gutenberg-rust-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from KevinBatdorf/update-testing-flow
Add e2e login tests
- Loading branch information
Showing
16 changed files
with
137 additions
and
50 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 |
---|---|---|
|
@@ -9,3 +9,5 @@ cypress/videos/**/* | |
!cypress/videos/**/.gitkeep | ||
cypress/downloads/**/* | ||
cypress/downloads/**/.gitkeep | ||
|
||
.env |
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { defineConfig } from 'cypress'; | ||
import * as dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
// We've imported your old cypress plugins here. | ||
// You may want to clean this up later by importing these. | ||
setupNodeEvents(on, config) { | ||
return require('./cypress/plugins/index.js')(on, config); | ||
}, | ||
defaultCommandTimeout: 60000, | ||
// defaultCommandTimeout: 60000, | ||
}, | ||
env: { | ||
API_TOKEN: process.env.API_TOKEN, | ||
}, | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
context('Login checks', () => { | ||
it('The wrong API key will show an error', () => { | ||
// Adds our block | ||
cy.addOurBlock(); | ||
|
||
// Click the login with nothing entered | ||
cy.get('[data-cy="login-button"]').should('exist').click(); | ||
|
||
// See no error | ||
cy.get('[data-cy="login-error"]').should('not.exist'); | ||
|
||
// Type in random stuff and click login | ||
cy.get('#replicate-api-key').type('random'); | ||
cy.get('[data-cy="login-button"]').should('exist').click(); | ||
|
||
// See error | ||
cy.get('[data-cy="login-error"]').should('exist'); | ||
|
||
cy.closeModal(); | ||
}); | ||
|
||
it('Successful login will show the select screen', () => { | ||
// Adds our block | ||
cy.addOurBlock(); | ||
|
||
// Confirm model screen is not there | ||
cy.get('[data-cy="model-screen"]').should('not.exist'); | ||
|
||
// Type in real API Token | ||
cy.get('#replicate-api-key').type(Cypress.env('API_TOKEN')); | ||
cy.get('[data-cy="login-button"]').should('exist').click(); | ||
|
||
// See model select screen | ||
cy.get('[data-cy="model-select"]').should('exist'); | ||
|
||
cy.closeModal(); | ||
}); | ||
}); |
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 @@ | ||
context('Starting up', () => { | ||
afterEach(() => { | ||
cy.window().then((win) => { | ||
expect(win.console.error).to.have.callCount(0); | ||
}); | ||
}); | ||
|
||
it('The image block is inserted', () => { | ||
// Adds our block | ||
cy.addOurBlock(); | ||
cy.closeModal(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export const closeOurModal = () => { | ||
const modalButton = | ||
'.stable-diffusion-editor.stable-diffusion-modal button[aria-label="Close"]'; | ||
cy.get(modalButton).click(); | ||
|
||
// Check the core image block is there | ||
cy.getPostContent('.wp-block[class$="wp-block-image"]').should('not.exist'); | ||
}; | ||
|
||
export const maybeLogin = () => { | ||
cy.get('body').then((body) => { | ||
if (body.find('[data-cy="login-button"]').length > 0) { | ||
cy.get('#replicate-api-key').type(Cypress.env('API_TOKEN')); | ||
cy.get('[data-cy="login-button"]').should('exist').click(); | ||
|
||
// See model select screen | ||
cy.get('[data-cy="model-screen"]').should('exist'); | ||
} | ||
}); | ||
}; | ||
|
||
export const maybeLogout = () => { | ||
cy.get('.stable-diffusion-modal').should('exist'); | ||
cy.get('body').then((body) => { | ||
if (body.find('[data-cy="logout"]').length > 0) { | ||
cy.get('[data-cy="logout"]').click(); | ||
cy.get('[data-cy="login-button"').should('exist'); | ||
} | ||
}); | ||
cy.get('[data-cy="login-screen"]').should('exist'); | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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