Skip to content

Commit

Permalink
Merge pull request #9 from Marketionist/feature/server
Browse files Browse the repository at this point in the history
Updated tests to run on the test server
  • Loading branch information
Marketionist authored Jan 23, 2017
2 parents 39d6687 + bd63e81 commit 8498d3a
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 115 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ before_install:
install:
- npm install

before_script:
- npm start

# http://docs.travis-ci.com/user/pull-requests/
script:
- npm test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports.config = {
],

capabilities: {
'browserName': 'chrome'
browserName: 'chrome'
},

onPrepare: function () {
Expand Down Expand Up @@ -68,7 +68,7 @@ like this:

```javascript
let second = element.all(by.css('.items li')).second();
let third = element.all(by.xpath('//li[@class="items"]')).third();
let third = element.all(by.xpath('//li[ancestor::*[@class="items"]]')).third();
let fourth = element.all(by.css('.items li')).fourth();
let fifth = element.all(by.css('.items li')).fifth();
let sixth = element.all(by.css('.items li')).sixth();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "protractor-numerator",
"version": "0.5.0",
"version": "0.6.0",
"description": "Readable numeration for elements in Protractor tests",
"main": "index.js",
"scripts": {
"postinstall": "webdriver-manager update",
"start": "node test/server/server.test.js > stdout.txt 2> stderr.txt &",
"test": "node_modules/.bin/protractor test/conf.js"
},
"repository": {
Expand All @@ -29,6 +28,7 @@
},
"homepage": "https://github.com/Marketionist/protractor-numerator#readme",
"devDependencies": {
"node-testing-server": "^1.1.0",
"protractor": "^5.0.0"
}
}
4 changes: 3 additions & 1 deletion test/conf.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global numerator */

exports.config = {
directConnect: true,

Expand All @@ -8,7 +10,7 @@ exports.config = {
],

capabilities: {
'browserName': 'chrome'
browserName: 'chrome'
},

onPrepare: function () {
Expand Down
21 changes: 0 additions & 21 deletions test/server/public/test.html

This file was deleted.

53 changes: 0 additions & 53 deletions test/server/server.test.js

This file was deleted.

100 changes: 67 additions & 33 deletions test/spec.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,111 @@
'use strict';

let nodeTestingServer = require('node-testing-server').nodeTestingServer;

// Settings for node testing server
nodeTestingServer.config = {
hostname: 'localhost',
port: 8001,
logsEnabled: 0,
pages: {
'/test.html': `<ul class="items">
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
<li>Fifth</li>
<li>Sixth</li>
<li>Seventh</li>
<li>Eighth</li>
<li>Ninth</li>
<li>Tenth</li>
</ul>`
}
}

describe('protractor-numerator tests', function () {
let selectorLinkCSS = '.site-footer-links > li > a';
let selectorLinkXPath = '//a[ancestor::*[li[ancestor::*[contains(@class, "site-footer-links")]]]]';
// Selectors for tests
let selectorLinkCSS = '.items li';
let selectorLinkXPath = '//li[ancestor::*[@class="items"]]';

beforeAll(function () {
// Turn off Angular synchronization
browser.ignoreSynchronization = true;
// Output some information about current tests process
console.log(`==> Tests running at: ${process.cwd()}`);
console.log(`==> With argv: ${process.argv}`);

// Start node testing server
nodeTestingServer.start();
});

beforeEach(function () {
browser.get('https://github.com/');
browser.get(`http://${nodeTestingServer.config.hostname}:${nodeTestingServer.config.port}/test.html`);
});

afterAll(function () {
// Stop node testing server
nodeTestingServer.stop();
});

it('should get the first link from the Github main page footer', function () {
let linkFooterContactGitHub = element.all(by.css(selectorLinkCSS)).first();
it('should get the first list item from the test server page', function () {
let listItemFirst = element.all(by.css(selectorLinkCSS)).first();

expect(linkFooterContactGitHub.getText()).toBe('Contact GitHub');
expect(listItemFirst.getText()).toBe('First');
});

it('should get the second link from the Github main page footer', function () {
let linkFooterAPI = element.all(by.xpath(selectorLinkXPath)).second();
it('should get the second list item from the test server page', function () {
let listItemSecond = element.all(by.xpath(selectorLinkXPath)).second();

expect(linkFooterAPI.getText()).toBe('API');
expect(listItemSecond.getText()).toBe('Second');
});

it('should get the third link from the Github main page footer', function () {
let linkFooterTraining = element.all(by.css(selectorLinkCSS)).third();
it('should get the third list item from the test server page', function () {
let listItemThird = element.all(by.css(selectorLinkCSS)).third();

expect(linkFooterTraining.getText()).toBe('Training');
expect(listItemThird.getText()).toBe('Third');
});

it('should get the fourth link from the Github main page footer', function () {
let linkFooterShop = element.all(by.css(selectorLinkCSS)).fourth();
it('should get the fourth list item from the test server page', function () {
let listItemFourth = element.all(by.css(selectorLinkCSS)).fourth();

expect(linkFooterShop.getText()).toBe('Shop');
expect(listItemFourth.getText()).toBe('Fourth');
});

it('should get the fifth link from the Github main page footer', function () {
let linkFooterBlog = element.all(by.css(selectorLinkCSS)).fifth();
it('should get the fifth list item from the test server page', function () {
let listItemFifth = element.all(by.css(selectorLinkCSS)).fifth();

expect(linkFooterBlog.getText()).toBe('Blog');
expect(listItemFifth.getText()).toBe('Fifth');
});

it('should get the sixth link from the Github main page footer', function () {
let linkFooterAbout = element.all(by.css(selectorLinkCSS)).sixth();
it('should get the sixth list item from the test server page', function () {
let listItemSixth = element.all(by.css(selectorLinkCSS)).sixth();

expect(linkFooterAbout.getText()).toBe('About');
expect(listItemSixth.getText()).toBe('Sixth');
});

it('should get the seventh link from the Github main page footer', function () {
let linkFooterTerms = element.all(by.css(selectorLinkCSS)).seventh();
it('should get the seventh list item from the test server page', function () {
let listItemSeventh = element.all(by.css(selectorLinkCSS)).seventh();

expect(linkFooterTerms.getText()).toBe('Terms');
expect(listItemSeventh.getText()).toBe('Seventh');
});

it('should get the eighth link from the Github main page footer', function () {
let linkFooterPrivacy = element.all(by.css(selectorLinkCSS)).eighth();
it('should get the eighth list item from the test server page', function () {
let listItemEighth = element.all(by.css(selectorLinkCSS)).eighth();

expect(linkFooterPrivacy.getText()).toBe('Privacy');
expect(listItemEighth.getText()).toBe('Eighth');
});

it('should get the ninth link from the Github main page footer', function () {
let linkFooterSecurity = element.all(by.css(selectorLinkCSS)).ninth();
it('should get the ninth list item from the test server page', function () {
let listItemNinth = element.all(by.css(selectorLinkCSS)).ninth();

expect(linkFooterSecurity.getText()).toBe('Security');
expect(listItemNinth.getText()).toBe('Ninth');
});

it('should get the tenth link from the Github main page footer', function () {
let linkFooterStatus = element.all(by.css(selectorLinkCSS)).tenth();
it('should get the tenth list item from the test server page', function () {
let listItemTenth = element.all(by.css(selectorLinkCSS)).tenth();

expect(linkFooterStatus.getText()).toBe('Status');
expect(listItemTenth.getText()).toBe('Tenth');
});

});

0 comments on commit 8498d3a

Please sign in to comment.