Skip to content

Commit

Permalink
fix: Fix incorrect step selected after deleting last step
Browse files Browse the repository at this point in the history
  • Loading branch information
ademuk committed Dec 23, 2020
1 parent e64cb5e commit d5c47b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
24 changes: 0 additions & 24 deletions src/Components.tsx.tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,6 @@
}
}
},
{
"type": "assertion",
"definition": {
"type": "mock",
"target": {
"name": "fetch",
"args": ["/module-component"]
}
}
},
{
"type": "assertion",
"definition": {
Expand All @@ -332,20 +322,6 @@
"type": "text",
"target": "Components.tsx"
}
},
{
"type": "assertion",
"definition": {
"type": "text",
"target": "Components"
}
},
{
"type": "assertion",
"definition": {
"type": "text",
"target": "You don't have any tests yet"
}
}
],
"name": "Load components if no tests found"
Expand Down
10 changes: 6 additions & 4 deletions src/Test.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
}`
);
}
Expand Down Expand Up @@ -245,6 +246,7 @@ const Test = ({ history, file, exportName, test, step }: TestProps) => {
}}
onKeyPress={handleUpdateTestNameKeyPress}
ref={editableTestNameRef}
suppressContentEditableWarning={true}
>
{testName}
</h1>{" "}
Expand Down Expand Up @@ -289,7 +291,7 @@ const Test = ({ history, file, exportName, test, step }: TestProps) => {
<h3 className="text-xl p-2">{capitalise(type)}</h3>
{regions.map((r) => (
<button
className={`text-gray-700 hover:text-gray-600 hover:bg-gray-100 p-2 px-4 my-2 rounded-full focus:rounded-full w-full text-left`}
className={`text-gray-700 hover:text-gray-600 hover:bg-gray-100 py-2 px-4 my-2 rounded-full focus:rounded-full w-full text-left`}
key={`${r.xpath}${r.text}`}
onClick={() => setSelectedRegion(r)}
>
Expand All @@ -311,7 +313,7 @@ const Test = ({ history, file, exportName, test, step }: TestProps) => {
<h3 className="text-xl p-2">{label(name)}</h3>
{calls.map((args, i) => (
<button
className={`text-gray-700 hover:text-gray-600 hover:bg-gray-100 p-2 my-2 rounded-full focus:rounded-full text-left`}
className={`text-gray-700 hover:text-gray-600 hover:bg-gray-100 py-2 px-4 my-2 rounded-full focus:rounded-full w-full text-left`}
key={[i, ...args].join("")}
onClick={() => setSelectedMockCall([name, args])}
>
Expand Down

0 comments on commit d5c47b1

Please sign in to comment.