test: add CI rendering PTY fixtures + 4 tests
- ci.tsx: Static items + counter (non-interactive/CI behavior) - ci-debug.tsx: debug mode rendering - ci-debug-after-exit.tsx: debug mode exit + DONE output Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
|||||||
|
import { test, expect } from "vite-plus/test";
|
||||||
|
import { run } from "./helpers/run.ts";
|
||||||
|
import stripAnsi from "strip-ansi";
|
||||||
|
|
||||||
|
test.sequential("render only last frame in CI", async () => {
|
||||||
|
const output = await run("ci", { env: { CI: "true" }, columns: 0 });
|
||||||
|
const clean = stripAnsi(output).replaceAll("\r", "");
|
||||||
|
// Counter: 0 through Counter: 4 should be absent
|
||||||
|
for (let i = 0; i <= 4; i++) {
|
||||||
|
expect(clean).not.toContain(`Counter: ${i}`);
|
||||||
|
}
|
||||||
|
expect(clean).toContain("Counter: 5");
|
||||||
|
});
|
||||||
|
|
||||||
|
test.sequential("render all frames if CI=false", async () => {
|
||||||
|
const output = await run("ci", { env: { CI: "false" }, columns: 0 });
|
||||||
|
const clean = stripAnsi(output).replaceAll("\r", "");
|
||||||
|
for (let i = 0; i <= 5; i++) {
|
||||||
|
expect(clean).toContain(`Counter: ${i}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test.sequential("debug mode in CI", async () => {
|
||||||
|
const output = await run("ci-debug", { env: { CI: "true" }, columns: 0 });
|
||||||
|
const clean = stripAnsi(output).replaceAll("\r", "");
|
||||||
|
const count = clean.split("Hello").length - 1;
|
||||||
|
expect(count).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.sequential("debug after exit", async () => {
|
||||||
|
const output = await run("ci-debug-after-exit", { env: { CI: "true" }, columns: 0 });
|
||||||
|
const clean = stripAnsi(output).replaceAll("\r", "");
|
||||||
|
expect(clean).toBe("HelloHello\nDONE");
|
||||||
|
});
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import process from "node:process";
|
||||||
|
import { createApp, Text } from "@vue-tui/runtime";
|
||||||
|
import { defineComponent } from "vue";
|
||||||
|
|
||||||
|
const App = defineComponent(() => () => <Text>Hello</Text>);
|
||||||
|
|
||||||
|
const app = createApp(App);
|
||||||
|
app.mount({ debug: true });
|
||||||
|
app.unmount();
|
||||||
|
await app.waitUntilExit();
|
||||||
|
process.stdout.write("DONE");
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { createApp, Text } from "@vue-tui/runtime";
|
||||||
|
import { defineComponent } from "vue";
|
||||||
|
|
||||||
|
const App = defineComponent(() => () => <Text>Hello</Text>);
|
||||||
|
|
||||||
|
const app = createApp(App);
|
||||||
|
app.mount({ debug: true });
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { createApp, Static, Text } from "@vue-tui/runtime";
|
||||||
|
import { defineComponent, onMounted, onScopeDispose, shallowRef } from "vue";
|
||||||
|
|
||||||
|
const App = defineComponent(() => {
|
||||||
|
const items = shallowRef<string[]>([]);
|
||||||
|
const counter = shallowRef(0);
|
||||||
|
let counterValue = 0;
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
let timer: ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
|
const onTimeout = () => {
|
||||||
|
if (counterValue > 4) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
counterValue += 1;
|
||||||
|
counter.value = counterValue;
|
||||||
|
items.value = [...items.value, `#${counterValue}`];
|
||||||
|
timer = setTimeout(onTimeout, 20);
|
||||||
|
};
|
||||||
|
|
||||||
|
timer = setTimeout(onTimeout, 20);
|
||||||
|
|
||||||
|
onScopeDispose(() => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => (
|
||||||
|
<>
|
||||||
|
<Static items={items.value}>
|
||||||
|
{{ default: ({ item }: { item: string }) => <Text key={item}>{item}</Text> }}
|
||||||
|
</Static>
|
||||||
|
<Text>Counter: {counter.value}</Text>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const app = createApp(App);
|
||||||
|
app.mount();
|
||||||
Reference in New Issue
Block a user