test(e2e): adjust tests to fit refactored version of the app
This commit is contained in:
committed by
Benedikt Rötsch
parent
c7567ca895
commit
1e271656de
@@ -12,7 +12,7 @@ app.set('port', TEST_PORT)
|
||||
|
||||
const server = http.createServer(app)
|
||||
|
||||
const { CF_SPACE, CF_ACCESS_TOKEN, CF_PREVIEW_ACCESS_TOKEN } = process.env
|
||||
const { CONTENTFUL_SPACE_ID, CONTENTFUL_DELIVERY_TOKEN, CONTENTFUL_PREVIEW_TOKEN } = process.env
|
||||
|
||||
server.on('error', console.error)
|
||||
server.listen(TEST_PORT, function () {
|
||||
@@ -20,7 +20,7 @@ server.listen(TEST_PORT, function () {
|
||||
spec: resolve(__dirname, 'specs', 'the-example-app-spec.js'),
|
||||
headed: !process.env.CI,
|
||||
env: {
|
||||
CF_SPACE, CF_ACCESS_TOKEN, CF_PREVIEW_ACCESS_TOKEN
|
||||
CONTENTFUL_SPACE_ID, CONTENTFUL_DELIVERY_TOKEN, CONTENTFUL_PREVIEW_TOKEN
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
@@ -176,55 +176,55 @@ describe('The Example App', () => {
|
||||
.invoke('text').then((text) => {
|
||||
expect(text).to.match(/Connected to space “.+”/)
|
||||
})
|
||||
cy.get('input#input-space').should('have.value', Cypress.env('CF_SPACE'))
|
||||
cy.get('input#input-cda').should('have.value', Cypress.env('CF_ACCESS_TOKEN'))
|
||||
cy.get('input#input-cpa').should('have.value', Cypress.env('CF_PREVIEW_ACCESS_TOKEN'))
|
||||
cy.get('input#input-space-id').should('have.value', Cypress.env('CONTENTFUL_SPACE_ID'))
|
||||
cy.get('input#input-delivery-token').should('have.value', Cypress.env('CONTENTFUL_DELIVERY_TOKEN'))
|
||||
cy.get('input#input-preview-token').should('have.value', Cypress.env('CONTENTFUL_PREVIEW_TOKEN'))
|
||||
})
|
||||
|
||||
it('checks for required fields', () => {
|
||||
cy.get('input#input-space').clear()
|
||||
cy.get('input#input-cda').clear()
|
||||
cy.get('input#input-cpa').clear()
|
||||
cy.get('input#input-space-id').clear()
|
||||
cy.get('input#input-delivery-token').clear()
|
||||
cy.get('input#input-preview-token').clear()
|
||||
cy.get('input[type=submit]').click()
|
||||
|
||||
cy.get('.status-block--info').should('not.exist')
|
||||
cy.get('.status-block--success').should('not.exist')
|
||||
cy.get('.status-block--error').should('exist')
|
||||
|
||||
cy.get('input#input-space').parent().children('.form-item__error-wrapper')
|
||||
cy.get('input#input-space-id').parent().children('.form-item__error-wrapper')
|
||||
.should('exist')
|
||||
.find('.form-item__error-message')
|
||||
.should('have.text', 'This field is required')
|
||||
cy.get('input#input-cda').parent().children('.form-item__error-wrapper')
|
||||
cy.get('input#input-delivery-token').parent().children('.form-item__error-wrapper')
|
||||
.should('exist')
|
||||
.find('.form-item__error-message')
|
||||
.should('have.text', 'This field is required')
|
||||
cy.get('input#input-cpa').parent().children('.form-item__error-wrapper')
|
||||
cy.get('input#input-preview-token').parent().children('.form-item__error-wrapper')
|
||||
.should('exist')
|
||||
.find('.form-item__error-message')
|
||||
.should('have.text', 'This field is required')
|
||||
})
|
||||
|
||||
it('validates field with actual client', () => {
|
||||
cy.get('input#input-space').clear().type(Math.random().toString(36).substring(12))
|
||||
cy.get('input#input-cda').clear().type(Math.random().toString(36))
|
||||
cy.get('input#input-cpa').clear().type(Math.random().toString(36))
|
||||
cy.get('input#input-space-id').clear().type(Math.random().toString(36).substring(12))
|
||||
cy.get('input#input-delivery-token').clear().type(Math.random().toString(36))
|
||||
cy.get('input#input-preview-token').clear().type(Math.random().toString(36))
|
||||
cy.get('input[type=submit]').click()
|
||||
|
||||
cy.get('.status-block--info').should('not.exist')
|
||||
cy.get('.status-block--success').should('not.exist')
|
||||
cy.get('.status-block--error').should('exist')
|
||||
|
||||
cy.get('input#input-cda').parent().children('.form-item__error-wrapper')
|
||||
cy.get('input#input-delivery-token').parent().children('.form-item__error-wrapper')
|
||||
.should('exist')
|
||||
.find('.form-item__error-message')
|
||||
.should('have.text', 'Your Delivery API key is invalid.')
|
||||
})
|
||||
|
||||
it('shows success message when valid credentials are supplied', () => {
|
||||
cy.get('input#input-space').clear().type(Cypress.env('CF_SPACE'))
|
||||
cy.get('input#input-cda').clear().type(Cypress.env('CF_ACCESS_TOKEN'))
|
||||
cy.get('input#input-cpa').clear().type(Cypress.env('CF_PREVIEW_ACCESS_TOKEN'))
|
||||
cy.get('input#input-space-id').clear().type(Cypress.env('CONTENTFUL_SPACE_ID'))
|
||||
cy.get('input#input-delivery-token').clear().type(Cypress.env('CONTENTFUL_DELIVERY_TOKEN'))
|
||||
cy.get('input#input-preview-token').clear().type(Cypress.env('CONTENTFUL_PREVIEW_TOKEN'))
|
||||
cy.get('input[type=submit]').click()
|
||||
|
||||
cy.get('.status-block--info').should('exist')
|
||||
|
||||
Reference in New Issue
Block a user