Skip to content

Commit c483372

Browse files
committed
Fix tests
1 parent 14da057 commit c483372

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

apps/builder/app/builder/features/pages/page-settings.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,16 @@ export const PageSettings = ({
16421642
onDuplicate={() => {
16431643
const newPageId = duplicatePage(pageId);
16441644
if (newPageId !== undefined) {
1645-
onDuplicate(newPageId);
1645+
// In `canvas.tsx`, within `subscribeStyles`, we use `requestAnimationFrame` (RAF) for style recalculation.
1646+
// After `duplicatePage`, styles are not yet recalculated.
1647+
// To ensure they are properly updated, we use double RAF.
1648+
requestAnimationFrame(() => {
1649+
// At this tick styles are updating
1650+
requestAnimationFrame(() => {
1651+
// At this tick styles are updated
1652+
onDuplicate(newPageId);
1653+
});
1654+
});
16461655
}
16471656
}}
16481657
>

packages/sdk-components-animation/vitest.config.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
import { defineConfig } from "vitest/config";
2+
import { existsSync, readdirSync } from "node:fs";
3+
import path from "node:path";
4+
5+
const isFolderEmpty = (folderPath: string) => {
6+
if (!existsSync(folderPath)) {
7+
return true; // Folder does not exist
8+
}
9+
const contents = readdirSync(folderPath);
10+
11+
return contents.length === 0;
12+
};
13+
14+
const hasPrivateFolders = !isFolderEmpty(
15+
path.join(__dirname, "../../packages/sdk-components-animation/private-src")
16+
);
17+
18+
const conditions = hasPrivateFolders
19+
? ["webstudio-private", "webstudio"]
20+
: ["webstudio"];
221

322
export default defineConfig({
23+
resolve: {
24+
conditions,
25+
},
26+
ssr: {
27+
resolve: {
28+
conditions,
29+
},
30+
},
431
test: {
532
passWithNoTests: true,
633
workspace: [

0 commit comments

Comments
 (0)