implement analytics too

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2024-10-08 17:51:14 +02:00
parent 40bfc240c7
commit 811ff0cddc
23 changed files with 196 additions and 153 deletions
+5 -9
View File
@@ -20,11 +20,7 @@ import { renderHook, act, waitFor } from '@testing-library/react';
import { ThemeProvider } from '@material-ui/core/styles';
import { lightTheme } from '@backstage/theme';
import {
MockAnalyticsApi,
mockApis,
TestApiProvider,
} from '@backstage/test-utils';
import { mockApis, TestApiProvider } from '@backstage/test-utils';
import { Entity, CompoundEntityRef } from '@backstage/catalog-model';
import {
analyticsApiRef,
@@ -66,7 +62,7 @@ const techdocsApiMock = {
getTechDocsMetadata: jest.fn().mockResolvedValue(mockTechDocsMetadata),
};
const analyticsApiMock = new MockAnalyticsApi();
const analyticsApiMock = mockApis.analytics();
const wrapper = ({
entityRef = {
@@ -170,12 +166,12 @@ describe('useTechDocsReaderPage', () => {
wrapper,
});
await waitFor(() => {
expect(analyticsApiMock.getEvents()[0]).toMatchObject({
expect(analyticsApiMock.captureEvent).toHaveBeenCalledWith({
action: 'action',
subject: 'subject',
context: {
context: expect.objectContaining({
entityRef: 'component:default/test',
},
}),
});
});
});