Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions redisinsight/api/src/__mocks__/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export const mockRedisUnknownIndexName: ReplyError = {
message: 'Unknown Index name',
};

export const mockRedisUnknownIndexNameV8: ReplyError = {
name: 'ReplyError',
command: 'FT.INFO',
message: 'idx: no such index',
};

export const mockRedisWrongNumberOfArgumentsError: ReplyError = {
name: 'ReplyError',
command: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
mockDatabaseClientFactory,
mockRedisNoPermError,
mockRedisUnknownIndexName,
mockRedisUnknownIndexNameV8,
mockStandaloneRedisClient,
} from 'src/__mocks__';
import { RedisearchService } from 'src/modules/browser/redisearch/redisearch.service';
Expand Down Expand Up @@ -155,6 +156,38 @@ describe('RedisearchService', () => {
{ replyEncoding: 'utf8' },
);
});
it('should create index for standalone v8', async () => {
when(standaloneClient.sendCommand)
.calledWith(expect.arrayContaining(['FT.INFO']))
.mockRejectedValue(mockRedisUnknownIndexNameV8);
when(standaloneClient.sendCommand)
.calledWith(expect.arrayContaining(['FT.CREATE']))
.mockResolvedValue('OK');

await service.createIndex(
mockBrowserClientMetadata,
mockCreateRedisearchIndexDto,
);

expect(standaloneClient.sendCommand).toHaveBeenCalledTimes(2);
expect(standaloneClient.sendCommand).toHaveBeenCalledWith(
[
'FT.CREATE',
mockCreateRedisearchIndexDto.index,
'ON',
mockCreateRedisearchIndexDto.type,
'PREFIX',
2,
...mockCreateRedisearchIndexDto.prefixes,
'SCHEMA',
mockCreateRedisearchIndexDto.fields[0].name,
mockCreateRedisearchIndexDto.fields[0].type,
mockCreateRedisearchIndexDto.fields[1].name,
mockCreateRedisearchIndexDto.fields[1].type,
],
{ replyEncoding: 'utf8' },
);
});
it('should create index for cluster', async () => {
databaseClientFactory.getOrCreateClient = jest
.fn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@
);
}
} catch (error) {
if (!error.message?.toLowerCase()?.includes('unknown index name')) {
const noIndexMessages = ['unknown index name', 'no such index'];

Check warning on line 107 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

if (
!noIndexMessages.some((keyword) =>

Check warning on line 110 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
error.message?.toLowerCase().includes(keyword),

Check warning on line 111 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 111 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 111 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 111 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 111 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
)
) {
throw error;
}

Check warning on line 115 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 115 in redisinsight/api/src/modules/browser/redisearch/redisearch.service.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const HorizontalRule = ({
className,
size = 'full',
margin = 'l',
color,
colorVariable,
...rest
}: HorizontalRuleProps) => {
const classes = classNames('RI-horizontal-rule', className)
Expand All @@ -19,9 +21,11 @@ const HorizontalRule = ({
size={size}
margin={margin}
className={classes}
color={color}
colorVariable={colorVariable}
{...rest}
/>
)
}

export default HorizontalRule
export default HorizontalRule
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ const horizontalRuleStyles = {
export interface HorizontalRuleProps extends HTMLAttributes<HTMLHRElement> {
size?: HorizontalRuleSize
margin?: HorizontalRuleMargin
color?: string
colorVariable?: string
}

export const StyledHorizontalRule = styled.hr<
Omit<HorizontalRuleProps, 'size' | 'margin'> & {
size?: HorizontalRuleSize
margin?: HorizontalRuleMargin
color?: string
colorVariable?: string
}
>`
${({ size = 'full' }) => horizontalRuleStyles.size[size]}
Expand All @@ -65,6 +69,9 @@ export const StyledHorizontalRule = styled.hr<
flex-shrink: 0;
flex-grow: 0;

background-color: var(--hrBackgroundColor);
background-color: ${({ color, colorVariable }) =>
color || colorVariable
? (color ?? `var(--${colorVariable})`)
: 'var(--hrBackgroundColor)'};
height: 1px;
`
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const CreateRedisearchIndex = ({ onClosePanel, onCreateIndex }: Props) => {
/>
</FlexItem>
</Row>
<HorizontalRule margin="s" />
<HorizontalRule margin="s" colorVariable="separatorColor" />
<Col grow={false} gap="s">
<Row align="center" gap="xs">
<Text>Identifier</Text>
Expand Down Expand Up @@ -317,7 +317,7 @@ const CreateRedisearchIndex = ({ onClosePanel, onCreateIndex }: Props) => {
</AddMultipleFields>
</Col>
</StyledContent>
<HorizontalRule margin="xs" />
<HorizontalRule margin="xs" colorVariable="separatorColor" />
<StyledFooter justify="end" gap="m">
<FlexItem>
<SecondaryButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const CreateRedisearchIndexWrapper = ({
</FlexItem>
<Spacer size="xl" />
</StyledHeader>
<HorizontalRule margin="xs" />
<HorizontalRule margin="xs" colorVariable="separatorColor" />
<CreateRedisearchIndex
onCreateIndex={onCreateIndex}
onClosePanel={onClosePanel}
Expand Down
Loading