Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to activity type as a message for unrecognized activities #2828

Merged
merged 1 commit into from
Jul 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, screen, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import '@testing-library/jest-dom';

import { faker } from '@faker-js/faker';
import {
activityLogEntryFactory,
taggingMetadataFactory,
Expand Down Expand Up @@ -176,14 +177,19 @@ describe('ActivityLogDetailModal component', () => {
);

it('should render detail for unknown activity type', async () => {
const entry = activityLogEntryFactory.build({ type: 'foo_bar' });
const unknownActivityType = faker.lorem.word();
const entry = activityLogEntryFactory.build({ type: unknownActivityType });
await act(async () => {
render(<ActivityLogDetailModal open entry={toRenderedEntry(entry)} />);
});

expect(screen.getByText('foo_bar')).toBeVisible();
const activityReferences = screen.getAllByText(unknownActivityType);
expect(activityReferences).toHaveLength(2);
activityReferences.forEach((activityReference) => {
expect(activityReference).toBeVisible();
});

expect(screen.getByText('Unrecognized resource')).toBeVisible();
expect(screen.getByText('Unrecognized activity')).toBeVisible();
});

it('should call onClose when the close button is clicked', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const toMessage = (activityLogEntry) => {
case CLUSTER_CHECKS_EXECUTION_REQUEST:
return 'Checks execution requested for cluster';
default:
return 'Unrecognized activity';
return type;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ describe('Activity Log Overview', () => {
expectedUser: 'user-8',
expectedMessage: 'Checks execution requested for cluster',
},
{
name: 'unknown activity type',
entry: activityLogEntryFactory.build({
actor: 'user-9',
type: 'foo_bar',
}),
expectedUser: 'user-9',
expectedMessage: 'foo_bar',
},
];

it.each(scenarios)(
Expand Down
Loading