Skip to content

Commit

Permalink
Merge branch 'main' into alert-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin-chaurasiya authored Aug 1, 2024
2 parents 3c00265 + 5100f46 commit 2e6ad18
Show file tree
Hide file tree
Showing 17 changed files with 540 additions and 530 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ describe(
cy.get('[data-testid="add-ingestion-button"]')
.should('be.visible')
.click();
cy.get('[data-testid="select-all-test-cases"]').click();
scheduleIngestion(false);

cy.get('[data-testid="success-line"]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test('TestSuite multi pipeline support', async ({ page }) => {
);

await page.getByTestId('add-ingestion-button').click();
await page.getByTestId('select-all-test-cases').click();
await page.getByTestId('cron-type').getByText('Hour').click();
await page.getByTitle('Day').click();
await page.getByTestId('deploy-button').click();
Expand All @@ -65,7 +66,7 @@ test('TestSuite multi pipeline support', async ({ page }) => {
await page.getByTestId('add-pipeline-button').click();

await page.fill('[data-testid="pipeline-name"]', pipelineName);
await page.getByTestId('select-test-case').click();

await page.getByTestId(testCaseName).click();

await page.getByTestId('cron-type').locator('div').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export interface TestSuiteIngestionProps {
testSuite: TestSuite;
ingestionPipeline?: IngestionPipeline;
onCancel?: () => void;
showAddTestCase?: boolean;
onViewServiceClick?: () => void;
}

Expand All @@ -48,7 +47,7 @@ export type TestSuiteIngestionDataType = {
enableDebugLog?: boolean;
testCases?: string[];
name?: string;
selectTestCase?: boolean;
selectAllTestCases?: boolean;
};

export interface TestSuiteSchedulerProps {
Expand All @@ -67,10 +66,10 @@ export interface TestSuiteSchedulerProps {
export interface AddTestSuitePipelineProps {
initialData?: Partial<TestSuiteIngestionDataType>;
isLoading: boolean;
testSuiteFQN?: string;
onSubmit: (data: TestSuiteIngestionDataType) => void;
includePeriodOptions?: string[];
onCancel?: () => void;
showAddTestCase?: boolean;
}

export interface RightPanelProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const TestSuiteIngestion: React.FC<TestSuiteIngestionProps> = ({
ingestionPipeline,
testSuite,
onCancel,
showAddTestCase = false,
onViewServiceClick,
}) => {
const { ingestionFQN } = useFqn();
Expand Down Expand Up @@ -130,7 +129,7 @@ const TestSuiteIngestion: React.FC<TestSuiteIngestionProps> = ({
enableDebugLog: ingestionPipeline?.loggerLevel === LogLevels.Debug,
testCases,
name: ingestionPipeline?.displayName,
selectTestCase: !isUndefined(testCases),
selectAllTestCases: !isEmpty(ingestionPipeline) && isUndefined(testCases),
};
}, [ingestionPipeline]);

Expand Down Expand Up @@ -301,7 +300,7 @@ const TestSuiteIngestion: React.FC<TestSuiteIngestionProps> = ({
includePeriodOptions={schedulerOptions}
initialData={initialFormData}
isLoading={isLoading}
showAddTestCase={showAddTestCase}
testSuiteFQN={testSuite?.fullyQualifiedName}
onCancel={onCancel}
onSubmit={handleIngestionSubmit}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jest.mock('react-router-dom', () => ({
const mockProps: AddTestSuitePipelineProps = {
isLoading: false,
onSubmit: jest.fn(),
showAddTestCase: true,
};

describe('AddTestSuitePipeline', () => {
Expand All @@ -43,7 +42,7 @@ describe('AddTestSuitePipeline', () => {
expect(screen.getByTestId('pipeline-name')).toBeInTheDocument();
expect(screen.getByTestId('enable-debug-log')).toBeInTheDocument();
expect(screen.getByTestId('cron-container')).toBeInTheDocument();
expect(screen.getByTestId('select-test-case')).toBeInTheDocument();
expect(screen.getByTestId('select-all-test-cases')).toBeInTheDocument();
expect(screen.getByTestId('deploy-button')).toBeInTheDocument();
expect(screen.getByTestId('cancel')).toBeInTheDocument();
});
Expand All @@ -57,6 +56,9 @@ describe('AddTestSuitePipeline', () => {
await act(async () => {
await fireEvent.click(screen.getByTestId('enable-debug-log'));
});
await act(async () => {
await fireEvent.click(screen.getByTestId('select-all-test-cases'));
});
await act(async () => {
await fireEvent.click(screen.getByTestId('deploy-button'));
});
Expand All @@ -67,7 +69,7 @@ describe('AddTestSuitePipeline', () => {
name: 'Test Suite pipeline',
period: '',
repeatFrequency: undefined,
selectTestCase: undefined,
selectAllTestCases: true,
testCases: undefined,
});
});
Expand All @@ -93,27 +95,27 @@ describe('AddTestSuitePipeline', () => {
expect(mockUseHistory.goBack).toHaveBeenCalled();
});

it('displays AddTestCaseList after clicking on select-test-case switch', async () => {
it('Hide AddTestCaseList after clicking on select-all-test-cases switch', async () => {
render(<AddTestSuitePipeline {...mockProps} />);

// Assert that AddTestCaseList.component is not initially visible
expect(screen.queryByText('AddTestCaseList.component')).toBeNull();
// Assert that AddTestCaseList.component is now visible
expect(screen.getByText('AddTestCaseList.component')).toBeInTheDocument();

// Click on the select-test-case switch
// Click on the select-all-test-cases switch
await act(async () => {
await fireEvent.click(screen.getByTestId('select-test-case'));
await fireEvent.click(screen.getByTestId('select-all-test-cases'));
});

// Assert that AddTestCaseList.component is now visible
expect(screen.getByText('AddTestCaseList.component')).toBeInTheDocument();
// Assert that AddTestCaseList.component is not initially visible
expect(screen.queryByText('AddTestCaseList.component')).toBeNull();
});

it('renders with initial data', () => {
const initialData = {
enableDebugLog: true,
name: 'Initial Test Suite',
repeatFrequency: '* 0 0 0',
selectTestCase: true,
selectAllTestCases: true,
testCases: ['test-case-1', 'test-case-2'],
};

Expand All @@ -122,7 +124,7 @@ describe('AddTestSuitePipeline', () => {
// Assert that the form fields are rendered with the initial data
expect(screen.getByTestId('pipeline-name')).toHaveValue(initialData.name);
expect(screen.getByTestId('enable-debug-log')).toBeChecked();
expect(screen.getByTestId('select-test-case')).toBeChecked();
expect(screen.getByTestId('select-all-test-cases')).toBeChecked();
expect(screen.getByTestId('deploy-button')).toBeInTheDocument();
expect(screen.getByTestId('cancel')).toBeInTheDocument();
});
Expand All @@ -132,14 +134,14 @@ describe('AddTestSuitePipeline', () => {
enableDebugLog: true,
name: 'Initial Test Suite',
repeatFrequency: '* 0 0 0',
selectTestCase: true,
selectAllTestCases: false,
testCases: ['test-case-1', 'test-case-2'],
};

render(<AddTestSuitePipeline {...mockProps} initialData={initialData} />);

await act(async () => {
await fireEvent.click(screen.getByTestId('select-test-case'));
await fireEvent.click(screen.getByTestId('select-all-test-cases'));
});

expect(screen.queryByText('AddTestCaseList.component')).toBeNull();
Expand All @@ -152,15 +154,8 @@ describe('AddTestSuitePipeline', () => {
expect(mockProps.onSubmit).toHaveBeenCalledWith({
...initialData,
period: '',
selectTestCase: false,
selectAllTestCases: true,
testCases: undefined,
});
});

it('does not render add test case container if showAddTestCase is false', () => {
render(<AddTestSuitePipeline {...mockProps} showAddTestCase={false} />);

// Assert that add-test-case-container is not rendered
expect(screen.queryByTestId('add-test-case-container')).toBeNull();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const AddTestSuitePipeline = ({
onSubmit,
onCancel,
includePeriodOptions,
showAddTestCase = false,
testSuiteFQN,
}: AddTestSuitePipelineProps) => {
const { t } = useTranslation();
const history = useHistory();
const { fqn: testSuiteFQN } = useFqn();
const { fqn } = useFqn();
const [form] = Form.useForm();
const selectTestCase = Form.useWatch('selectTestCase', form);
const selectAllTestCases = Form.useWatch('selectAllTestCases', form);

const formFields: FieldProp[] = [
{
Expand Down Expand Up @@ -83,16 +83,16 @@ const AddTestSuitePipeline = ({

const testCaseFormFields: FieldProp[] = [
{
name: 'selectTestCase',
label: t('label.select-entity', {
entity: t('label.test-case'),
name: 'selectAllTestCases',
label: t('label.select-all-entity', {
entity: t('label.test-case-plural'),
}),
type: FieldTypes.SWITCH,
required: false,
props: {
'data-testid': 'select-test-case',
'data-testid': 'select-all-test-cases',
},
id: 'root/selectTestCase',
id: 'root/selectAllTestCases',
formItemLayout: FormItemLayout.HORIZONTAL,
},
];
Expand All @@ -112,7 +112,7 @@ const AddTestSuitePipeline = ({
};

const onValuesChange: FormProps['onValuesChange'] = (changedValues) => {
if (changedValues?.selectTestCase === false) {
if (changedValues?.selectAllTestCases) {
form.setFieldsValue({ testCases: undefined });
}
};
Expand All @@ -125,24 +125,30 @@ const AddTestSuitePipeline = ({
onFinish={onFinish}
onValuesChange={onValuesChange}>
{generateFormFields(formFields)}
{showAddTestCase && (
<Row className="add-test-case-container" gutter={[0, 16]}>
<Col span={24}>{generateFormFields(testCaseFormFields)}</Col>
{selectTestCase && (
<Col span={24}>
<Form.Item
label={t('label.test-case')}
name="testCases"
valuePropName="selectedTest">
<AddTestCaseList
filters={`testSuite.fullyQualifiedName:${testSuiteFQN}`}
showButton={false}
/>
</Form.Item>
</Col>
)}
</Row>
)}
<Row className="add-test-case-container" gutter={[0, 16]}>
<Col span={24}>{generateFormFields(testCaseFormFields)}</Col>
{!selectAllTestCases && (
<Col span={24}>
<Form.Item
label={t('label.test-case')}
name="testCases"
rules={[
{
required: true,
message: t('label.field-required', {
field: t('label.test-case'),
}),
},
]}
valuePropName="selectedTest">
<AddTestCaseList
filters={`testSuite.fullyQualifiedName:${testSuiteFQN ?? fqn}`}
showButton={false}
/>
</Form.Item>
</Col>
)}
</Row>
<Form.Item>
<Space className="w-full justify-end m-t-md" size={16}>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "Wählen Sie einen Metriktyp aus",
"select-a-policy": "Wählen Sie eine Richtlinie aus",
"select-add-test-suite": "Auswahl/Hinzufügen einer Test-Suite",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "Spalten zum Ausschließen auswählen",
"select-column-plural-to-include": "Spalten zum Einschließen auswählen",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "Select a Metric Type",
"select-a-policy": "Select a Policy",
"select-add-test-suite": "Select/Add Test Suite",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "Select Columns to Exclude",
"select-column-plural-to-include": "Select Columns to Include",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "Seleccionar un Tipo de Métrica",
"select-a-policy": "Seleccionar una Política",
"select-add-test-suite": "Seleccionar/Agregar Suite de Pruebas",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "Seleccionar Columnas para Excluir",
"select-column-plural-to-include": "Seleccionar Columnas para Incluir",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "Sélectionner un Type d'Indicateur",
"select-a-policy": "Sélectionner une Stratégie",
"select-add-test-suite": "Sélectionner/Ajouter un Ensemble de Tests",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "Sélectionner les Colonnes à Exclure",
"select-column-plural-to-include": "Sélectionner les Colonnes à Inclure",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "בחר סוג מטריקה",
"select-a-policy": "בחר מדיניות",
"select-add-test-suite": "בחר/הוסף יחידת בדיקה",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "בחר עמודות לא לכלול",
"select-column-plural-to-include": "בחר עמודות לכלול",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "メトリックのタイプを選択",
"select-a-policy": "ポリシーを選択",
"select-add-test-suite": "Select/Add Test Suite",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "除外するカラムを選択",
"select-column-plural-to-include": "含めるカラムを選択",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "Selecteer een type metriek",
"select-a-policy": "Selecteer een beleidsregel",
"select-add-test-suite": "Selecteer/voeg testsuite toe",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "Selecteer kolommen om uit te sluiten",
"select-column-plural-to-include": "Selecteer kolommen om op te nemen",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "Selecionar um Tipo de Métrica",
"select-a-policy": "Selecionar uma Política",
"select-add-test-suite": "Selecionar/Adicionar Conjunto de Testes",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "Selecionar Colunas para Excluir",
"select-column-plural-to-include": "Selecionar Colunas para Incluir",
"select-entity": "Select {{entity}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
"select-a-metric-type": "Выбрать тип показателя",
"select-a-policy": "Выбрать политику",
"select-add-test-suite": "Выбрать/добавить набор тестов",
"select-all-entity": "Select All {{entity}}",
"select-column-plural-to-exclude": "Выберите столбцы для исключения",
"select-column-plural-to-include": "Выберите столбцы для исключения",
"select-entity": "Select {{entity}}",
Expand Down
Loading

0 comments on commit 2e6ad18

Please sign in to comment.