From f490e6a0c39421a8803c8fe66708202fcd47ff48 Mon Sep 17 00:00:00 2001 From: woothu <32914662+woothu@users.noreply.github.com> Date: Sat, 10 Aug 2019 13:48:04 +0200 Subject: [PATCH] test: update e2e tests --- tests/e2e/custom-assertions/elementCount.js | 19 ---- tests/e2e/specs/test.js | 96 ++++----------------- 2 files changed, 19 insertions(+), 96 deletions(-) delete mode 100644 tests/e2e/custom-assertions/elementCount.js diff --git a/tests/e2e/custom-assertions/elementCount.js b/tests/e2e/custom-assertions/elementCount.js deleted file mode 100644 index 52883038..00000000 --- a/tests/e2e/custom-assertions/elementCount.js +++ /dev/null @@ -1,19 +0,0 @@ -// A custom Nightwatch assertion. -// The assertion name is the filename. -// Example usage: -// -// browser.assert.elementCount(selector, count) -// -// For more information on custom assertions see: -// http://nightwatchjs.org/guide#writing-custom-assertions - -exports.assertion = function elementCount (selector, count) { - this.message = `Testing if element <${selector}> has count: ${count}` - this.expected = count - this.pass = val => val === count - this.value = res => res.value - function evaluator (_selector) { - return document.querySelectorAll(_selector).length - } - this.command = cb => this.api.execute(evaluator, [selector], cb) -} diff --git a/tests/e2e/specs/test.js b/tests/e2e/specs/test.js index 198b1ab3..1e1b3f15 100644 --- a/tests/e2e/specs/test.js +++ b/tests/e2e/specs/test.js @@ -22,83 +22,25 @@ module.exports = { browser.url(devServer).pause(500).expect.element('body').to.be.present - // browser.waitForElementVisible('.app', 10000) - // .assert.elementPresent('.app-header') - // .assert.elementPresent('.app-header > .navbar-brand') - // .assert.elementPresent('.app-body') - // .assert.elementPresent('.app-body > .main > .breadcrumb') - // .assert.elementPresent('.app-body > .main > .container-fluid > .animated') - // .assert.elementPresent('.app-body > .sidebar > .sidebar-nav') - // .assert.elementPresent('.app-body > .sidebar > .sidebar-minimizer') - // .assert.elementPresent('.app-footer') - // .assert.containsText('.app-footer > div > span', 'creativeLabs') - // .assert.containsText('.app-footer > div.ml-auto > span', 'Powered by') - // .assert.elementCount('button', 10) - // .resizeWindow(1024, 800) - // .pause(500) - - // browser.click('body > div > header > button.d-none.d-lg-block.navbar-toggler', function (response) { - // console.log('response', typeof response) - // this.assert.ok(browser === this, 'Check if the context is right.') - // this.assert.cssClassPresent('body', 'aside-menu-show') - // }) - // - // browser.pause(500) - - // browser.click('body > div > header > button.d-none.d-lg-block.navbar-toggler', function (response) { - // console.log('response', typeof response) - // this.assert.cssClassNotPresent('body', 'aside-menu-show') - // }) - // - // browser.pause(500) - // - // browser - // .useXpath() - // .click('/html/body/div/header/button[2]', function (response) { - // console.log('response', typeof response) - // this.assert.cssClassNotPresent('/html/body', 'sidebar-lg-show') - // }) - // - // browser - // .pause(500) - // .click('/html/body/div/header/button[2]', function (response) { - // console.log('response', typeof response) - // this.assert.cssClassPresent('/html/body', 'sidebar-lg-show') - // }) - // - // browser - // .pause(500) - // .click('/html/body/div/div/div/button', function (response) { - // console.log('response', typeof response) - // this.assert.cssClassPresent('/html/body', 'sidebar-minimized') - // this.assert.cssClassPresent('/html/body', 'brand-minimized') - // }) - // .pause(500) - // .click('/html/body/div/div/div/button', function (response) { - // console.log('response', typeof response) - // this.assert.cssClassNotPresent('/html/body', 'sidebar-minimized') - // this.assert.cssClassNotPresent('/html/body', 'brand-minimized') - // }) - // - // browser - // .resizeWindow(800, 600) - // .pause(500) - // - // browser - // .pause(500) - // .click('/html/body/div/header/button[1]', function (response) { - // console.log('response', typeof response) - // this.assert.cssClassPresent('/html/body', 'sidebar-show') - // }) - // - // browser - // .pause(500) - // .click('/html/body/div/div/div/nav/section/ul/li[1]/div/a', function (response) { - // console.log('response', typeof response) - // this.assert.cssClassNotPresent('/html/body', 'sidebar-show') - // }) - // - // browser.pause(5000) + browser.waitForElementVisible('.c-app', 2000) + .assert.elementPresent('.c-header') + .assert.elementPresent('.c-sidebar') + .assert.elementPresent('.c-footer') + .assert.elementPresent('.c-sidebar') + .assert.elementPresent('.c-body') + + browser.resizeWindow(700, 800) + browser.expect.element('.c-sidebar').to.have.css('margin-left').which.equals('-250px') + browser.resizeWindow(1900, 800) + browser.expect.element('.c-sidebar').to.have.css('margin-left').which.equals('0px') + browser.pause(1500) + browser.click('.c-sidebar-minimizer') + browser.pause(1000) + browser.expect.element('.c-sidebar').to.have.css('width').which.equals('50px') + browser.click('button.c-header-toggler.c-d-md-down-none') + browser.pause(1000) + browser.expect.element('.c-sidebar').to.have.css('margin-left').which.equals('-250px') + browser.pause(1000) browser.end() }