Skip to content

Commit

Permalink
Refactoring visual tests: hide adorner actions (#6229)
Browse files Browse the repository at this point in the history
* Refactoring visual tests: hide adorner actions

* Refactoring visual tests: hide adorner actions

---------

Co-authored-by: OlgaLarina <[email protected]>
  • Loading branch information
OlgaLarina and OlgaLarina authored Dec 12, 2024
1 parent 48e7402 commit 6282c8d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
12 changes: 11 additions & 1 deletion functionalTests/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,14 @@ export function getDropdownValue(selector: string | Selector = ".sd-input.sd-dro

export async function resetHoverToCreator(t: TestController): Promise<void> {
await t.hover(Selector("#survey-creator"), { offsetX: 0, offsetY: 0 });
}
}

export const hideAllAdornerActions = ClientFunction(() => {
(<any>window).creator.onElementAllowOperations.add((_, options) => {
Object.keys(options).forEach(key => {
if (key !== "allowDragging" && key !== "allowEdit") {
options[key] = false;
}
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion visualRegressionTests/tests/designer/drag-drop.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Selector, ClientFunction } from "testcafe";
import { url, setJSON, takeElementScreenshot, explicitErrorHandler, getPropertyGridCategory, changeToolboxScrolling, patchDragDropToDisableDrop, wrapVisualTest, resetHoverToCreator, getPagesLength, RatingToolboxItem, setShowAddQuestionButton, setAllowEditSurveyTitle } from "../../helper";
import { url, setJSON, takeElementScreenshot, explicitErrorHandler, getPropertyGridCategory, changeToolboxScrolling, patchDragDropToDisableDrop, wrapVisualTest, resetHoverToCreator, getPagesLength, RatingToolboxItem, setShowAddQuestionButton, setAllowEditSurveyTitle, hideAllAdornerActions } from "../../helper";

const title = "DragDrop Screenshot";

Expand All @@ -8,6 +8,7 @@ fixture`${title}`.page`${url}`.beforeEach(async (t) => {

test("Ghost Survey Element", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await setJSON({ pages: [{ name: "page1" }] });
await t.resizeWindow(2560, 1440);
await setJSON({ pages: [{ name: "page1" }] });
Expand All @@ -31,6 +32,7 @@ test("Ghost Survey Element", async (t) => {

test("Empty page", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await setJSON({ pages: [{ name: "page1" }] });
await t.resizeWindow(2560, 1440);
await setJSON({ pages: [{ name: "page1" }] });
Expand All @@ -54,6 +56,7 @@ test("Empty page", async (t) => {

test("Ghost Survey Element after several drops", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await setJSON({ pages: [{ name: "page1" }] });
await t.resizeWindow(2560, 1440);
await setJSON({ pages: [{ name: "page1" }] });
Expand Down Expand Up @@ -99,6 +102,7 @@ test("Ghost Survey Element after several drops", async (t) => {

test("Toolbox Item State After Drag", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await setJSON({ pages: [{ name: "page1" }] });
await t.resizeWindow(2560, 1440);
await setJSON({ pages: [{ name: "page1" }] });
Expand All @@ -116,6 +120,7 @@ test("Toolbox Item State After Drag", async (t) => {

test("Empty Panel Styles", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(2560, 1440);

const json = {
Expand Down Expand Up @@ -147,6 +152,7 @@ test("Empty Panel Styles", async (t) => {

test("Empty Panel Dynamic Styles", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(2560, 1440);

const json = {
Expand Down Expand Up @@ -177,6 +183,7 @@ test("Empty Panel Dynamic Styles", async (t) => {

test("Choices: Ranking", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(2560, 1440);

const json = {
Expand Down Expand Up @@ -214,6 +221,7 @@ test("Choices: Ranking", async (t) => {

test("Choices: Mobile", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(390, 844);

const json = {
Expand Down Expand Up @@ -241,6 +249,7 @@ test("Choices: Mobile", async (t) => {
});

test("Choices: Ranking: Mobile", async (t) => {
await hideAllAdornerActions();
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(390, 844);

Expand Down Expand Up @@ -270,6 +279,7 @@ test("Choices: Ranking: Mobile", async (t) => {

test("Choices: DropDown: Mobile", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(390, 844);

const json = {
Expand Down Expand Up @@ -298,6 +308,7 @@ test("Choices: DropDown: Mobile", async (t) => {

test("Matrix: Property Grid: Choices", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(2560, 1440);

const patchMatrixDragDropToDisableDrop = ClientFunction(() => {
Expand Down Expand Up @@ -403,6 +414,7 @@ test("Matrix: Property Grid: Choices: Scroll", async (t) => {
test("Drag Drop ImagePicker (choices) drop to invalid area", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await explicitErrorHandler();
await hideAllAdornerActions();
await t.resizeWindow(2560, 1440);

const json = {
Expand Down Expand Up @@ -457,6 +469,7 @@ test("Drag Drop ImagePicker (choices) drop to invalid area", async (t) => {
// https://github.com/surveyjs/survey-creator/issues/3234
test("Drag Drop to Multiline from Toolbox", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
changeToolboxScrolling(false);
await explicitErrorHandler();
await t.resizeWindow(2584, 1440);
Expand Down Expand Up @@ -500,6 +513,7 @@ test("Drag Drop to Multiline from Toolbox", async (t) => {

test("Drag Drop to Multiline styles", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await explicitErrorHandler();
await t.resizeWindow(832, 600);
await setShowAddQuestionButton(false);
Expand Down Expand Up @@ -558,6 +572,7 @@ test("Drag Drop to Multiline styles", async (t) => {

test("Drag Drop inside panel dynamic top indicator", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await explicitErrorHandler();
await t.resizeWindow(832, 600);

Expand Down Expand Up @@ -605,6 +620,7 @@ test("Drag Drop inside panel dynamic top indicator", async (t) => {

test("Toolbox Custom Component Icon", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(2560, 1440);

const changeIconRatingForToolbox = ClientFunction((iconName) => {
Expand Down Expand Up @@ -644,6 +660,7 @@ test("Toolbox Custom Component Icon", async (t) => {

test("Drag Drop (choices): scroll", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(1000, 500);

const json = {
Expand Down Expand Up @@ -802,6 +819,7 @@ test("Drag indicator for custom widget", async (t) => {
`;
document.body.appendChild(widgetTemplateForKo);
})();
await hideAllAdornerActions();
await t.resizeWindow(1252, 900);
await setShowAddQuestionButton(false);

Expand All @@ -823,6 +841,7 @@ test("Drag indicator for custom widget", async (t) => {

test("Drag Drop Indicator: Inside Panel: Rows", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await hideAllAdornerActions();
await t.resizeWindow(1000, 500);

const json = {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6282c8d

Please sign in to comment.