Commit Graph
16 Commits
Author SHA1 Message Date
Oleg Isonen 8718feb465 test: simplify browser testing infrastructure (#6271)
## Summary

Unifies frontend testing around three intentional boundaries:

- Vitest Node projects for pure and server tests
- Vitest Browser Mode with Playwright/Chromium for DOM and component
tests
- Playwright Test for Builder end-to-end workflows

The Builder no longer uses jsdom. Ordinary E2E workflows use an
automatically managed isolated `page` fixture; explicit contexts remain
only for simultaneous identities and suite-scoped setup.

## Technical choices

- Split Builder tests into one Node project and independent browser
projects so each Chromium/Vite process has a bounded workload.
- Added shared Browser Mode configuration for the affected SDK React
packages.
- Preserve the Builder's production top-window bridge ownership; Browser
Mode uses explicit test-only installation seams.
- Centralized Playwright context options and kept action/navigation
timeouts bounded.
- Validate Playwright filters before Docker, migrations, browser
installation, or Builder builds start.
- Preserve the first failed E2E attempt's report, traces, screenshots,
and videos when CI retries a shard.
- Split static checks, typechecks, CLI tests, core package tests,
browser package tests, and Builder projects into parallel CI jobs with
five-minute hard ceilings.
- Distribute Builder E2E tests across ten isolated shards with two
workers; parallel suites create unique per-worker setup data.
- Reuse color contrast DOM/canvas samples so the exhaustive theme sweep
takes about four seconds instead of timing out at 30 seconds.
- The removed cost is jsdom behavior drift, oversized serial check jobs,
and unnecessary E2E startup for empty selections. Real browser startup
and E2E environment setup remain.

## Todo

- [x] Split Builder pure/server tests from browser/component tests.
- [x] Migrate Builder DOM tests from jsdom to Vitest Browser Mode.
- [x] Migrate affected SDK React DOM tests to the shared Browser Mode
setup.
- [x] Remove jsdom annotations, dependencies, and compatibility setup.
- [x] Replace ordinary manual E2E contexts with the isolated `page`
fixture.
- [x] Keep explicit contexts only for concurrent identities and
`beforeAll` setup.
- [x] Preserve setup authentication isolation from workflow pages.
- [x] Add bounded Playwright action and navigation timeouts.
- [x] Preserve first-attempt E2E failure evidence across CI retry.
- [x] Reject empty E2E selections before expensive environment setup.
- [x] Parallelize repository checks into bounded CI shards.
- [x] Isolate parallel E2E setup data across workers.
- [x] Remove the color contrast sweep bottleneck.
- [x] Update E2E contributor documentation.
- [x] Review product documentation impact; no user-facing product docs
are affected.
- [x] Run the full repository tests and typechecks.
- [x] Run formatting, lint, package-boundary, generated-file, and
fixture checks.
- [x] Complete final correctness and simplification review.

## Verification

- `pnpm --filter @webstudio-is/builder test`
- `pnpm -r typecheck`
- `pnpm lint`
- `pnpm check:package-boundaries`
- `pnpm check:generated-api`
- `pnpm check:generated-docs`
- `pnpm fixtures`
- Design-system: 222 tests pass locally.
- Builder: all seven Vitest projects pass locally.
- The formerly slow E2E shard passes locally in 1m55s.
- Full database-backed Builder E2E execution passes in CI.
- All CI jobs pass; the slowest completed in 4m58s.
- No fixture inputs/outputs or generated files changed.

Ref #6270
2026-08-31 17:17:28 +02:00
Oleg Isonen 5a57234c75 revert: Store Content Block content in MDX assets
Revert the accidental merge of #6125 so the implementation can continue in draft PR #6181.
2026-08-18 13:23:32 +01:00
Oleg Isonen 86b6310fff feat: Store Content Block content in MDX assets 2026-08-17 15:22:20 +01:00
Oleg Isonen 4f36bfd899 fix: Ignore messages from unknown sources e.g. browser extension (#5666)
… third-party scripts)
2026-03-27 21:24:06 +01:00
Oleg Isonen 9e72cc23c0 feat: New color formats and color picker (#5661)
https://github.com/webstudio-is/webstudio/issues/3574
2026-03-27 01:53:57 +01:00
Oleg Isonen 6c17a0ec19 chore: Oxlint (#5650) 2026-03-20 21:09:47 +01:00
Oleg Isonen 11ba996f13 feat: New token conflict resolution logic (#5524)
Fixes https://github.com/webstudio-is/webstudio/issues/5491

## Description

- When pasting an instance with tokens, we can compare the name and the
contents. If they are identical, we can choose the existing one and
avoid having any conflicts.
- When pasting a token and the name is already used, add a numeric
suffix to it.
- find duplicate tokens command that will go based on content even if
name is different


## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
0000)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2025-12-18 17:31:31 +01:00
Oleg Isonen ff2e086632 feat: Convert instance to an instance of a different component (#5522)
Closes https://github.com/webstudio-is/webstudio/issues/5523

## Description

- convert command now shows a list of available components
- along the way cleaned up commands.ts and made namespaced subscribe api
to subscribe for specific actions

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
0000)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2025-12-16 22:17:18 +01:00
Bogdan Chadkin a02e9d1afe refactor: prepare react 19 types (#4553)
React 19 simplified ref object story, moved JSX from global into react
package. Here prepared our code to not refactor too much in packages
bump.
2024-12-13 16:20:54 +07:00
Ivan Starkov afc77fa72a feat: Block editing with arrow keys (#4334)
## Description

- Double click now sets cursor to the click position
- Up/Down arrows on a first/last line trying to preserve cursor x
position (visible in case of block above block)
- Right/Left arrows switch blocks if cursor is at block begin/end.



## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-10-28 19:44:08 +03:00
Ivan Starkov 87bfd994be chore: Add postMessage token to secure against Canvas script execution (#4060)
## Description


https://github.com/webstudio-is/webstudio-saas/issues/317#issuecomment-2317121292

See postMessage

Doesn't work as can be intercepted using `addEventListener`.

## Steps for reproduction

In chrome dev console in window and canvas context 

```js
globalThis.postMessage = (...args) => console.log(...args); // no messages
```

```js
globalThis.postMessage({
    "action": {
        "type": "sendStoreData",
        "payload": {
            "source": "builder",
            "data": [
                {
                    "namespace": "hoveredInstanceSelector",
                    "value": [
                        "w2emY6HYI160BmYG9WA6C",
                        "_BKGofOEhOFV_zLiN0iZk"
                    ]
                }
            ]
        }
    },
    "token": "development-token-2"
}, '*'); // Error in console "Invalid token"
```

```js
window["__webstudio__$__api_token"] // is undefined
```


```js
window.addEventListener(
    "message",
    e=>console.log({...e.data}), {capture: true}); // token prop is undefined
```

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-09-04 14:07:56 +03:00
Bogdan Chadkin 45aca18843 feat: select sibling after delete instance (#2476)
Quite requested improvement. Instead of selecting parent on delete
select next or previous sibling to be able to clean items within
collections with minimal amount of actions.

For testing
- delete first item in a list
- delete last item in a list
- delete the only item in a list
2023-10-15 12:49:22 +04:00
Bogdan Chadkin 743d2f1842 refactor: add commands emitter (#2389)
Added new commands emitter utility to manage hotkeys across plugins and
separate a lot of logic from canvas.

Here migrated only togglePreview as an example.

Later we can build commands panel and hotkeys overrides on top of this
utility.
2023-09-29 20:47:25 +04:00
Bogdan Chadkin 88dd24ff7d Move pubsub from sdk to builder (#2280)
Pubsub is only used for builder/canvas communication while sdk is
responsible for rendering sites.
Here moved pubsub to builder. Now we can drop nanoevents from cli
dependencies.
2023-09-08 20:56:46 +04:00
Bogdan Chadkin f0c8681a2d Replace mitt with nanoevents (#1365)
nanoevents doesn't have `*` we stopped using recently, have simpler api
with unsubscribe function and allows to avoid patch upcoming changes
https://github.com/webstudio-is/webstudio-builder/pull/1351.
2023-04-04 17:36:01 +07:00
Andras Bacsai ac413cdd5f rename designer to builder 2023-02-14 11:15:24 +01:00