diff --git a/server/render.ts b/server/render.ts index bc436c2..dd759fc 100644 --- a/server/render.ts +++ b/server/render.ts @@ -78,7 +78,7 @@ window.result = getWrapperComponent().then( render(WrapperComponent).then( () => new Promise((resolve, reject) => - setTimeout(() => (window.error ? reject(window.error) : resolve()), 0) + setTimeout(() => (window.error ? reject(window.error) : resolve())) ) ) ); diff --git a/server/server.ts b/server/server.ts index 7b5824c..58f8e8d 100644 --- a/server/server.ts +++ b/server/server.ts @@ -683,7 +683,9 @@ const runEventStep = ( ); }); - return Promise.resolve(["success", context]); + return new Promise((resolve) => + setTimeout(() => resolve(["success", context]), 10) + ); }; const runAssertionStep = ( diff --git a/src/Components.tsx.tests.json b/src/Components.tsx.tests.json index 581eaaa..30947b1 100644 --- a/src/Components.tsx.tests.json +++ b/src/Components.tsx.tests.json @@ -141,6 +141,190 @@ } ], "name": "Render project components" + }, + { + "id": "0837dde0-453e-11eb-8435-8385c7863d38", + "steps": [ + { + "type": "mock", + "definition": { + "name": "fetch", + "args": ["/module-component"], + "return": [ + { + "file": "App.tsx", + "components": [ + { + "exportName": "default", + "name": "App" + } + ] + }, + { + "file": "Components.tsx", + "components": [ + { + "exportName": "default", + "name": "Components" + } + ] + } + ] + } + }, + { + "type": "mock", + "definition": { + "name": "fetch", + "args": ["/module-test"], + "return": [ + { + "file": "App.tsx", + "components": [ + { + "name": "App", + "tests": [ + { + "id": "c34b2f30-1c83-11eb-a8c1-1da52322ddf8", + "steps": [ + { + "type": "mock", + "definition": { + "name": "fetch", + "args": ["/module-component"], + "return": [] + } + }, + { + "type": "render", + "definition": { + "props": {} + } + }, + { + "type": "event", + "definition": { + "type": "click", + "target": "Look for other components" + } + } + ] + } + ], + "exportName": "default" + } + ] + } + ] + } + }, + { + "type": "render", + "definition": { + "props": {}, + "wrapper": { + "file": "react-router-dom", + "exportName": "MemoryRouter", + "props": {} + } + } + }, + { + "type": "event", + "definition": { + "type": "click", + "target": "Look for other components" + } + }, + { + "type": "assertion", + "definition": { + "type": "text", + "target": "Components.tsx" + } + }, + { + "type": "assertion", + "definition": { + "type": "text", + "target": "Components" + } + } + ], + "name": "Look for other components" + }, + { + "id": "6e725e50-453e-11eb-8435-8385c7863d38", + "steps": [ + { + "type": "mock", + "definition": { + "name": "fetch", + "args": ["/module-component"], + "return": [ + { + "file": "App.tsx", + "components": [ + { + "exportName": "default", + "name": "App" + } + ] + }, + { + "file": "Components.tsx", + "components": [ + { + "exportName": "default", + "name": "Components" + } + ] + } + ] + } + }, + { + "type": "mock", + "definition": { + "name": "fetch", + "args": ["/module-test"], + "return": [] + } + }, + { + "type": "render", + "definition": { + "props": {}, + "wrapper": { + "file": "react-router-dom", + "exportName": "MemoryRouter", + "props": {} + } + } + }, + { + "type": "assertion", + "definition": { + "type": "text", + "target": "App.tsx" + } + }, + { + "type": "assertion", + "definition": { + "type": "text", + "target": "App" + } + }, + { + "type": "assertion", + "definition": { + "type": "text", + "target": "Components.tsx" + } + } + ], + "name": "Load components if no tests found" } ] } diff --git a/src/Test.tsx b/src/Test.tsx index f876dd8..eae2544 100644 --- a/src/Test.tsx +++ b/src/Test.tsx @@ -1,4 +1,5 @@ -import React, { Fragment, useEffect, useRef, useState } from "react"; +import { Fragment, useEffect, useRef, useState } from "react"; +import * as React from "react"; import { Link as RouterLink, RouteComponentProps } from "react-router-dom"; import type { History } from "history"; import queryString from "query-string"; @@ -111,7 +112,7 @@ const Test = ({ history, file, exportName, test, step }: TestProps) => { if (test && step > steps.length - 1) { history.replace( `/tests/${test.id}?file=${file}&exportName=${exportName}&step=${ - test.steps.length - 1 + (steps.length ? steps.length : test.steps.length) - 1 }` ); } @@ -245,6 +246,7 @@ const Test = ({ history, file, exportName, test, step }: TestProps) => { }} onKeyPress={handleUpdateTestNameKeyPress} ref={editableTestNameRef} + suppressContentEditableWarning={true} > {testName} {" "} @@ -289,7 +291,7 @@ const Test = ({ history, file, exportName, test, step }: TestProps) => {