mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 22:45:25 +00:00
fix: unable to add assertions to a request (#6435)
* fix: add assertion * rm: unnecessary wait fn * fix: test * fix: tests * fix: review comments * fix: review * fix: review comments * fix: review comments * fix: test failure * review fixes * fix: rm sandbox accept * fix: indentation
This commit is contained in:
@@ -16,7 +16,8 @@ const EditableTable = ({
|
||||
checkboxKey = 'enabled',
|
||||
reorderable = false,
|
||||
onReorder,
|
||||
showAddRow = true
|
||||
showAddRow = true,
|
||||
testId = 'editable-table'
|
||||
}) => {
|
||||
const tableRef = useRef(null);
|
||||
const emptyRowUidRef = useRef(null);
|
||||
@@ -224,7 +225,7 @@ const EditableTable = ({
|
||||
|
||||
return (
|
||||
<StyledWrapper className={showCheckbox ? 'has-checkbox' : 'no-checkbox'}>
|
||||
<div className="table-container" ref={tableRef}>
|
||||
<div className="table-container" ref={tableRef} data-testid={testId}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -285,6 +286,7 @@ const EditableTable = ({
|
||||
<input
|
||||
type="checkbox"
|
||||
className="mousetrap"
|
||||
data-testid="column-checkbox"
|
||||
checked={row[checkboxKey] ?? true}
|
||||
onChange={(e) => handleCheckboxChange(row.uid, e.target.checked)}
|
||||
/>
|
||||
@@ -292,14 +294,17 @@ const EditableTable = ({
|
||||
</td>
|
||||
)}
|
||||
{columns.map((column) => (
|
||||
<td key={column.key}>
|
||||
<td key={column.key} data-testid={`column-${column.key}`}>
|
||||
{renderCell(column, row, rowIndex)}
|
||||
</td>
|
||||
))}
|
||||
{showDelete && (
|
||||
<td>
|
||||
{!isEmpty && (
|
||||
<button onClick={() => handleRemoveRow(row.uid)}>
|
||||
<button
|
||||
data-testid="column-delete"
|
||||
onClick={() => handleRemoveRow(row.uid)}
|
||||
>
|
||||
<IconTrash strokeWidth={1.5} size={18} />
|
||||
</button>
|
||||
)}
|
||||
|
||||
@@ -81,7 +81,7 @@ const AssertionOperator = ({ operator, onChange }) => {
|
||||
};
|
||||
|
||||
return (
|
||||
<select value={operator} onChange={handleChange} className="mousetrap">
|
||||
<select value={operator} onChange={handleChange} className="mousetrap" data-testid="assertion-operator-select">
|
||||
{operators.map((operator) => (
|
||||
<option key={operator} value={operator}>
|
||||
{getLabel(operator)}
|
||||
|
||||
@@ -163,6 +163,7 @@ const Assertions = ({ item, collection }) => {
|
||||
defaultRow={defaultRow}
|
||||
reorderable={true}
|
||||
onReorder={handleAssertionDrag}
|
||||
testId="assertions-table"
|
||||
/>
|
||||
</StyledWrapper>
|
||||
);
|
||||
|
||||
@@ -33,6 +33,46 @@ const keyValueSchema = Yup.object({
|
||||
.noUnknown(true)
|
||||
.strict();
|
||||
|
||||
const assertionOperators = [
|
||||
'eq',
|
||||
'neq',
|
||||
'gt',
|
||||
'gte',
|
||||
'lt',
|
||||
'lte',
|
||||
'in',
|
||||
'notIn',
|
||||
'contains',
|
||||
'notContains',
|
||||
'length',
|
||||
'matches',
|
||||
'notMatches',
|
||||
'startsWith',
|
||||
'endsWith',
|
||||
'between',
|
||||
'isEmpty',
|
||||
'isNotEmpty',
|
||||
'isNull',
|
||||
'isUndefined',
|
||||
'isDefined',
|
||||
'isTruthy',
|
||||
'isFalsy',
|
||||
'isJson',
|
||||
'isNumber',
|
||||
'isString',
|
||||
'isBoolean',
|
||||
'isArray'
|
||||
];
|
||||
|
||||
const assertionSchema = keyValueSchema.shape({
|
||||
operator: Yup.string()
|
||||
.oneOf(assertionOperators)
|
||||
.nullable()
|
||||
.optional()
|
||||
})
|
||||
.noUnknown(true)
|
||||
.strict();
|
||||
|
||||
const varsSchema = Yup.object({
|
||||
uid: uidSchema,
|
||||
name: Yup.string().nullable(),
|
||||
@@ -372,7 +412,7 @@ const requestSchema = Yup.object({
|
||||
.noUnknown(true)
|
||||
.strict()
|
||||
.nullable(),
|
||||
assertions: Yup.array().of(keyValueSchema).nullable(),
|
||||
assertions: Yup.array().of(assertionSchema).nullable(),
|
||||
tests: Yup.string().nullable(),
|
||||
docs: Yup.string().nullable()
|
||||
})
|
||||
@@ -408,7 +448,7 @@ const grpcRequestSchema = Yup.object({
|
||||
.noUnknown(true)
|
||||
.strict()
|
||||
.nullable(),
|
||||
assertions: Yup.array().of(keyValueSchema).nullable(),
|
||||
assertions: Yup.array().of(assertionSchema).nullable(),
|
||||
tests: Yup.string().nullable(),
|
||||
docs: Yup.string().nullable(),
|
||||
})
|
||||
@@ -446,7 +486,7 @@ const wsRequestSchema = Yup.object({
|
||||
.noUnknown(true)
|
||||
.strict()
|
||||
.nullable(),
|
||||
assertions: Yup.array().of(keyValueSchema).nullable(),
|
||||
assertions: Yup.array().of(assertionSchema).nullable(),
|
||||
tests: Yup.string().nullable(),
|
||||
docs: Yup.string().nullable()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user