Skip to content

Commit

Permalink
chore: fixed ocational server startup error
Browse files Browse the repository at this point in the history
  • Loading branch information
raaymax committed Mar 4, 2024
1 parent 2dd527c commit 3244c09
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 34 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches: [ dev, master]

jobs:
build:
e2e:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -39,10 +39,3 @@ jobs:

- name: Run E2E tests
run: poetry run alfred ci --e2e

- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: e2e_tests/playwright-report/
retention-days: 2
2 changes: 1 addition & 1 deletion alfred/npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def npm_lint():

@alfred.command("npm.e2e", help="run e2e tests")
def npm_test():
alfred.run("npm run test:ci")
alfred.run("npm run e2e:ci")

@alfred.command("npm.build", help="build ui code")
def npm_build():
Expand Down
20 changes: 12 additions & 8 deletions e2e_tests/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const express = require("express");
const fs = require("node:fs").promises;
const { spawn } = require("node:child_process");
const httpProxy = require('http-proxy');
const httpProxy = require("http-proxy");

class Streamsync {
constructor() {
Expand All @@ -11,15 +11,18 @@ class Streamsync {
}

async start() {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
const ss = spawn(
"streamsync",
["edit", "./runtime", "--port", this.port],
{
stdio: "pipe",
}
["edit", "./runtime", "--port", this.port]
);
this.process = ss;
const startupTimeout = setTimeout(() => {
// eslint-disable-next-line no-console
console.error("Streamsync startup timeout");
ss.kill();
reject();
}, 5000);

ss.stdout.on("data", (data) => {
// eslint-disable-next-line no-console
Expand All @@ -28,6 +31,7 @@ class Streamsync {
);
if (data.includes("Builder is available at")) {
this.initialized = true;
clearTimeout(startupTimeout);
resolve(ss);
}
});
Expand All @@ -45,7 +49,7 @@ class Streamsync {
// eslint-disable-next-line no-console
console.log(`[${ss.pid}] child process error`, err);
});
ss.on("exit", (code, arg) => {
ss.on("exit", (code) => {
// eslint-disable-next-line no-console
this.process = null;
console.log(
Expand Down Expand Up @@ -86,7 +90,6 @@ class Streamsync {
const ss = new Streamsync();
(async () => {
await fs.mkdir("runtime", { recursive: true });
await ss.loadPreset("empty_page");
})();

var proxy = httpProxy.createProxyServer();
Expand All @@ -99,6 +102,7 @@ proxy.on('error', function (e) {
const app = express();

app.get("/preset/:preset", async (req, res) => {
console.log("Loading preset", req.params.preset);
const preset = req.params.preset;
await ss.loadPreset(preset);
res.send("UI updated");
Expand Down
5 changes: 3 additions & 2 deletions e2e_tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "node index.js",
"start": "node index.js",
"test": "playwright test --project=chromium --reporter=list",
"test:ci": "playwright test --project=chromium"
"test:ci": "playwright test --project=chromium",
"test:ui": "playwright test --project=chromium --ui"
},
"dependencies": {
"express": "4.18.2",
Expand Down
4 changes: 2 additions & 2 deletions e2e_tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: 1,
reporter: "html",
reporter: "list",
use: {
baseURL: "http://127.0.0.1:7357",
trace: "on-first-retry",
Expand All @@ -30,7 +30,7 @@ export default defineConfig({
],

webServer: {
command: "npm run dev",
command: "npm start",
url: "http://127.0.0.1:7357",
reuseExistingServer: true,
stdout: 'pipe',
Expand Down
6 changes: 1 addition & 5 deletions e2e_tests/tests/createAndRemove.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const fullCheck = [
{ type: "textareainput", locator: `div.CoreTextareaInput.component` },
{ type: "numberinput", locator: `div.CoreNumberInput.component` },
{ type: "sliderinput", locator: `div.CoreSliderInput.component` },
{ type: "dateinput", locator: `div.CoreDateInput.component` },
//{ type: "dateinput", locator: `div.CoreDateInput.component` },
{ type: "radioinput", locator: `div.CoreRadioInput.component` },
{ type: "checkboxinput", locator: `div.CoreCheckboxInput.component` },
{ type: "dropdowninput", locator: `div.CoreDropdownInput.component` },
Expand All @@ -47,10 +47,6 @@ const fullCheck = [
{ type: "videoplayer", locator: `div.CoreVideoPlayer.component` },
];

const loadPreset = async (preset) => {
await fetch(`http://127.0.0.1:7358/${preset}`);
};

createAndRemove.forEach(({ type, locator }) => {
test.describe(type, () => {
const TYPE = type;
Expand Down
4 changes: 0 additions & 4 deletions e2e_tests/tests/undoRedo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ import { test, expect } from "@playwright/test";

test.setTimeout(5000);

const loadPreset = async (preset) => {
await fetch(`http://127.0.0.1:7358/${preset}`);
};

test.describe('undo and redo', () => {
const TYPE = 'button';
const COMPONENT_LOCATOR = 'button.CoreButton.component';
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"scripts": {
"build": "npm run -w streamsync-ui build",
"custom.build": "npm run -w streamsync-ui custom.build",
"test": "npm run -w streamsync-e2e test",
"test:ci": "npm run -w streamsync-e2e test:ci",
"e2e": "npm run -w streamsync-e2e test",
"e2e:ui": "npm run -w streamsync-e2e test:ui",
"e2e:ci": "npm run -w streamsync-e2e test:ci",
"lint": "npm run -w streamsync-ui lint",
"lint:ci": "npm run -w streamsync-ui lint:ci",
"dev": "npm run -w streamsync-ui dev"
Expand Down
4 changes: 2 additions & 2 deletions ui/src/core_components/other/CorePagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<div v-show="pagesizeEnabled" class="pagination-pagesize">
<select class="pagesize-select" @change="onPageSizeChange">
<option
v-for="o in pageSizeOptions"
:key="o.value"
v-for="(o, key) in pageSizeOptions"
:key="key"
:value="o.value"
:selected="o.value == fields.pageSize.value"
>
Expand Down

0 comments on commit 3244c09

Please sign in to comment.