diff --git a/excalidraw-app/tests/test-utils.ts b/excalidraw-app/tests/test-utils.ts new file mode 100644 index 000000000..0dbf4d9ec --- /dev/null +++ b/excalidraw-app/tests/test-utils.ts @@ -0,0 +1,17 @@ +import { ImportedDataState } from "../../packages/excalidraw/data/types"; +import { STORAGE_KEYS } from "../app_constants"; + +export const initLocalStorage = (data: ImportedDataState) => { + if (data.elements) { + localStorage.setItem( + STORAGE_KEYS.LOCAL_STORAGE_ELEMENTS, + JSON.stringify(data.elements), + ); + } + if (data.appState) { + localStorage.setItem( + STORAGE_KEYS.LOCAL_STORAGE_APP_STATE, + JSON.stringify(data.appState), + ); + } +}; diff --git a/package.json b/package.json index bb31e4522..95ec40cc9 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "build:app": "cross-env VITE_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA vite build", "build:version": "node ./scripts/build-version.js", "build": "yarn workspace @excalidraw/utils build:esm && yarn --cwd ./excalidraw-app build", + "clear:workspaces": "yarn workspace @excalidraw/utils run clear && yarn workspace @excalidraw/excalidraw run clear", "fix:code": "yarn test:code --fix", "fix:other": "yarn prettier --write", "fix": "yarn fix:other && yarn fix:code", @@ -71,7 +72,7 @@ "locales-coverage:description": "node scripts/locales-coverage-description.js", "prepare": "husky install", "prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore", - "start": "yarn workspace @excalidraw/utils build:esm && yarn --cwd ./excalidraw-app start", + "start": "yarn workspace @excalidraw/utils run build:esm && yarn --cwd ./excalidraw-app start", "start:app:production": "npm run build && npx http-server build -a localhost -p 5001 -o", "test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watch=false", "test:app": "vitest", @@ -79,7 +80,7 @@ "test:other": "yarn prettier --list-different", "test:typecheck": "tsc", "test:update": "yarn test:app --update --watch=false", - "test": "yarn workspace @excalidraw/utils build:esm && yarn test:app", + "test": "yarn clear:workspaces && yarn workspace @excalidraw/utils build:esm && yarn test:app", "test:coverage": "vitest --coverage", "test:coverage:watch": "vitest --coverage --watch", "test:ui": "yarn test --ui --coverage.enabled=true", diff --git a/packages/excalidraw/package.json b/packages/excalidraw/package.json index 0f531e1d6..ca9ec19a3 100644 --- a/packages/excalidraw/package.json +++ b/packages/excalidraw/package.json @@ -132,6 +132,7 @@ "pack": "yarn build:umd && yarn pack", "start": "node ../../scripts/buildExample.mjs && vite", "build:example": "node ../../scripts/buildExample.mjs", + "clear": "rm -rf dist", "size": "yarn build:umd && size-limit" } } diff --git a/packages/utils/package.json b/packages/utils/package.json index d8374f8b7..1a8b3ce6b 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -81,6 +81,7 @@ "build:umd": "cross-env NODE_ENV=production webpack --config webpack.prod.config.js", "build:esm": "rm -rf dist && node ../../scripts/buildUtils.js && yarn gen:types", "build:umd:withAnalyzer": "cross-env NODE_ENV=production ANALYZER=true webpack --config webpack.prod.config.js", + "clear":"rm -rf dist", "pack": "yarn build:umd && yarn pack" } }