Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
- Loading branch information
Showing
6 changed files
with
99 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import ExcalidrawApp from "../excalidraw-app"; | ||
import { t } from "../i18n"; | ||
import { CODES } from "../keys"; | ||
import { API } from "../tests/helpers/api"; | ||
import { Keyboard, Pointer, UI } from "../tests/helpers/ui"; | ||
import { fireEvent, render, screen } from "../tests/test-utils"; | ||
import { copiedStyles } from "./actionStyles"; | ||
|
||
const { h } = window; | ||
|
||
const mouse = new Pointer("mouse"); | ||
|
||
describe("actionStyles", () => { | ||
beforeEach(async () => { | ||
await render(<ExcalidrawApp />); | ||
}); | ||
it("should copy & paste styles via keyboard", () => { | ||
UI.clickTool("rectangle"); | ||
mouse.down(10, 10); | ||
mouse.up(20, 20); | ||
|
||
UI.clickTool("rectangle"); | ||
mouse.down(10, 10); | ||
mouse.up(20, 20); | ||
|
||
// Change some styles of second rectangle | ||
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 | ||
fireEvent.click(screen.getByTitle("Bold")); | ||
// Stroke style | ||
fireEvent.click(screen.getByTitle("Dotted")); | ||
// Roughness | ||
fireEvent.click(screen.getByTitle("Cartoonist")); | ||
// Opacity | ||
fireEvent.change(screen.getByLabelText("Opacity"), { | ||
target: { value: "60" }, | ||
}); | ||
|
||
mouse.reset(); | ||
|
||
API.setSelectedElements([h.elements[1]]); | ||
|
||
Keyboard.withModifierKeys({ ctrl: true, alt: true }, () => { | ||
Keyboard.codeDown(CODES.C); | ||
}); | ||
const secondRect = JSON.parse(copiedStyles); | ||
expect(secondRect.id).toBe(h.elements[1].id); | ||
|
||
mouse.reset(); | ||
// Paste styles to first rectangle | ||
API.setSelectedElements([h.elements[0]]); | ||
Keyboard.withModifierKeys({ ctrl: true, alt: true }, () => { | ||
Keyboard.codeDown(CODES.V); | ||
}); | ||
|
||
const firstRect = API.getSelectedElement(); | ||
expect(firstRect.id).toBe(h.elements[0].id); | ||
expect(firstRect.strokeColor).toBe("#c92a2a"); | ||
expect(firstRect.backgroundColor).toBe("#e64980"); | ||
expect(firstRect.fillStyle).toBe("cross-hatch"); | ||
expect(firstRect.strokeWidth).toBe(2); // Bold: 2 | ||
expect(firstRect.strokeStyle).toBe("dotted"); | ||
expect(firstRect.roughness).toBe(2); // Cartoonist: 2 | ||
expect(firstRect.opacity).toBe(60); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20de06e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
excalidraw-package-example – ./src/packages/excalidraw
excalidraw-package-example.vercel.app
excalidraw-package-example-git-master-excalidraw.vercel.app
excalidraw-package-example-excalidraw.vercel.app
20de06e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
excalidraw – ./
excalidraw-git-master-excalidraw.vercel.app
excalidraw.com
excalidraw-excalidraw.vercel.app
fonts.excalidraw.com
www.excalidraw.com