diff --git a/superset-frontend/src/views/CRUD/alert/AlertReportModal.test.tsx b/superset-frontend/src/views/CRUD/alert/AlertReportModal.test.tsx new file mode 100644 index 000000000000..8eeea3d45bcd --- /dev/null +++ b/superset-frontend/src/views/CRUD/alert/AlertReportModal.test.tsx @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import userEvent from '@testing-library/user-event'; +import AlertReportModal from 'src/views/CRUD/alert/AlertReportModal'; + +test('allows change to None in log retention', async () => { + render(, { useRedux: true }); + // open the log retention select + userEvent.click(screen.getByText('90 days')); + // change it to 30 days + userEvent.click(await screen.findByText('30 days')); + // open again + userEvent.click(screen.getAllByText('30 days')[0]); + // change it to None + userEvent.click(await screen.findByText('None')); + // get the selected item + const selectedItem = await waitFor(() => + screen + .getAllByLabelText('Log retention')[0] + .querySelector('.ant-select-selection-item'), + ); + // check if None is selected + expect(selectedItem).toHaveTextContent('None'); +}); diff --git a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx index 7ec6521f856f..8ad693ebdf59 100644 --- a/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx +++ b/superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx @@ -1223,7 +1223,11 @@ const AlertReportModal: FunctionComponent = ({ ariaLabel={t('Log retention')} placeholder={t('Log retention')} onChange={onLogRetentionChange} - value={currentAlert?.log_retention || DEFAULT_RETENTION} + value={ + typeof currentAlert?.log_retention === 'number' + ? currentAlert?.log_retention + : DEFAULT_RETENTION + } options={RETENTION_OPTIONS} sortComparator={propertyComparator('value')} />