Use driver pattern for e2e tests (#2)

* Initial commit

* Fix spec

* Move driver

* Fix config location

* Fix helper location

* More usage of driver

* Add click

* Fix click

* Migrate more tests

* Add setValue to driver

* Move more code to driver

* add isExisting to driver

* Change modal tests to use driver

* Fix tests

* Fix test

* Fix invalid alert wait

* Fix missing wd

* Fix tests

* Fix missing fs

* Fix test

* Fix path

* Move screenshort to driver

* Migrate keyboard

* Migrate skiplinks to driver

* Fix tests

* Try fix skip-links

* add config

* Add helper

* Fix driver?

* remove helper

* remove wd-helper

* Remove redundant file

* Remove webdriver extsions
This commit is contained in:
Harel M
2023-12-14 18:14:06 +02:00
committed by GitHub
parent b7838ad6e1
commit 73f7798a1d
15 changed files with 490 additions and 605 deletions

View File

@@ -1,6 +1,4 @@
var config = require("../../config/specs");
var helper = require("../helper");
var wd = require("../../wd-helper");
var driver = require("../driver");
// These will get used in the marketing material. They are also useful to do a quick manual check of the styling across browsers
@@ -8,104 +6,57 @@ var wd = require("../../wd-helper");
describe('screenshots', function() {
beforeEach(async function() {
await browser.setWindowSize(1280, 800)
await driver.setWindowSize(1280, 800)
})
it("front_page", async function() {
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example"
]));
await browser.acceptAlert();
const elem = await $(".maputnik-toolbar-link");
await elem.waitForExist();
await browser.flushReactUpdates();
await driver.setStyle(["geojson:example"]);
await browser.takeScreenShot("/front_page.png")
await driver.takeScreenShot("/front_page.png")
})
it("open", async function() {
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example"
]));
await browser.acceptAlert();
const elem = await $(".maputnik-toolbar-link");
await elem.waitForExist();
await browser.flushReactUpdates();
await driver.setStyle(["geojson:example"]);
await driver.click(driver.getDataAttribute("nav:open"));
await driver.zeroTimeout();
const nav_open = await $(wd.$("nav:open"));
await nav_open.click();
await nav_open.waitForExist();
await browser.flushReactUpdates();
await browser.takeScreenShot("/open.png")
await driver.takeScreenShot("/open.png")
})
it("export", async function() {
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example"
]));
await browser.acceptAlert();
const elem = await $(".maputnik-toolbar-link")
await elem.waitForExist()
await browser.flushReactUpdates();
await driver.setStyle(["geojson:example"]);
const nav_export = await $(wd.$("nav:export"));
await nav_export.click();
await nav_export.waitForExist();
await browser.flushReactUpdates();
await driver.click(driver.getDataAttribute("nav:export"));
await driver.zeroTimeout();
await browser.takeScreenShot("/export.png")
await driver.takeScreenShot("/export.png")
})
it("sources", async function() {
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example"
]));
await browser.acceptAlert();
const elem = await $(".maputnik-toolbar-link")
await elem.waitForExist()
await browser.flushReactUpdates();
await driver.setStyle(["geojson:example"]);
const nav_sources = await $(wd.$("nav:sources"));
await nav_sources.click();
await nav_sources.waitForExist();
await browser.flushReactUpdates();
await driver.click(driver.getDataAttribute("nav:sources"));
await driver.zeroTimeout();
await browser.takeScreenShot("/sources.png")
await driver.takeScreenShot("/sources.png")
})
it("style settings", async function() {
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example"
]));
await browser.acceptAlert();
const elem = await $(".maputnik-toolbar-link")
await elem.waitForExist()
await browser.flushReactUpdates();
await driver.setStyle(["geojson:example"]);
const nav_settings = await $(wd.$("nav:settings"));
await nav_settings.click();
await nav_settings.waitForExist();
await browser.flushReactUpdates();
await driver.click(driver.getDataAttribute("nav:settings"));
await driver.zeroTimeout();
await browser.takeScreenShot("/settings.png")
await driver.takeScreenShot("/settings.png")
})
it("inspect", async function() {
await browser.url(config.baseUrl+"?debug&style="+helper.getStyleUrl([
"geojson:example"
]));
await browser.acceptAlert();
const elem = await $(".maputnik-toolbar-link")
await elem.waitForExist()
await browser.flushReactUpdates();
await driver.setStyle(["geojson:example"]);
const selectBox = await $(wd.$("nav:inspect", "select"));
await selectBox.selectByAttribute('value', 'inspect');
await driver.selectFromDropdown(driver.getDataAttribute("nav:inspect", "select"), 'inspect');
await driver.zeroTimeout();
await browser.flushReactUpdates();
await browser.takeScreenShot("/inspect.png")
await driver.takeScreenShot("/inspect.png")
})
})