adding success alert message for topic deletion (#2094)
This commit is contained in:
parent
a211c41207
commit
9eae6b1f0a
2 changed files with 29 additions and 14 deletions
|
@ -368,7 +368,16 @@ describe('topics Slice', () => {
|
|||
describe('Thunks', () => {
|
||||
const store = mockStoreCreator;
|
||||
const topicName = topic.name;
|
||||
const RealDate = Date.now;
|
||||
|
||||
beforeAll(() => {
|
||||
global.Date.now = jest.fn(() =>
|
||||
new Date('2019-04-07T10:20:30Z').getTime()
|
||||
);
|
||||
});
|
||||
afterAll(() => {
|
||||
global.Date.now = RealDate;
|
||||
});
|
||||
afterEach(() => {
|
||||
fetchMock.restore();
|
||||
store.clearActions();
|
||||
|
@ -495,6 +504,18 @@ describe('topics Slice', () => {
|
|||
|
||||
expect(getTypeAndPayload(store)).toEqual([
|
||||
{ type: deleteTopic.pending.type },
|
||||
{ type: showSuccessAlert.pending.type },
|
||||
{
|
||||
type: alertAdded.type,
|
||||
payload: {
|
||||
id: 'message-topic-local',
|
||||
title: '',
|
||||
type: 'success',
|
||||
createdAt: global.Date.now(),
|
||||
message: 'Topic successfully deleted!',
|
||||
},
|
||||
},
|
||||
{ type: showSuccessAlert.fulfilled.type },
|
||||
{
|
||||
type: deleteTopic.fulfilled.type,
|
||||
payload: { topicName },
|
||||
|
@ -662,17 +683,6 @@ describe('topics Slice', () => {
|
|||
});
|
||||
});
|
||||
describe('updateTopicPartitionsCount', () => {
|
||||
const RealDate = Date.now;
|
||||
|
||||
beforeAll(() => {
|
||||
global.Date.now = jest.fn(() =>
|
||||
new Date('2019-04-07T10:20:30Z').getTime()
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
global.Date.now = RealDate;
|
||||
});
|
||||
it('updateTopicPartitionsCount/fulfilled', async () => {
|
||||
fetchMock.patchOnce(
|
||||
`/api/clusters/${clusterName}/topics/${topicName}/partitions`,
|
||||
|
|
|
@ -201,11 +201,16 @@ export const updateTopic = createAsyncThunk<
|
|||
export const deleteTopic = createAsyncThunk<
|
||||
{ topicName: TopicName },
|
||||
DeleteTopicRequest
|
||||
>('topic/deleteTopic', async (payload, { rejectWithValue }) => {
|
||||
>('topic/deleteTopic', async (payload, { rejectWithValue, dispatch }) => {
|
||||
try {
|
||||
const { topicName } = payload;
|
||||
const { topicName, clusterName } = payload;
|
||||
await topicsApiClient.deleteTopic(payload);
|
||||
|
||||
dispatch(
|
||||
showSuccessAlert({
|
||||
id: `message-${topicName}-${clusterName}`,
|
||||
message: 'Topic successfully deleted!',
|
||||
})
|
||||
);
|
||||
return { topicName };
|
||||
} catch (err) {
|
||||
return rejectWithValue(await getResponse(err as Response));
|
||||
|
|
Loading…
Add table
Reference in a new issue