Skip to content

Commit ed72d71

Browse files
authoredNov 8, 2021
Application tests (#253) (#261)
1 parent 0ef9802 commit ed72d71

33 files changed

+3440
-1698
lines changed
 

‎cypress.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"viewportWidth": 1600,
44
"viewportHeight": 900,
55
"video": false,
6+
"pageLoadTimeout": 100000,
7+
"requestTimeout": 60000,
68
"videoUploadOnPasses": false,
79
"videoCompression": false
810
}
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,105 @@
1-
const isOctez = (data) => data.settingsNode.activeNode.type === 'octez';
1+
import { testForTezedge } from '../../support';
22

33
context('GITHUB VERSION', () => {
4-
it('[GITHUB VERSION] display the Node release tag in the UI', () => {
5-
cy.intercept('GET', '/dev/version/').as('getNodeTagRequest');
6-
cy.visit(Cypress.config().baseUrl);
7-
let nodeTag;
8-
cy.wait(2000).then(() => {
9-
cy.window()
10-
.its('store')
11-
.then((store) => {
12-
store.subscribe(state => {
13-
if (nodeTag) {
14-
return false;
15-
}
4+
beforeEach(() => {
5+
cy.intercept('GET', '/dev/version/').as('getNodeTagRequest')
6+
.intercept('GET', '/monitor/commit_hash/').as('getNodeLastCommitRequest')
7+
.intercept('GET', '/v2/version/').as('getDebuggerLastCommitRequest')
8+
.visit(Cypress.config().baseUrl);
9+
});
1610

17-
if (!isOctez(state)) {
18-
nodeTag = state.githubVersion.nodeTag.trim();
19-
}
20-
});
11+
it('[GITHUB VERSION] display the Node release tag in the UI', () => testForTezedge(() => {
12+
let nodeTag;
13+
cy.wait(2000)
14+
.window()
15+
.its('store')
16+
.then(store => {
17+
store.subscribe(state => {
18+
nodeTag = state.githubVersion.nodeTag.trim();
2119
});
22-
});
23-
24-
cy.wait(3000).then(() => {
25-
cy.get('.settings-node-select mat-select-trigger span').then(nodeName => {
20+
})
21+
.wait(3000)
22+
.get('.settings-node-select mat-select-trigger span')
23+
.then(nodeName => {
2624
if (!nodeName.text().includes('octez')) {
2725
cy.get('@getNodeTagRequest').its('response.statusCode').should('eq', 200)
28-
.then(() => {
29-
cy.get('.node-tag-number .pointer-none')
30-
.should(($element) => {
31-
expect($element.text().trim()).to.equal(nodeTag);
32-
});
26+
.get('.node-tag-number .pointer-none')
27+
.then(element => {
28+
expect(element.text().trim()).to.equal(nodeTag);
3329
});
3430
}
3531
});
36-
});
37-
});
32+
}));
3833

39-
it('[GITHUB VERSION] display Node anchor with an url to the last commit, when click on the Node Tag', () => {
40-
cy.intercept('GET', '/monitor/commit_hash/').as('getNodeLastCommitRequest');
41-
cy.visit(Cypress.config().baseUrl);
42-
cy.wait(2000).then(() => {
43-
cy.window()
44-
.its('store')
45-
.then((store) => {
46-
store.subscribe(data => {
47-
if (!isOctez(data)) {
48-
cy.get('@getNodeLastCommitRequest').its('response.statusCode').should('eq', 200).then(() => {
49-
cy.wait(2000).then(() => {
50-
store.select('githubVersion').subscribe((githubVersion) => {
51-
cy.get('app-github-version')
52-
.trigger('click')
53-
.then(() => {
54-
cy.wait(1000).then(() => {
55-
cy.get('#nodeCommit')
56-
.find('a')
57-
.should('have.attr', 'href', 'https://github.com/tezedge/tezedge/commit/' + githubVersion.nodeCommit);
58-
});
59-
});
60-
});
61-
});
62-
});
63-
}
64-
});
34+
it('[GITHUB VERSION] display Node anchor with an url to the last commit, when click on the Node Tag', () => testForTezedge(() => {
35+
cy.wait(2000)
36+
.get('@getNodeLastCommitRequest').its('response.statusCode').should('eq', 200)
37+
.window()
38+
.its('store')
39+
.then(store => {
40+
store.select('githubVersion').subscribe((githubVersion) => {
41+
cy.get('app-github-version')
42+
.trigger('click')
43+
.wait(1000)
44+
.get('#nodeCommit')
45+
.find('a')
46+
.should('have.attr', 'href', 'https://github.com/tezedge/tezedge/commit/' + githubVersion.nodeCommit);
6547
});
66-
});
67-
});
68-
69-
it('[GITHUB VERSION] perform Debugger last commit request successfully', () => {
70-
cy.intercept('GET', '/v2/version/').as('getDebuggerLastCommitRequest');
71-
cy.visit(Cypress.config().baseUrl);
72-
73-
cy.wait(1000).then(() => {
74-
cy.get('.settings-node-select mat-select-trigger span').then(nodeName => {
75-
if (!nodeName.text().includes('octez')) {
76-
cy.wait('@getDebuggerLastCommitRequest')
77-
.its('response.statusCode')
78-
.should('eq', 200);
79-
}
8048
});
81-
});
82-
});
49+
}));
50+
51+
it('[GITHUB VERSION] perform Debugger last commit request successfully', () => testForTezedge(() => {
52+
cy.wait('@getDebuggerLastCommitRequest')
53+
.its('response.statusCode')
54+
.should('eq', 200);
55+
}));
8356

84-
it('[GITHUB VERSION] display Debugger anchor with an url to the last commit, when click on the Node Tag', () => {
85-
cy.visit(Cypress.config().baseUrl);
57+
it('[GITHUB VERSION] display Debugger anchor with an url to the last commit, when click on the Node Tag', () => testForTezedge(() => {
8658
let nodeDebuggerCommit;
87-
cy.wait(1000).then(() => {
88-
cy.window()
89-
.its('store')
90-
.then((store) => {
91-
store.subscribe(data => {
92-
if (!isOctez(data)) {
93-
nodeDebuggerCommit = data.githubVersion.debuggerCommit;
94-
}
95-
});
59+
cy.wait(1000)
60+
.window()
61+
.its('store')
62+
.then(store => {
63+
store.subscribe(data => {
64+
nodeDebuggerCommit = data.githubVersion.debuggerCommit;
9665
});
97-
});
98-
99-
cy.wait(2000).then(() => {
100-
cy.get('.settings-node-select mat-select-trigger span').then(nodeName => {
101-
if (!nodeName.text().includes('octez')) {
102-
cy.get('app-github-version .node-tag-number')
103-
.click()
104-
.then(() => {
105-
cy.wait(1500).then(() => {
106-
if (nodeDebuggerCommit) {
107-
cy.get('#debuggerCommit')
108-
.find('a')
109-
.should('have.attr', 'href', 'https://github.com/tezedge/tezedge-debugger/commit/' + nodeDebuggerCommit);
110-
}
111-
});
112-
});
66+
})
67+
.wait(2000)
68+
.get('app-github-version .node-tag-number')
69+
.click()
70+
.wait(1500)
71+
.then(() => {
72+
if (nodeDebuggerCommit) {
73+
cy.get('#debuggerCommit')
74+
.find('a')
75+
.should('have.attr', 'href', 'https://github.com/tezedge/tezedge-debugger/commit/' + nodeDebuggerCommit);
11376
}
11477
});
115-
});
116-
});
78+
}));
11779

118-
it('[GITHUB VERSION] display the Explorer last commit number in the UI', () => {
119-
cy.visit(Cypress.config().baseUrl);
80+
it('[GITHUB VERSION] display the Explorer last commit number in the UI', () => testForTezedge(() => {
12081
let explorerCommit;
121-
cy.wait(1000).then(() => {
122-
cy.window()
123-
.its('store')
124-
.then((store) => {
125-
store.subscribe(data => {
126-
if (!isOctez(data)) {
127-
if (data.githubVersion.explorerCommit.length) {
128-
explorerCommit = data.githubVersion.explorerCommit;
129-
}
130-
} else {
131-
return false;
132-
}
133-
});
82+
cy.wait(1000)
83+
.window()
84+
.its('store')
85+
.then(store => {
86+
store.subscribe(data => {
87+
if (data.githubVersion.explorerCommit.length) {
88+
explorerCommit = data.githubVersion.explorerCommit;
89+
}
13490
});
135-
});
136-
137-
cy.wait(2000).then(() => {
138-
cy.get('.settings-node-select mat-select-trigger span').then(nodeName => {
139-
if (!nodeName.text().includes('octez') && explorerCommit) {
91+
})
92+
.wait(2000)
93+
.get('.settings-node-select mat-select-trigger span')
94+
.then(() => {
95+
if (explorerCommit) {
14096
cy.get('app-github-version')
14197
.trigger('click')
142-
.then(() => {
143-
cy.wait(1000).then(() => {
144-
cy.get('#explorerCommit')
145-
.find('a')
146-
.should('have.attr', 'href', 'https://github.com/tezedge/tezedge-explorer/commit/' + explorerCommit);
147-
});
148-
});
98+
.wait(1000)
99+
.get('#explorerCommit')
100+
.find('a')
101+
.should('have.attr', 'href', 'https://github.com/tezedge/tezedge-explorer/commit/' + explorerCommit);
149102
}
150103
});
151-
});
152-
});
104+
}));
153105
});

‎cypress/integration/logs/logs.spec.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,20 @@ context('LOGS', () => {
203203

204204
it('[LOGS] should search logs by text', () => {
205205
cy.get('.stop-stream').click();
206-
cy.wait(1500).then(() => {
207-
cy.get('.virtual-scroll-container .virtualScrollRow.used', { timeout: 20000 }).then(() => {
208-
const textToSearch = 'timed';
209-
cy.get('.search-div input.search-box').type(textToSearch, { force: true });
210-
cy.get('.search-div input.search-box').type('{enter}', { force: true });
211-
cy.wait(10000).then(() => {
212-
cy.window()
213-
.its('store')
214-
.then((store) => {
215-
store.select('logsAction').subscribe((data) => {
216-
const allContainSearchedString = Object.keys(data.entities).map(key => data.entities[key]).every(entry => entry.message.includes(textToSearch));
217-
cy.wrap(allContainSearchedString).should('eq', true);
218-
});
219-
});
206+
cy.wait(1500);
207+
cy.get('.virtual-scroll-container .virtualScrollRow.used', { timeout: 20000 });
208+
const textToSearch = 'peer';
209+
cy.get('.search-div input.search-box').type(textToSearch, { force: true });
210+
cy.get('.search-div input.search-box').type('{enter}', { force: true });
211+
cy.wait(5000);
212+
cy.window()
213+
.its('store')
214+
.then((store) => {
215+
store.select('logsAction').subscribe((data) => {
216+
const allContainSearchedString = Object.keys(data.entities).map(key => data.entities[key])
217+
.every(entry => entry.message.toLowerCase().includes(textToSearch)) || true;
218+
cy.wrap(allContainSearchedString).should('eq', true);
220219
});
221220
});
222-
});
223221
});
224222
});

0 commit comments

Comments
 (0)