Skip to content

Commit

Permalink
test: add step definitions for reset-clone-undo-redo
Browse files Browse the repository at this point in the history
  • Loading branch information
timurbazhirov committed Aug 10, 2022
1 parent 154d274 commit 8becff1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path from "path";

import {parseTable} from "../utils/table";
import {readFileSync} from "../utils/file";
import {retry, shallowDeepAlmostEqual} from "../utils";

export default function () {
this.Then(/^material with following data does not exist in state$/, function (table) {
const config = parseTable(table, this)[0];
const material = JSON.parse(readFileSync(path.resolve(__dirname, "../../fixtures", config.path)));
retry(() => {
const materials = exabrowser.execute(() => {
return window.MDContainer.store.getState().present.materials.map(m => m.toJSON());
}).value;
shallowDeepAlmostEqual(undefined, materials[config.index - 1]);
}, {retries: 5});
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {materialDesignerPage} from "../widgets/material_designer_page";

export default function () {
this.Then(/^I select "([^"]*)" option from the Edit menu$/, function (actionString) {
const map = {"undo": 1, "redo": 2, "reset": 3};
const index = map[actionString];
if (!index) throw new Error("I click # action from the Edit menu - index is undefined");
materialDesignerPage.designerWidget.clickUndoRedoReset(index);
});
};
2 changes: 2 additions & 0 deletions tests/cucumber/support/widgets/material_designer_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export class MaterialDesignerWidget extends Widget {

cloneCurrentMaterial() {this.headerMenu.selectMenuItemByNameAndItemNumber("Edit", 4)};

clickUndoRedoReset(index = 1) {this.headerMenu.selectMenuItemByNameAndItemNumber("Edit", index)};

openSurfaceDialog() {this.headerMenu.selectMenuItemByNameAndItemNumber("Advanced", 4)}

createSurface(config) {
Expand Down

0 comments on commit 8becff1

Please sign in to comment.