Skip to content

Commit 0f7304f

Browse files
authored
Merge pull request #192 from Senyoret1/Improved-e2e-tests
Improved e2e tests
2 parents f11da8a + cb49c1e commit 0f7304f

20 files changed

+638
-435
lines changed
Lines changed: 54 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,71 @@
11
import { AddressDetailPage } from './address-detail.po';
2+
import { GeneralPageFunctions } from "../general.po";
23

34
describe('skycoin-explorer Address Page', () => {
45
const page = new AddressDetailPage();
6+
const generalFunctions = new GeneralPageFunctions();
57

68
beforeEach(() => { });
79

8-
it('should show the Address Text and its length should be l>26 and l<36', () => {
9-
page.navigateTo();
10-
let address = page.getAddressText();
11-
expect(address).toBeLessThan(36);
12-
expect(address).toBeGreaterThan(26);
10+
it('should display the correct title', () => {
11+
generalFunctions.navigateTo('/app/address/24ooGeabUGQLnJmoyviqA8h2y7Cgz2CY4x7');
12+
expect(generalFunctions.getPageTitle()).toBe("24ooGeabUGQLnJmoyviqA8h2y7Cgz2CY4x7");
1313
});
1414

15-
it('should show the Address Info row and its length should be 5', () => {
16-
page.navigateTo();
17-
expect(page.getAddressInfo()).toEqual(5);
15+
it('should have the title for small screens', () => {
16+
expect(page.getPageTitleForSmallScreens()).toBe("Address");
1817
});
1918

20-
it('should show the Transactions Rows and its length should be more than 0', () => {
21-
page.navigateTo();
22-
expect(page.getTransactions()).toBe(true);
19+
it('should have 5 address details rows', () => {
20+
expect(generalFunctions.getDetailsRowCount()).toEqual(5);
2321
});
2422

25-
it('should show One Transaction Input and its length should be l>26 and l<36', () => {
26-
page.navigateTo();
27-
let inputAddress = page.getOneTransactionInput();
28-
expect(inputAddress).toBeLessThan(36);
29-
expect(inputAddress).toBeGreaterThan(26);
23+
it('should have the correct address for small screens', () => {
24+
expect(page.getAddressForSmallScreens()).toEqual("24ooGeabUGQLnJmoyviqA8h2y7Cgz2CY4x7");
3025
});
3126

32-
it('should show tOne Transaction Output and its length should be l>26 and l<36', () => {
33-
page.navigateTo();
34-
let outputAddress = page.getOneTransactionOutput();
35-
expect(outputAddress).toBeLessThan(36);
36-
expect(outputAddress).toBeGreaterThan(26);
27+
it('should show the correct # of transactions', () => {
28+
expect(page.getNumberOfTransactions()).toBe(1);
29+
});
30+
31+
it('should show the correct received amount', () => {
32+
expect(page.getTotalReceived()).toBe(0.001);
33+
});
34+
35+
it('should show the correct current balance', () => {
36+
expect(page.getCurrentBalance()).toBe(0.001);
37+
});
38+
39+
it('should show the correct transaction ID', () => {
40+
expect(generalFunctions.getTransactionId(0)).toEqual('f375dfb0cea3f082daa03341f6283a483a9857206442feabc94f2b05b1df1fab');
41+
});
42+
43+
it('should show a valid transaction date', () => {
44+
expect(generalFunctions.getTransactionDateValidity(0)).toBeTruthy();
45+
});
46+
47+
it('should show the correct transaction inputs', () => {
48+
expect(generalFunctions.getTransactionInputs(0)).toBe('TXXyvkvs7Lt3EFtvTh51i4BagiJaGARsva');
49+
});
50+
51+
it('should show the correct transaction outputs', () => {
52+
expect(generalFunctions.getTransactionOutputs(0)).toBe('24ooGeabUGQLnJmoyviqA8h2y7Cgz2CY4x7,TXXyvkvs7Lt3EFtvTh51i4BagiJaGARsva');
53+
});
54+
55+
it('should have the correct coins amount', () => {
56+
expect(generalFunctions.getTransactionInputsAndOutputsTotalCoins()).toBe(6.002);
57+
});
58+
59+
it('should show the correct final address balance', () => {
60+
expect(page.getFinalBalance(0)).toBe(0.001);
61+
});
62+
63+
it('should show the correct balance variation', () => {
64+
expect(page.getBalanceChange(0)).toBe(0.001);
65+
});
66+
67+
it('should show the error message', () => {
68+
generalFunctions.navigateTo('/app/address/24ooGeabUGQLnJmoyviqA8h2y7Cgz2CY4x8');
69+
expect(generalFunctions.getErrorMessage()).toBeDefined();
3770
});
3871
});
Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,49 @@
11
import { browser, by, element } from 'protractor';
22

33
export class AddressDetailPage {
4-
navigateTo() {
5-
return browser.get('/');
4+
getPageTitleForSmallScreens() {
5+
return element(by.css('.element-details-wrapper > h2:nth-child(2)'))
6+
.getAttribute('textContent');
67
}
78

8-
goToAddressPage() {
9-
return element(by.css('.table a.-row'))
10-
.click()
11-
.then(() => {
12-
return element(by.css('.transaction > .-data > .row > div:nth-of-type(2) a'))
13-
.click();
14-
});
9+
getAddressForSmallScreens() {
10+
return element(by.css('.element-details > div:nth-of-type(1) > span:nth-of-type(2)'))
11+
.getAttribute('textContent');
1512
}
1613

17-
getAddressText() {
18-
return this.goToAddressPage().then(() => {
19-
return element(by.css('.element-details-wrapper h2:nth-of-type(1)'))
20-
.getText()
21-
.then(text => text.length);
22-
});
14+
getNumberOfTransactions() {
15+
return element(by.css('.element-details > div:nth-of-type(2) > div'))
16+
.getText()
17+
.then(text => Number(text));
2318
}
2419

25-
getAddressInfo() {
26-
return this.goToAddressPage().then(() => {
27-
return element
28-
.all(by.css('.element-details > div'))
29-
.count()
30-
.then(count => count);
31-
});
20+
getTotalReceived() {
21+
return element(by.css('.element-details > div:nth-of-type(3) > div'))
22+
.getText()
23+
.then(text => Number(text.replace(new RegExp(',', 'g'), '')));
3224
}
3325

34-
getTransactions() {
35-
return this.goToAddressPage().then(() => {
36-
return element
37-
.all(by.css('.transaction'))
38-
.count()
39-
.then(count => count > 0);
40-
});
26+
getCurrentBalance() {
27+
return element(by.css('.element-details > div:nth-of-type(3) > div'))
28+
.getText()
29+
.then(text => Number(text.replace(new RegExp(',', 'g'), '')));
4130
}
4231

43-
getOneTransactionId() {
44-
return this.goToAddressPage().then(() => {
45-
return element
46-
.all(by.css('.transaction .-title .col-sm-8.-left a'))
47-
.get(0)
48-
.getText()
49-
.then(text => text.length);
50-
});
32+
getFinalBalance(transsactionIndex: number) {
33+
return element
34+
.all(by.css('.transaction'))
35+
.get(transsactionIndex)
36+
.element(by.css('.-final-balance > div > div:nth-of-type(3)'))
37+
.getText()
38+
.then(text => Number(text.replace(new RegExp(',', 'g'), '')));
5139
}
5240

53-
getOneTransactionInput() {
54-
return this.goToAddressPage().then(() => {
55-
return element
56-
.all(by.css('.transaction > .-data > .row > div:nth-of-type(1) a'))
57-
.get(0)
58-
.getText()
59-
.then(text => text.length);
60-
});
61-
}
62-
63-
getOneTransactionOutput() {
64-
return this.goToAddressPage().then(() => {
65-
return element
66-
.all(by.css('.transaction > .-data > .row > div:nth-of-type(2) a'))
67-
.get(0)
68-
.getText()
69-
.then(text => text.length);
70-
});
41+
getBalanceChange(transsactionIndex: number) {
42+
return element
43+
.all(by.css('.transaction'))
44+
.get(transsactionIndex)
45+
.element(by.css('.-label'))
46+
.getText()
47+
.then(text => Number(text.split(' ')[0].replace(new RegExp(',', 'g'), '')));
7148
}
7249
}
Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,63 @@
11
import { BlockDetailsPage } from './block-details.po';
2+
import { GeneralPageFunctions } from "../general.po";
23

34
describe('skycoin-explorer Block Details Page', () => {
45
const page = new BlockDetailsPage();
6+
const generalFunctions = new GeneralPageFunctions();
57

68
beforeEach(() => { });
79

8-
it('should display block details text', () => {
9-
page.navigateTo();
10-
expect(page.getOneBlockDetailsText()).toEqual('Block Details');
10+
it('should display the title', () => {
11+
generalFunctions.navigateTo('/app/block/5');
12+
expect(generalFunctions.getPageTitle()).toEqual('Block Details');
1113
});
1214

1315
it('should display 6 block details rows', () => {
14-
page.navigateTo();
15-
expect(page.getDetailsRow()).toEqual(6);
16+
expect(generalFunctions.getDetailsRowCount()).toEqual(6);
1617
});
1718

18-
it('should show the details of the Hash and its length should be 64', () => {
19-
page.navigateTo();
20-
expect(page.getHash()).toEqual(64);
19+
it('should show the correct block hight', () => {
20+
expect(page.getBlockHeight()).toBe(5);
2121
});
2222

23-
it('should show the details of the Parent Hash and its length should be 64', () => {
24-
page.navigateTo();
25-
expect(page.getParentHash()).toEqual(64);
23+
it('should show a valid timestamp', () => {
24+
expect(page.getTimestampValidity()).toBeTruthy();
2625
});
2726

28-
it('should show the Transaction Id and its length should be 64', () => {
29-
page.navigateTo();
30-
expect(page.getTransactionId()).toEqual(64);
27+
it('should show the correct size', () => {
28+
expect(page.getSize()).toBe(317);
3129
});
3230

33-
it('should show one Transaction Input address and its length should be l>26 and l<36', () => {
34-
page.navigateTo();
35-
let inputAddress = page.getOneTransactionInput();
36-
expect(inputAddress).toBeLessThan(36);
37-
expect(inputAddress).toBeGreaterThan(26);
31+
it('should show the correct block hash', () => {
32+
expect(page.getBlockHash()).toEqual("114fe60587a158428a47e0f9571d764f495912c299aa4e67fc88004cf21b0c24");
3833
});
3934

40-
it('should show One Transaction Output address and its length should be l>26 and l<36', () => {
41-
page.navigateTo();
42-
let outputAddress = page.getOneTransactionOutput();
43-
expect(outputAddress).toBeLessThan(36);
44-
expect(outputAddress).toBeGreaterThan(26);
35+
it('should show the correct parent block hash', () => {
36+
expect(page.getParentHash()).toEqual("415e47348a1e642cb2e31d00ee500747d3aed0336aabfff7d783ed21465251c7");
37+
});
38+
39+
it('should show the correct amount', () => {
40+
expect(page.getAmount()).toBe(999990);
41+
});
42+
43+
it('should show the correct transaction ID', () => {
44+
expect(generalFunctions.getTransactionId(0)).toEqual('0579e7727627cd9815a8a8b5e1df86124f45a4132cc0dbd00d2f110e4f409b69');
45+
});
46+
47+
it('should show the correct transaction inputs', () => {
48+
expect(generalFunctions.getTransactionInputs(0)).toBe('R6aHqKWSQfvpdo2fGSrq4F1RYXkBWR9HHJ,R6aHqKWSQfvpdo2fGSrq4F1RYXkBWR9HHJ');
49+
});
50+
51+
it('should show the correct transaction outputs', () => {
52+
expect(generalFunctions.getTransactionOutputs(0)).toBe('R6aHqKWSQfvpdo2fGSrq4F1RYXkBWR9HHJ,2fGC7kwAM9yZyEF1QqBqp8uo9RUsF6ENGJF');
53+
});
54+
55+
it('should have the correct coins amount', () => {
56+
expect(generalFunctions.getTransactionInputsAndOutputsTotalCoins()).toBe(1999980);
57+
});
58+
59+
it('should show the error message', () => {
60+
generalFunctions.navigateTo('/app/block/-1');
61+
expect(generalFunctions.getErrorMessage()).toBeDefined();
4562
});
4663
});
Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,42 @@
11
import { browser, by, element } from 'protractor';
22

33
export class BlockDetailsPage {
4-
navigateTo() {
5-
return browser.get('/');
6-
}
74

8-
goToOneBlockDetails() {
9-
return element(by.css('.table a.-row')).click();
5+
getBlockHeight() {
6+
return element(by.css('.element-details > div:nth-of-type(1) > div'))
7+
.getText()
8+
.then(text => Number(text));
109
}
1110

12-
getOneBlockDetailsText() {
13-
return this.goToOneBlockDetails().then(() => {
14-
return element(by.css('.element-details-wrapper h2')).getText();
15-
});
11+
getTimestampValidity() {
12+
return element(by.css('.element-details > div:nth-of-type(2) > div'))
13+
.getText()
14+
.then(text => !isNaN((new Date(text)).getTime()));
1615
}
1716

18-
getDetailsRow() {
19-
return this.goToOneBlockDetails().then(() => {
20-
return element
21-
.all(by.css('.element-details .-row'))
22-
.count()
23-
.then(count => {
24-
return count;
25-
});
26-
});
17+
getSize() {
18+
return element(by.css('.element-details > div:nth-of-type(3) > div'))
19+
.getText()
20+
.then(text => Number(text.split(' ')[0]));
2721
}
2822

29-
getHash() {
30-
return this.goToOneBlockDetails().then(() => {
31-
return element
32-
.all(by.css('.element-details .-row a.-link'))
33-
.get(0)
34-
.getText()
35-
.then(text => text.length);
36-
});
23+
getBlockHash() {
24+
return element
25+
.all(by.css('.element-details .-row a.-link'))
26+
.get(0)
27+
.getText();
3728
}
3829

3930
getParentHash() {
40-
return this.goToOneBlockDetails().then(() => {
41-
return element
42-
.all(by.css('.element-details .-row a.-link'))
43-
.get(1)
44-
.getText()
45-
.then(text => text.length);
46-
});
47-
}
48-
49-
getTransactionId() {
50-
return this.goToOneBlockDetails().then(() => {
51-
return element(by.css('.transaction .-row a'))
52-
.getText()
53-
.then(text => text.length);
54-
});
55-
}
56-
57-
getOneTransactionInput() {
58-
return this.goToOneBlockDetails().then(() => {
59-
return element
60-
.all(by.css('.transaction > .-data > .row > div:nth-of-type(1) a'))
61-
.get(0)
62-
.getText()
63-
.then(text => text.length);
64-
});
31+
return element
32+
.all(by.css('.element-details .-row a.-link'))
33+
.get(1)
34+
.getText();
6535
}
6636

67-
getOneTransactionOutput() {
68-
return this.goToOneBlockDetails().then(() => {
69-
return element
70-
.all(by.css('.transaction > .-data > .row > div:nth-of-type(2) a'))
71-
.get(0)
72-
.getText()
73-
.then(text => text.length);
74-
});
37+
getAmount() {
38+
return element(by.css('.element-details > div:nth-of-type(6) > div'))
39+
.getText()
40+
.then(text => Number(text.split(' ')[0].replace(new RegExp(',', 'g'), '')));
7541
}
7642
}

0 commit comments

Comments
 (0)