Use driver pattern for e2e tests (#829)

I've moved all the logic relevant to WBIO into a single file in order to
be able to replace it.
I have tried to upgrade WDIO in order to use the latest version and it
got stuck on my computer.
Furthermore, I was not able to run it locally which made this whole
cycle very long.
After this will be merged I will replace WDIO with cypress.
This doesn't change anything, only moves some code in the tests to a
single file, removes unneeded files and uses the driver pattern, which
will later allow switching the underline WDIO with Cypress.

cc: @nyurik
This commit is contained in:
Harel M
2023-12-17 08:14:23 +02:00
committed by GitHub
parent 31d56c9fae
commit 18f45e932b
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")
})
})