mirror of https://github.com/portainer/portainer
				
				
				
			feat(project): add automated testing with cypress (#3305)
* feat(project): add automated testing with cypress * feat(project): made suggested edits * feat(project): add init test * feat(project): add socket to correct containerpull/3314/head
							parent
							
								
									542b76912a
								
							
						
					
					
						commit
						91c83eccd2
					
				| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					PORTAINER_TAG=develop
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    "video": false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					// Tests to run
 | 
				
			||||||
 | 
					context('Tests to run', () => {
 | 
				
			||||||
 | 
					  //Browse to homepage before each test
 | 
				
			||||||
 | 
					  beforeEach(() => {
 | 
				
			||||||
 | 
					    cy.visit('/')
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  describe('Init admin', function() {
 | 
				
			||||||
 | 
					    it('Create user and verify success', function() {
 | 
				
			||||||
 | 
					      cy.get('#username')
 | 
				
			||||||
 | 
					      .should('have.value', 'admin')
 | 
				
			||||||
 | 
					      cy.get('#password')
 | 
				
			||||||
 | 
					      .type('portaineriscool')
 | 
				
			||||||
 | 
					      .should('have.value', 'portaineriscool')
 | 
				
			||||||
 | 
					      cy.get('#confirm_password')
 | 
				
			||||||
 | 
					      .type('portaineriscool')
 | 
				
			||||||
 | 
					      .should('have.value', 'portaineriscool')
 | 
				
			||||||
 | 
					      cy.get('[type=submit]').click()
 | 
				
			||||||
 | 
					      cy.url().should('include', '/init/endpoint')
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					// ***********************************************************
 | 
				
			||||||
 | 
					// 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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module.exports = (on, config) => {
 | 
				
			||||||
 | 
					  // `on` is used to hook into various events Cypress emits
 | 
				
			||||||
 | 
					  // `config` is the resolved Cypress config
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					// ***********************************************
 | 
				
			||||||
 | 
					// 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 is will overwrite an existing command --
 | 
				
			||||||
 | 
					// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
 | 
				
			||||||
| 
						 | 
					@ -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')
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					version: '3'
 | 
				
			||||||
 | 
					services:
 | 
				
			||||||
 | 
					  portainer:
 | 
				
			||||||
 | 
					    image: portainerci/portainer:$PORTAINER_TAG
 | 
				
			||||||
 | 
					    container_name: e2e-portainer
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - /var/run/docker.sock:/var/run/docker.sock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  cypress:
 | 
				
			||||||
 | 
					    image: cypress/included:3.4.1
 | 
				
			||||||
 | 
					    container_name: e2e-cypress
 | 
				
			||||||
 | 
					    depends_on:
 | 
				
			||||||
 | 
					      - portainer
 | 
				
			||||||
 | 
					    working_dir: /app
 | 
				
			||||||
 | 
					    environment:
 | 
				
			||||||
 | 
					      - CYPRESS_baseUrl=http://e2e-portainer:9000
 | 
				
			||||||
 | 
					    volumes:
 | 
				
			||||||
 | 
					      - ./cypress:/app/cypress
 | 
				
			||||||
 | 
					      - ./cypress.json:/app/cypress.json
 | 
				
			||||||
		Loading…
	
		Reference in New Issue