auto: 2026-08-29 16:28 (EOMSANGDON-HOME)
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
{
|
||||
"title": "record eraser 2",
|
||||
"selectorAttribute": "data-id",
|
||||
"steps": [
|
||||
{
|
||||
"type": "setViewport",
|
||||
"width": 1278,
|
||||
"height": 1430,
|
||||
"deviceScaleFactor": 1,
|
||||
"isMobile": false,
|
||||
"hasTouch": false,
|
||||
"isLandscape": false
|
||||
},
|
||||
{
|
||||
"type": "navigate",
|
||||
"url": "http://localhost:5173/",
|
||||
"assertedEvents": [
|
||||
{
|
||||
"type": "navigation",
|
||||
"url": "http://localhost:5173/",
|
||||
"title": "Open WebCAD"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "click",
|
||||
"target": "main",
|
||||
"selectors": [
|
||||
["[data-id='canvas']"],
|
||||
["xpath///*[@data-id=\"canvas\"]"],
|
||||
["pierce/[data-id='canvas']"]
|
||||
],
|
||||
"offsetY": 148,
|
||||
"offsetX": 473
|
||||
},
|
||||
{
|
||||
"type": "click",
|
||||
"target": "main",
|
||||
"selectors": [
|
||||
["[data-id='canvas']"],
|
||||
["xpath///*[@data-id=\"canvas\"]"],
|
||||
["pierce/[data-id='canvas']"]
|
||||
],
|
||||
"offsetY": 698,
|
||||
"offsetX": 473
|
||||
},
|
||||
{
|
||||
"type": "keyDown",
|
||||
"target": "main",
|
||||
"key": "c"
|
||||
},
|
||||
{
|
||||
"type": "keyUp",
|
||||
"key": "c",
|
||||
"target": "main"
|
||||
},
|
||||
{
|
||||
"type": "keyDown",
|
||||
"target": "main",
|
||||
"key": "i"
|
||||
},
|
||||
{
|
||||
"type": "keyUp",
|
||||
"key": "i",
|
||||
"target": "main"
|
||||
},
|
||||
{
|
||||
"type": "keyDown",
|
||||
"target": "main",
|
||||
"key": "r"
|
||||
},
|
||||
{
|
||||
"type": "keyUp",
|
||||
"key": "r",
|
||||
"target": "main"
|
||||
},
|
||||
{
|
||||
"type": "keyDown",
|
||||
"target": "main",
|
||||
"key": "c"
|
||||
},
|
||||
{
|
||||
"type": "keyUp",
|
||||
"key": "c",
|
||||
"target": "main"
|
||||
},
|
||||
{
|
||||
"type": "keyDown",
|
||||
"target": "main",
|
||||
"key": "l"
|
||||
},
|
||||
{
|
||||
"type": "keyUp",
|
||||
"key": "l",
|
||||
"target": "main"
|
||||
},
|
||||
{
|
||||
"type": "keyDown",
|
||||
"target": "main",
|
||||
"key": "e"
|
||||
},
|
||||
{
|
||||
"type": "keyUp",
|
||||
"key": "e",
|
||||
"target": "main"
|
||||
},
|
||||
{
|
||||
"type": "keyDown",
|
||||
"target": "main",
|
||||
"key": "Enter"
|
||||
},
|
||||
{
|
||||
"type": "keyUp",
|
||||
"key": "Enter",
|
||||
"target": "main"
|
||||
},
|
||||
{
|
||||
"type": "click",
|
||||
"target": "main",
|
||||
"selectors": [
|
||||
["[data-id='canvas']"],
|
||||
["xpath///*[@data-id=\"canvas\"]"],
|
||||
["pierce/[data-id='canvas']"]
|
||||
],
|
||||
"offsetY": 402,
|
||||
"offsetX": 266
|
||||
},
|
||||
{
|
||||
"type": "click",
|
||||
"target": "main",
|
||||
"selectors": [
|
||||
["[data-id='canvas']"],
|
||||
["xpath///*[@data-id=\"canvas\"]"],
|
||||
["pierce/[data-id='canvas']"]
|
||||
],
|
||||
"offsetY": 441,
|
||||
"offsetX": 542
|
||||
},
|
||||
{
|
||||
"type": "click",
|
||||
"target": "main",
|
||||
"selectors": [
|
||||
["[data-id='delete-segment-button'] path"],
|
||||
["xpath///*[@data-id=\"delete-segment-button\"]/div/svg/path"],
|
||||
["pierce/[data-id='delete-segment-button'] path"],
|
||||
["aria/Delete segments", "aria/[role=\"graphics-symbol\"]"]
|
||||
],
|
||||
"offsetY": 15,
|
||||
"offsetX": 9
|
||||
},
|
||||
{
|
||||
"type": "click",
|
||||
"target": "main",
|
||||
"selectors": [
|
||||
["[data-id='canvas']"],
|
||||
["xpath///*[@data-id=\"canvas\"]"],
|
||||
["pierce/[data-id='canvas']"]
|
||||
],
|
||||
"offsetY": 291,
|
||||
"offsetX": 524
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import {Point} from '@flatten-js/core'; /* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {expect, test} from 'vitest';
|
||||
import type {ArcJsonData} from '../../../src/entities/ArcEntity';
|
||||
import {EntityName, type JsonEntity} from '../../../src/entities/Entity';
|
||||
import type {LineJsonData} from '../../../src/entities/LineEntity';
|
||||
import {pointDistance} from '../../../src/helpers/distance-between-points';
|
||||
import {getEntities} from '../../../src/state';
|
||||
import {initApplication} from '../../helpers/init-application';
|
||||
import {replayRecording} from '../../helpers/replay-recording';
|
||||
import {CANVAS_HEIGHT} from "../../helpers/tests.consts";
|
||||
import eraserRecording from './eraser.recording.json';
|
||||
|
||||
test('Draw circle and line and erase part of circle', async () => {
|
||||
const inputController = initApplication();
|
||||
|
||||
replayRecording(inputController, eraserRecording);
|
||||
|
||||
const entities = getEntities();
|
||||
|
||||
expect(entities).toHaveLength(2);
|
||||
|
||||
const lineEntity = entities[0];
|
||||
expect(lineEntity.getType()).toBe(EntityName.Line);
|
||||
const lineJson = (await lineEntity.toJson()) as JsonEntity<LineJsonData>;
|
||||
|
||||
expect(lineJson.lineColor).toBe('#fff');
|
||||
expect(lineJson.lineWidth).toBe(1);
|
||||
expect(lineJson.type).toBe('Line');
|
||||
expect(lineJson.shapeData.startPoint.x).toBe(473);
|
||||
expect(lineJson.shapeData.startPoint.y).toBe(CANVAS_HEIGHT - 148);
|
||||
expect(lineJson.shapeData.endPoint.x).toBe(473);
|
||||
expect(lineJson.shapeData.endPoint.y).toBe(CANVAS_HEIGHT - 698);
|
||||
|
||||
const arcEntity = entities[1];
|
||||
expect(arcEntity.getType()).toBe(EntityName.Arc);
|
||||
const arcJson = (await arcEntity.toJson()) as JsonEntity<ArcJsonData>;
|
||||
|
||||
expect(arcJson.lineColor).toBe('#fff');
|
||||
expect(arcJson.lineWidth).toBe(1);
|
||||
expect(arcJson.type).toBe('Arc');
|
||||
expect(arcJson.shapeData.center.x).toBe(266);
|
||||
expect(arcJson.shapeData.center.y).toBe(CANVAS_HEIGHT - 402);
|
||||
const radius = pointDistance(
|
||||
new Point(266, CANVAS_HEIGHT - 402),
|
||||
new Point(542, CANVAS_HEIGHT - 441)
|
||||
);
|
||||
expect(arcJson.shapeData.radius).toBeCloseTo(radius, 5);
|
||||
expect(arcJson.shapeData.startAngle).toBeCloseTo(0.7338182524767606, 5);
|
||||
expect(arcJson.shapeData.endAngle).toBeCloseTo(-0.7338182524767606, 5);
|
||||
});
|
||||
Reference in New Issue
Block a user