mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: paste styles shortcut (#4886)
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
parent
1849ff6ee2
commit
20de06ef50
6 changed files with 99 additions and 31 deletions
|
@ -40,14 +40,6 @@ const queryContextMenu = () => {
|
|||
return GlobalTestState.renderResult.container.querySelector(".context-menu");
|
||||
};
|
||||
|
||||
const clickLabeledElement = (label: string) => {
|
||||
const element = document.querySelector(`[aria-label='${label}']`);
|
||||
if (!element) {
|
||||
throw new Error(`No labeled element found: ${label}`);
|
||||
}
|
||||
fireEvent.click(element);
|
||||
};
|
||||
|
||||
// Unmount ReactDOM from root
|
||||
ReactDOM.unmountComponentAtNode(document.getElementById("root")!);
|
||||
|
||||
|
@ -312,10 +304,10 @@ describe("contextMenu element", () => {
|
|||
mouse.up(20, 20);
|
||||
|
||||
// Change some styles of second rectangle
|
||||
clickLabeledElement("Stroke");
|
||||
clickLabeledElement(t("colors.c92a2a"));
|
||||
clickLabeledElement("Background");
|
||||
clickLabeledElement(t("colors.e64980"));
|
||||
UI.clickLabeledElement("Stroke");
|
||||
UI.clickLabeledElement(t("colors.c92a2a"));
|
||||
UI.clickLabeledElement("Background");
|
||||
UI.clickLabeledElement(t("colors.e64980"));
|
||||
// Fill style
|
||||
fireEvent.click(screen.getByTitle("Cross-hatch"));
|
||||
// Stroke width
|
||||
|
|
|
@ -221,6 +221,14 @@ export class UI {
|
|||
fireEvent.click(GlobalTestState.renderResult.getByToolName(toolName));
|
||||
};
|
||||
|
||||
static clickLabeledElement = (label: string) => {
|
||||
const element = document.querySelector(`[aria-label='${label}']`);
|
||||
if (!element) {
|
||||
throw new Error(`No labeled element found: ${label}`);
|
||||
}
|
||||
fireEvent.click(element);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an Excalidraw element, and returns a proxy that wraps it so that
|
||||
* accessing props will return the latest ones from the object existing in
|
||||
|
|
|
@ -26,14 +26,6 @@ const mouse = new Pointer("mouse");
|
|||
const finger1 = new Pointer("touch", 1);
|
||||
const finger2 = new Pointer("touch", 2);
|
||||
|
||||
const clickLabeledElement = (label: string) => {
|
||||
const element = document.querySelector(`[aria-label='${label}']`);
|
||||
if (!element) {
|
||||
throw new Error(`No labeled element found: ${label}`);
|
||||
}
|
||||
fireEvent.click(element);
|
||||
};
|
||||
|
||||
/**
|
||||
* This is always called at the end of your test, so usually you don't need to call it.
|
||||
* However, if you have a long test, you might want to call it during the test so it's easier
|
||||
|
@ -168,10 +160,10 @@ describe("regression tests", () => {
|
|||
mouse.down(10, 10);
|
||||
mouse.up(10, 10);
|
||||
|
||||
clickLabeledElement("Background");
|
||||
clickLabeledElement(t("colors.fa5252"));
|
||||
clickLabeledElement("Stroke");
|
||||
clickLabeledElement(t("colors.5f3dc4"));
|
||||
UI.clickLabeledElement("Background");
|
||||
UI.clickLabeledElement(t("colors.fa5252"));
|
||||
UI.clickLabeledElement("Stroke");
|
||||
UI.clickLabeledElement(t("colors.5f3dc4"));
|
||||
expect(API.getSelectedElement().backgroundColor).toBe("#fa5252");
|
||||
expect(API.getSelectedElement().strokeColor).toBe("#5f3dc4");
|
||||
});
|
||||
|
@ -952,8 +944,8 @@ describe("regression tests", () => {
|
|||
UI.clickTool("rectangle");
|
||||
// change background color since default is transparent
|
||||
// and transparent elements can't be selected by clicking inside of them
|
||||
clickLabeledElement("Background");
|
||||
clickLabeledElement(t("colors.fa5252"));
|
||||
UI.clickLabeledElement("Background");
|
||||
UI.clickLabeledElement(t("colors.fa5252"));
|
||||
mouse.down();
|
||||
mouse.up(1000, 1000);
|
||||
|
||||
|
@ -1059,8 +1051,8 @@ describe("regression tests", () => {
|
|||
mouse.up(10, 10);
|
||||
expect(screen.queryByText(/fill/i)).toBeNull();
|
||||
|
||||
clickLabeledElement("Background");
|
||||
clickLabeledElement(t("colors.fa5252"));
|
||||
UI.clickLabeledElement("Background");
|
||||
UI.clickLabeledElement(t("colors.fa5252"));
|
||||
// select rectangle
|
||||
mouse.reset();
|
||||
mouse.click();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue