mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-10-31 15:53:33 +00:00 
			
		
		
		
	Added users cypress tests
This commit is contained in:
		
							
								
								
									
										22
									
								
								test/cypress/integration/api/Health.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								test/cypress/integration/api/Health.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| /// <reference types="Cypress" /> | ||||
|  | ||||
| describe('Basic API checks', () => { | ||||
| 	it('Should return a valid health payload', function () { | ||||
| 		cy.wait(2000); | ||||
| 		cy.task('backendApiGet', { | ||||
| 			path: '/api/', | ||||
| 		}).then((data) => { | ||||
| 			// Check the swagger schema: | ||||
| 			cy.validateSwaggerSchema('get', '/', data); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should return a valid schema payload', function () { | ||||
| 		cy.wait(2000); | ||||
| 		cy.task('backendApiGet', { | ||||
| 			path: '/api/schema', | ||||
| 		}).then((data) => { | ||||
| 			expect(data.openapi).to.be.equal('3.0.0'); | ||||
| 		}); | ||||
| 	}); | ||||
| }); | ||||
							
								
								
									
										49
									
								
								test/cypress/integration/api/Users.spec.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								test/cypress/integration/api/Users.spec.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| /// <reference types="Cypress" /> | ||||
|  | ||||
| describe('Users endpoints', () => { | ||||
| 	let token; | ||||
|  | ||||
| 	before(() => { | ||||
| 		cy.getToken().then((tok) => { | ||||
| 			token = tok; | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should be able to get yourself', function() { | ||||
| 		cy.task('backendApiGet', { | ||||
| 			token: token, | ||||
| 			path:  '/api/users/me' | ||||
| 		}).then((data) => { | ||||
| 			cy.validateSwaggerSchema('get', 200, '/users/{userID}', data); | ||||
| 			expect(data).to.have.property('id'); | ||||
| 			expect(data.id).to.be.greaterThan(0); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should be able to get all users', function() { | ||||
| 		cy.task('backendApiGet', { | ||||
| 			token: token, | ||||
| 			path:  '/api/users' | ||||
| 		}).then((data) => { | ||||
| 			cy.validateSwaggerSchema('get', 200, '/users', data); | ||||
| 			expect(typeof data).to.be.equal('array'); | ||||
| 			expect(data.length).to.be.greaterThan(0); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('Should be able to update yourself', function() { | ||||
| 		cy.task('backendApiPut', { | ||||
| 			token: token, | ||||
| 			path:  '/api/users/me', | ||||
| 			data:  { | ||||
| 				name: 'changed name' | ||||
| 			} | ||||
| 		}).then((data) => { | ||||
| 			cy.validateSwaggerSchema('put', 200, '/users/{userID}', data); | ||||
| 			expect(data).to.have.property('id'); | ||||
| 			expect(data.id).to.be.greaterThan(0); | ||||
| 			expect(data.name).to.be.equal('changed name'); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user