diff --git a/package.json b/package.json index 86058be..d2a510b 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,11 @@ "author": "Sergey Zhigalov ", "license": "MIT", "devDependencies": { - "wdio-mocha-framework": "0.5.10", - "wdio-sauce-service": "0.4.0", - "wdio-spec-reporter": "0.1.0", - "webdriverio": "4.8.0" + "selenium-standalone": "^6.4.1", + "wdio-mocha-framework": "^0.5.10", + "wdio-sauce-service": "^0.4.0", + "wdio-spec-reporter": "^0.1.0", + "webdriverio": "^4.8.0", + "moment": "^2.18.1" } } diff --git a/tests/mongomart-test.js b/tests/mongomart-test.js index b2dccbc..25da231 100644 --- a/tests/mongomart-test.js +++ b/tests/mongomart-test.js @@ -1,5 +1,48 @@ -describe('Mongomart', () => { - it('should ...', () => { - browser.url('http://urfu-2016-testing.herokuapp.com/'); +const assert = require("assert"); +const moment = require("moment"); + +describe("Mongomart", () => { + describe('Product search', () => { + before(() => { + browser + .url('/'); + }); + + it('should show 0 product for ""', () => { + browser + .setValue("input[name='query']", "") + .click('button[type="submit"]'); + assert.equal(browser.getText('i'), '0 Products'); + + }); }); -}); + + describe('Comments', () => { + + it('should have right datetime format', () => { + browser + .url('/item/12') + .click(`input[value="5"]`) + .click('form:nth-child(2) button[type="submit"]'); + let allComments = browser.getText('div.col-lg-12>div'); + const date = browser.getText('.media-heading small')[allComments.length - 1]; + + assert(moment(date, 'MMMM Do YYYY, h:m:s a').isValid()); + }); + }); + + describe('Bread crumbs', () => { + + it('should show right bread crumbs for "Leaf Sticker"', () => { + browser + .url('/') + .click('a[href="/?category=Stickers"]') + .click('a[href="/item/12"'); + + let crumbs = browser.getText('ol li'); + assert.equal(crumbs[0], 'Home'); + assert.equal(crumbs[1], 'Stickers'); + assert.equal(crumbs[2], 'Leaf Sticker'); + }); + }); +}); \ No newline at end of file diff --git a/wdio.conf.js b/wdio.conf.js new file mode 100644 index 0000000..bd73b16 --- /dev/null +++ b/wdio.conf.js @@ -0,0 +1,62 @@ +exports.config = { + + // + // ================= + // Service Providers + // ================= + // WebdriverIO supports Sauce Labs, Browserstack, and Testing Bot (other cloud providers + // should work too though). These services define specific user and key (or access key) + // values you need to put in here in order to connect to these services. + // + user: "georgy", + key: "2d20cd62-cd70-4418-9d23-5e112520341c", + + specs: [ + './tests/*.js' + ], + + exclude: [ + ], + + maxInstances: 10, + + capabilities: [ + { + browserName: 'firefox', + name: 'firefox mongomart tests' + }, + { + browserName: 'chrome', + name: 'chrome mongomart tests' + }], + + sync: true, + + logLevel: 'command', + + coloredLogs: true, + + bail: 0, + + screenshotPath: './errorShots/', + + baseUrl: 'http://urfu-2016-testing.herokuapp.com', + + waitforTimeout: 10000, + + connectionRetryTimeout: 90000, + + connectionRetryCount: 3, + + services: ['sauce'], + + framework: 'mocha', + + reporters: ['spec'], + + + mochaOpts: { + ui: 'bdd', + timeout: 30000 + } +}