Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Carina Ursu <[email protected]>
  • Loading branch information
ursucarina committed Nov 11, 2024
1 parent daff550 commit 54ba506
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import Chip from '@mui/material/Chip';
import makeStyles from '@mui/styles/makeStyles';

type ValuesType = {[p: string]: string};
type ValuesType = { [p: string]: string };
interface Props {
values: ValuesType;
}
Expand All @@ -12,21 +12,20 @@ const useStyles = makeStyles({
display: 'flex',
flexWrap: 'wrap',
width: '100%',
maxWidth: '420px'
maxWidth: '420px',
},
chip: {
margin: '2px 2px 2px 0',
},
});


export const ExecutionLabels: React.FC<Props> = ({values}) => {
export const ExecutionLabels: React.FC<Props> = ({ values }) => {
const classes = useStyles();
return (
<div className={classes.chipContainer}>
{Object.entries(values).map(([key, value]) => (
<Chip
color='info'
color="info"
key={key}
label={value ? `${key}: ${value}` : key}
className={classes.chip}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,7 @@ export const ExecutionMetadata: React.FC<{}> = () => {
const workflowId = execution?.closure?.workflowId;

const { labels } = execution.spec;
const {
referenceExecution,
systemMetadata ,
parentNodeExecution,
} = execution.spec.metadata;
const { referenceExecution, systemMetadata, parentNodeExecution } = execution.spec.metadata;
const cluster = systemMetadata?.executionCluster ?? dashedValueString;

const details: DetailItem[] = [
Expand Down Expand Up @@ -130,11 +126,13 @@ export const ExecutionMetadata: React.FC<{}> = () => {
if (labels != null && labels.values != null) {
details.push({
label: ExecutionMetadataLabels.labels,
value: (
Object.entries(labels.values).length > 0 ?
<ExecutionLabels values={labels.values} /> : dashedValueString
)
})
value:
Object.entries(labels.values).length > 0 ? (
<ExecutionLabels values={labels.values} />
) : (
dashedValueString
),
});
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export const ExecutionNodeURL: React.FC<{

const config =
// eslint-disable-next-line no-nested-ternary
env.CODE_SNIPPET_USE_AUTO_CONFIG === "true"
env.CODE_SNIPPET_USE_AUTO_CONFIG === 'true'
? 'Config.auto()'
: isHttps
? // https snippet
`Config.for_endpoint("${window.location.host}")`
: // http snippet
`Config.for_endpoint("${window.location.host}", True)`;
const code = `from flytekit.remote.remote import FlyteRemote
const code = `from flytekit.remote.remote import FlyteRemote
from flytekit.configuration import Config
remote = FlyteRemote(
${config},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@ import '@testing-library/jest-dom';
import { ExecutionLabels } from '../ExecutionLabels';

jest.mock('@mui/material/Chip', () => (props: any) => (
<div data-testid="chip" {...props}>{props.label}</div>
<div data-testid="chip" {...props}>
{props.label}
</div>
));

describe('ExecutionLabels', () => {
it('renders chips with key-value pairs correctly', () => {
const values = {
'random/uuid': 'f8b9ff18-4811-4bcc-aefd-4f4ec4de469d',
'bar': 'baz',
'foo': '',
bar: 'baz',
foo: '',
};

render(<ExecutionLabels values={values} />);

expect(screen.getByText('random/uuid: f8b9ff18-4811-4bcc-aefd-4f4ec4de469d')).toBeInTheDocument();
expect(
screen.getByText('random/uuid: f8b9ff18-4811-4bcc-aefd-4f4ec4de469d'),
).toBeInTheDocument();
expect(screen.getByText('bar: baz')).toBeInTheDocument();
expect(screen.getByText('foo')).toBeInTheDocument();
});

it('applies correct styles to chip container', () => {
const values = {
'key': 'value',
key: 'value',
};

const { container } = render(<ExecutionLabels values={values} />);
Expand All @@ -38,9 +42,9 @@ describe('ExecutionLabels', () => {

it('renders correct number of chips', () => {
const values = {
'key1': 'value1',
'key2': 'value2',
'key3': 'value3',
key1: 'value1',
key2: 'value2',
key3: 'value3',
};

render(<ExecutionLabels values={values} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const durationTestId = `metadata-${ExecutionMetadataLabels.duration}`;
const interruptibleTestId = `metadata-${ExecutionMetadataLabels.interruptible}`;
const overwriteCacheTestId = `metadata-${ExecutionMetadataLabels.overwriteCache}`;
const relatedToTestId = `metadata-${ExecutionMetadataLabels.relatedTo}`;
const parentNodeExecutionTestId = `metadata-${ExecutionMetadataLabels.parent}`
const parentNodeExecutionTestId = `metadata-${ExecutionMetadataLabels.parent}`;
const labelsTestId = `metadata-${ExecutionMetadataLabels.labels}`;

jest.mock('../../../../models/Launch/api', () => ({
Expand Down Expand Up @@ -113,15 +113,15 @@ describe('ExecutionMetadata', () => {
it('shows related to if metadata is available', () => {
const { getByTestId } = renderMetadata();
expect(getByTestId(relatedToTestId)).toHaveTextContent('name');
})
});

it('shows parent execution if metadata is available', () => {
const { getByTestId } = renderMetadata();
expect(getByTestId(parentNodeExecutionTestId)).toHaveTextContent('name');
})
});

it('shows labels if spec has them', () => {
const { getByTestId } = renderMetadata();
expect(getByTestId(labelsTestId)).toHaveTextContent("key: value");
})
expect(getByTestId(labelsTestId)).toHaveTextContent('key: value');
});
});
14 changes: 7 additions & 7 deletions packages/oss-console/src/models/__mocks__/executionsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const MOCK_EXECUTION_ID = {
project: 'project',
domain: 'domain',
name: 'name',
}
};

export function fixedDuration(): Protobuf.Duration {
return {
Expand Down Expand Up @@ -84,13 +84,13 @@ export function generateExecutionMetadata(): ExecutionMetadata {
executionCluster: 'flyte',
},
referenceExecution: {
...MOCK_EXECUTION_ID
...MOCK_EXECUTION_ID,
},
parentNodeExecution: {
nodeId: 'node',
executionId: {
...MOCK_EXECUTION_ID
}
...MOCK_EXECUTION_ID,
},
},
};
}
Expand All @@ -102,9 +102,9 @@ export const createMockExecutionSpec: () => ExecutionSpec = () => ({
metadata: generateExecutionMetadata(),
labels: {
values: {
"key": "value"
}
}
key: 'value',
},
},
});

export const createMockExecution: (id?: string | number) => Execution = (id = 1) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/oss-console/src/test/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const axiosMock = jest.mock('axios', () => ({
response: {
use: jest.fn(),
},
}
},
}),
defaults: {
transformRequest: [],
Expand Down

0 comments on commit 54ba506

Please sign in to comment.