Skip to content

Commit

Permalink
chore(e2e): migrate ui.json of presets
Browse files Browse the repository at this point in the history
Migrated the `ui.json` of E2E to avoid warning during E2E test. I just ran `writer edit tests/e2e/presets/$FILE` in each preset folder and committed.

It should avoid unnecessary computation during the E2E execution and ease the migration.
  • Loading branch information
madeindjs committed Oct 1, 2024
1 parent 1c26d26 commit 46c6df2
Show file tree
Hide file tree
Showing 30 changed files with 69 additions and 409 deletions.
19 changes: 17 additions & 2 deletions tests/e2e/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const express = require("express");
const fs = require("node:fs").promises;
const fs = require("node:fs/promises");
const path = require("node:path/promises");
const { spawn } = require("node:child_process");
const httpProxy = require("http-proxy");

Expand Down Expand Up @@ -109,7 +110,7 @@ class WriterProcessPool {
async start(preset) {
const id = this.genId.next().value;
await fs.mkdir(`./runtime/${id}`);
await fs.copyFile(`./presets/${preset}/ui.json`, `./runtime/${id}/ui.json`);
await copyDir(`./presets/${preset}/.wf`, `./runtime/${id}/.wf`);
await fs.copyFile(`./presets/${preset}/main.py`, `./runtime/${id}/main.py`);
const process = new WriterProcess(`./runtime/${id}`, this.genPort.next().value);
await process.start();
Expand All @@ -126,6 +127,20 @@ class WriterProcessPool {
await fs.rm(`./runtime/${id}`, { recursive: true });
}


}
async function copyDir(src,dest) {
const entries = await fs.readdir(src, {withFileTypes: true});
await fs.mkdir(dest);
for(let entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if(entry.isDirectory()) {
await copyDir(srcPath, destPath);
} else {
await fs.copyFile(srcPath, destPath);
}
}
}

const sspp = new WriterProcessPool();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"id": "qlbz49xq2emx9ip4", "type": "page", "content": {}, "parentId": "root", "position": 0, "handlers": {}, "visible": true}
{"id": "3fzi2hkb6fzfgf40", "type": "section", "content": {"title": ""}, "parentId": "qlbz49xq2emx9ip4", "position": 0, "handlers": {}, "visible": true}
{"id": "gm7nov9whz3q0i7l", "type": "columns", "parentId": "3fzi2hkb6fzfgf40", "content": {}, "handlers": {}, "position": 0, "visible": true}
{"id": "kj09cwig8j3336jc", "type": "column", "parentId": "gm7nov9whz3q0i7l", "content": {"width": "1"}, "handlers": {}, "position": 0, "visible": true}
{"id": "f5kw67b26pht1iys", "type": "column", "parentId": "gm7nov9whz3q0i7l", "content": {"width": "1"}, "handlers": {}, "position": 1, "visible": true}
1 change: 1 addition & 0 deletions tests/e2e/presets/2columns/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "My App"}, "parentId": null, "position": 0, "handlers": {}, "visible": true}
3 changes: 3 additions & 0 deletions tests/e2e/presets/2columns/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.3.0"
}
69 changes: 0 additions & 69 deletions tests/e2e/presets/2columns/ui.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "qlbz49xq2emx9ip4", "type": "page", "content": {"key": "page1"}, "position": 0, "parentId": "root", "handlers": {}, "visible": true}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "6gnhb317w7k76uhw", "type": "page", "parentId": "root", "content": {"key": "page2"}, "handlers": {}, "position": 1, "visible": true}
1 change: 1 addition & 0 deletions tests/e2e/presets/2pages/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "My App"}, "position": 0, "handlers": {}, "visible": true}
3 changes: 3 additions & 0 deletions tests/e2e/presets/2pages/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.3.0"
}
39 changes: 0 additions & 39 deletions tests/e2e/presets/2pages/ui.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "qlbz49xq2emx9ip4", "type": "page", "content": {}, "parentId": "root", "position": 0, "handlers": {}, "visible": true}
1 change: 1 addition & 0 deletions tests/e2e/presets/empty_page/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "My App"}, "parentId": null, "position": 0, "handlers": {}, "visible": true}
3 changes: 3 additions & 0 deletions tests/e2e/presets/empty_page/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.3.0"
}
27 changes: 0 additions & 27 deletions tests/e2e/presets/empty_page/ui.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"id": "bb4d0e86-619e-4367-a180-be28ab6059f4", "type": "page", "content": {"pageMode": "", "key": "main"}, "isCodeManaged": false, "position": 0, "parentId": "root"}
{"id": "fa1r81mv2rrdhfh9", "type": "jsonviewer", "content": {"data": "{\"name\":\"JSON Viewer\",\"description\":\"A JSON tree viewer where you can expand the keys.\",\"sample\":{\"description\":\"This sample is opened by default\",\"bool\":true,\"null\":null,\"list\":[1,\"two\",{\"key\":3}]},\"sampleClosed\":{\"description\":\"This sample is not opened by default\"},\"createdAt\":\"2024-08-13T20:45:15.668Z\"}", "initialDepth": "0"}, "isCodeManaged": false, "position": 0, "parentId": "bb4d0e86-619e-4367-a180-be28ab6059f4", "handlers": {}, "visible": true}
1 change: 1 addition & 0 deletions tests/e2e/presets/jsonviewer/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "Hello", "emptinessColor": "#ffffff"}, "isCodeManaged": false, "position": 0}
3 changes: 3 additions & 0 deletions tests/e2e/presets/jsonviewer/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.6.2rc3"
}
42 changes: 0 additions & 42 deletions tests/e2e/presets/jsonviewer/ui.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{"id": "qlbz49xq2emx9ip4", "type": "page", "content": {"key": "setup"}, "isCodeManaged": false, "position": 0, "parentId": "root", "handlers": {}, "visible": true}
{"id": "0jbl2x7sl5gbjdnl", "type": "section", "content": {"title": "Test"}, "isCodeManaged": false, "position": 0, "parentId": "qlbz49xq2emx9ip4", "handlers": {}, "visible": true}
{"id": "byk3srfwyj1hn4wl", "type": "button", "content": {"text": "Run test", "cssClasses": "TestExec"}, "isCodeManaged": false, "position": 1, "parentId": "0jbl2x7sl5gbjdnl", "handlers": {"wf-click": "execute_test"}, "visible": true}
{"id": "1ybermv0ttvw4lhk", "type": "textareainput", "content": {"label": "Input Label", "rows": "5", "cssClasses": "TestInput"}, "isCodeManaged": false, "position": 0, "parentId": "0jbl2x7sl5gbjdnl", "handlers": {}, "visible": true, "binding": {"eventType": "wf-change", "stateRef": "code"}}
{"id": "results", "type": "section", "content": {"title": "Test Results", "cssClasses": "results"}, "isCodeManaged": false, "position": 1, "parentId": "qlbz49xq2emx9ip4", "handlers": {}, "visible": true}
{"id": "5756wvfy52nzjnrl", "type": "textinput", "parentId": "0jbl2x7sl5gbjdnl", "content": {"label": "Input Label"}, "handlers": {}, "position": 2, "visible": true}
{"id": "initialization", "type": "section", "parentId": "qlbz49xq2emx9ip4", "content": {"title": "Initialization", "cssClasses": "initialization"}, "handlers": {}, "position": 2, "visible": true}
1 change: 1 addition & 0 deletions tests/e2e/presets/low_code/.wf/components-root.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id": "root", "type": "root", "content": {"appName": "My App"}, "isCodeManaged": false, "position": 0, "handlers": {}, "visible": true}
3 changes: 3 additions & 0 deletions tests/e2e/presets/low_code/.wf/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"writer_version": "0.3.0"
}
111 changes: 0 additions & 111 deletions tests/e2e/presets/low_code/ui.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"id": "qlbz49xq2emx9ip4", "type": "page", "content": {}, "parentId": "root", "position": 0, "handlers": {}, "visible": true}
{"id": "3fzi2hkb6fzfgf40", "type": "section", "parentId": "qlbz49xq2emx9ip4", "content": {"title": ""}, "handlers": {}, "position": 0, "visible": true}
Loading

0 comments on commit 46c6df2

Please sign in to comment.