docs: init cypress test e2e

Signed-off-by: jffarge <jf@dagger.io>
This commit is contained in:
jffarge
2021-07-02 11:23:12 +02:00
parent 795430024b
commit 868339e174
15 changed files with 1091 additions and 56 deletions

View File

@@ -0,0 +1,4 @@
{
"message": "Bad credentials",
"documentation_url": "https://docs.github.com/rest"
}

View File

@@ -0,0 +1,5 @@
{
"error":"bad_verification_code",
"error_description":"The code passed is incorrect or expired.",
"error_uri":"https://docs.github.com/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#bad-verification-code"
}

View File

@@ -0,0 +1,53 @@
describe('Visit Docs website', function() {
it('Visit docs website without authentication', function() {
cy.visit('http://localhost:3000')
cy.get('[data-cy="cy-signin"]').should('not.exist')
}),
it('Visit docs website with authentication', function() {
cy.visit('http://localhost:3001')
cy.get('[data-cy="cy-signin"]').should('exist')
})
context('When user is authenticated', function() {
beforeEach(() => {
cy.setLocalStorage('user', "{\"permission\":true,\"login\":\"slumbering\"}")
cy.intercept('/t', 'success').as('logAmplitude')
cy.visit(('http://localhost:3001'))
})
it('Visit docs website with a valid authenticated user', function() {
cy.get('[data-cy=cy-doc-content]').should('exist')
})
it('log to amplitude when user visit another page', function() {
cy.get('[data-cy=cy-doc-content]').should('exist')
cy.get('.menu > :nth-child(2) > :nth-child(2) > .menu__link').click()
})
})
context('When user is not authorized', function() {
it('Redirect user after unsuccessful sign in', function() {
cy.intercept('**/login/oauth/access_token?code=jergub54545&client_id=123&client_secret=321', {fixture: 'bad_verification.code.json'})
cy.intercept('**/user', (req) => {
req.continue((res) => {
expect(res.statusCode).to.be.equal(401)
})
})
cy.visit('http://localhost:3001?code=jergub54545')
cy.get('[data-cy=cy-page-redirect]').should('exist')
// cy.wait(10000)
// cy.location().should((location) => {
// expect(location.host).to.eq('dagger.io')
// })
})
it('Visit docs website with a user not authorized', function() {
cy.setLocalStorage('user', "{\"permission\":false,\"login\":\"slumbering\"}")
cy.visit('http://localhost:3001')
cy.get('[data-cy=cy-page-redirect]').should('exist')
cy.intercept('/t', 'success')
})
})
})

View File

@@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@@ -0,0 +1,26 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
import "cypress-localstorage-commands"

View File

@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')

4
website/cypress/videos/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore