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

fix: Table does not instanceIdentifier for the reported task name in … #3310

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
33 changes: 33 additions & 0 deletions src/table/__tests__/analytics-events.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';
import { render } from '@testing-library/react';

import Header from '../../../lib/components/header';
import { ComponentMetrics, setComponentMetrics } from '../../../lib/components/internal/analytics';
import Table from '../../../lib/components/table';

const componentMounted = jest.fn();
const componentUpdated = jest.fn();

setComponentMetrics({ componentMounted, componentUpdated });

describe('Task name', () => {
test('instanceIdentifier overrides the automatically determined task name', () => {
render(
<Table
analyticsMetadata={{ instanceIdentifier: 'My custom task name override' }}
items={[]}
columnDefinitions={[]}
header={<Header>This is the table header</Header>}
/>
);

expect(ComponentMetrics.componentMounted).toHaveBeenCalledTimes(1);
expect(ComponentMetrics.componentMounted).toHaveBeenCalledWith(
expect.objectContaining({
componentConfiguration: expect.objectContaining({ taskName: 'My custom task name override' }),
})
);
});
});
2 changes: 1 addition & 1 deletion src/table/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const InternalTable = React.forwardRef(
variant,
flowType: rest.analyticsMetadata?.flowType,
instanceIdentifier: analyticsMetadata?.instanceIdentifier,
taskName: getHeaderText(),
taskName: analyticsMetadata?.instanceIdentifier ?? getHeaderText(),
patternIdentifier: getPatternIdentifier(),
sortedBy: {
columnId: sortingColumn?.sortingField,
Expand Down
Loading