From cf0cef0d89ad4461e9f6b9074d2a29b85050dc97 Mon Sep 17 00:00:00 2001 From: Wout Mertens Date: Fri, 6 Oct 2023 22:55:22 +0200 Subject: [PATCH] refactor(e2e): Make tests more robust (#5279) Use async matchers instead of waiting. --- .../src/components/attributes/attributes.tsx | 13 ++++-- .../apps/e2e/src/components/render/render.tsx | 11 +++-- .../apps/e2e/src/components/slot/slot.tsx | 1 + .../src/components/streaming/streaming.tsx | 4 +- .../apps/e2e/src/components/styles/styles.tsx | 7 +-- starters/apps/e2e/tsconfig.json | 1 + starters/apps/qwikcity-test/tsconfig.json | 1 + starters/e2e/e2e.attributes.spec.ts | 25 +++++----- starters/e2e/e2e.context.spec.ts | 6 +-- starters/e2e/e2e.effect-client.spec.ts | 7 --- starters/e2e/e2e.events.spec.ts | 46 +++++++------------ starters/e2e/e2e.lexical-scope.spec.ts | 6 +-- starters/e2e/e2e.render.spec.ts | 8 ++-- starters/e2e/e2e.resource.spec.ts | 8 +--- starters/e2e/e2e.signals.spec.ts | 7 --- starters/e2e/e2e.slot.spec.ts | 21 ++------- starters/e2e/e2e.streaming.spec.ts | 12 ++--- starters/e2e/e2e.style.spec.ts | 22 ++++----- starters/e2e/e2e.watch.spec.ts | 9 ++-- starters/e2e/qwikcity/actions.spec.ts | 12 ++--- starters/e2e/qwikcity/loaders.spec.ts | 5 -- starters/e2e/qwikcity/nav.spec.ts | 36 ++++++--------- starters/e2e/qwikcity/server.spec.ts | 5 -- starters/e2e/starter-partytown.spec.ts | 3 -- starters/e2e/todo.spec.ts | 1 - 25 files changed, 108 insertions(+), 169 deletions(-) create mode 100644 starters/apps/e2e/tsconfig.json create mode 100644 starters/apps/qwikcity-test/tsconfig.json diff --git a/starters/apps/e2e/src/components/attributes/attributes.tsx b/starters/apps/e2e/src/components/attributes/attributes.tsx index 6e43627d047..547d8479b4e 100644 --- a/starters/apps/e2e/src/components/attributes/attributes.tsx +++ b/starters/apps/e2e/src/components/attributes/attributes.tsx @@ -5,15 +5,19 @@ export const Attributes = component$(() => { return ( <>

Most of the changes happen in the input attributes

- - + ); }); -export const AttributesChild = component$(() => { +export const AttributesChild = component$<{ v: number }>(({ v }) => { const renders = useStore( { count: 0, @@ -157,6 +161,7 @@ export const AttributesChild = component$(() => { +
Render {v}
); }); @@ -181,6 +186,7 @@ export const Issue4718Undefined = component$(() => { data-works={signal.value} aria-label={signal.value} title={signal.value} + class={!signal.value && "moop"} onClick$={() => { signal.value = undefined; }} @@ -199,6 +205,7 @@ export const Issue4718Null = component$(() => { data-works={signal.value as any} aria-label={signal.value as any} title={signal.value as any} + class={!signal.value && "moop"} onClick$={() => { signal.value = null; }} diff --git a/starters/apps/e2e/src/components/render/render.tsx b/starters/apps/e2e/src/components/render/render.tsx index 7880f51c83a..2e162873033 100644 --- a/starters/apps/e2e/src/components/render/render.tsx +++ b/starters/apps/e2e/src/components/render/render.tsx @@ -22,14 +22,18 @@ export const Render = component$(() => { const rerender = useSignal(0); return ( <> - - + ); }); -export const RenderChildren = component$(() => { +export const RenderChildren = component$<{ v: number }>(({ v }) => { const parent = { counter: { count: 0, @@ -42,6 +46,7 @@ export const RenderChildren = component$(() => { const state = useStore(parent, { deep: true }); return ( <> +
Render {v}
@@ -35,7 +35,7 @@ export const Streaming = component$(() => { return (
    diff --git a/starters/apps/e2e/src/components/styles/styles.tsx b/starters/apps/e2e/src/components/styles/styles.tsx index 0530b4f1558..5c64ece4608 100644 --- a/starters/apps/e2e/src/components/styles/styles.tsx +++ b/starters/apps/e2e/src/components/styles/styles.tsx @@ -16,15 +16,15 @@ export const Styles = component$(() => { const reload = useSignal(0); return ( <> - - + ); }); -export const StylesChildren = component$(() => { +export const StylesChildren = component$<{ v: number }>(({ v }) => { useStylesScoped$(parent); useStylesScoped$(parent2); @@ -33,6 +33,7 @@ export const StylesChildren = component$(() => { }); return (
    +
    Render {v}
    Parent