Skip to content

Commit 8826748

Browse files
committed
Added upstreams tests for cypress
1 parent e39f18b commit 8826748

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

test/cypress/integration/api/Settings.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Settings endpoints', () => {
1212
});
1313
});
1414

15-
it('Should be able to create new settting', function() {
15+
it('Should be able to create new setting', function() {
1616
cy.task('backendApiPost', {
1717
token: token,
1818
path: '/api/settings',
@@ -31,7 +31,7 @@ describe('Settings endpoints', () => {
3131
});
3232
});
3333

34-
it('Should be able to get a settting', function() {
34+
it('Should be able to get a setting', function() {
3535
cy.task('backendApiGet', {
3636
token: token,
3737
path: '/api/settings/' + settingName
@@ -44,7 +44,7 @@ describe('Settings endpoints', () => {
4444
});
4545
});
4646

47-
it('Should be able to update a settting', function() {
47+
it('Should be able to update a setting', function() {
4848
cy.task('backendApiPut', {
4949
token: token,
5050
path: '/api/settings/' + settingName,
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/// <reference types="Cypress" />
2+
3+
describe('Upstream endpoints', () => {
4+
let token;
5+
let upstreamId;
6+
7+
before(() => {
8+
cy.getToken().then((tok) => {
9+
token = tok;
10+
});
11+
});
12+
13+
it('Should be able to create new Upstream', function() {
14+
cy.task('backendApiPost', {
15+
token: token,
16+
path: '/api/upstreams',
17+
data: {
18+
nginx_template_id: 5,
19+
name: 'CypressGeneratedUpstreamA',
20+
// These servers must be reachable by the Cypress CI stack!
21+
servers: [
22+
{
23+
24+
server: 'fullstack:80',
25+
weight: 100
26+
},
27+
{
28+
server: 'fullstack:443',
29+
weight: 50
30+
}
31+
]
32+
}
33+
}).then((data) => {
34+
// Check the swagger schema:
35+
cy.validateSwaggerSchema('post', 201, '/upstreams', data);
36+
expect(data.result).to.have.property('id');
37+
expect(data.result.id).to.be.greaterThan(0);
38+
upstreamId = data.result.id;
39+
});
40+
});
41+
42+
it('Should be able to get a Upstream', function() {
43+
cy.task('backendApiGet', {
44+
token: token,
45+
path: '/api/upstreams/' + upstreamId
46+
}).then((data) => {
47+
// Check the swagger schema:
48+
cy.validateSwaggerSchema('get', 200, '/upstreams/{upstreamID}', data);
49+
expect(data.result).to.have.property('id');
50+
expect(data.result).to.have.property('name', 'CypressGeneratedUpstreamA');
51+
expect(data.result.id).to.be.greaterThan(0);
52+
});
53+
});
54+
55+
it('Should be able to get all Upstreams', function() {
56+
cy.task('backendApiGet', {
57+
token: token,
58+
path: '/api/upstreams'
59+
}).then((data) => {
60+
cy.validateSwaggerSchema('get', 200, '/upstreams', data);
61+
expect(data).to.have.property('result');
62+
expect(data.result).to.have.property('items');
63+
expect(data.result.items.length).to.be.greaterThan(0);
64+
});
65+
});
66+
67+
});

0 commit comments

Comments
 (0)