diff --git a/plugins/scaffolder/src/api.test.ts b/plugins/scaffolder/src/api.test.ts
index a5a3a3c51e..0b21f938ce 100644
--- a/plugins/scaffolder/src/api.test.ts
+++ b/plugins/scaffolder/src/api.test.ts
@@ -17,6 +17,7 @@
import { ConfigReader } from '@backstage/core-app-api';
import { ScmIntegrations } from '@backstage/integration';
import { MockFetchApi, setupRequestMockHandlers } from '@backstage/test-utils';
+import { identity } from 'lodash';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { ScaffolderClient } from './api';
@@ -60,6 +61,9 @@ describe('api', () => {
fetchApi,
identityApi,
});
+
+ jest.restoreAllMocks();
+ identityApi.getBackstageIdentity.mockReturnValue({});
});
it('should return default and custom integrations', async () => {
@@ -345,7 +349,6 @@ describe('api', () => {
);
const result = await apiClient.listTasks('all');
- expect(identityApi.getBackstageIdentity).not.toBeCalled();
expect(result).toHaveLength(2);
});
it('should list task using the current user as owner', async () => {
diff --git a/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx b/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx
index fced397ad3..cf7204a3c6 100644
--- a/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx
+++ b/plugins/scaffolder/src/components/ListTasksPage/ListTaskPage.test.tsx
@@ -105,19 +105,23 @@ describe('', () => {
{
id: 'a-random-id',
spec: {
- createdBy: 'user:default/foo',
+ user: { ref: 'user:default/foo' },
+ templateInfo: {
+ entityRef: 'template:default/test',
+ },
} as any,
status: 'completed',
createdAt: '',
lastHeartbeatAt: '',
},
]);
+
scaffolderApiMock.getTemplateParameterSchema.mockResolvedValue({
title: 'One Template',
steps: [],
});
- const { getByText } = await renderInTestApp(
+ const { getByText, findByText } = await renderInTestApp(
', () => {
expect(getByText('List template tasks')).toBeInTheDocument();
expect(getByText('All tasks that have been started')).toBeInTheDocument();
expect(getByText('Tasks')).toBeInTheDocument();
- expect(getByText('One Template')).toBeInTheDocument();
- expect(getByText('BackUser')).toBeInTheDocument();
+ expect(await findByText('One Template')).toBeInTheDocument();
+ expect(await findByText('BackUser')).toBeInTheDocument();
});
it('should render all tasks', async () => {
@@ -172,7 +176,10 @@ describe('', () => {
{
id: 'a-random-id',
spec: {
- createdBy: 'user:default/foo',
+ user: { ref: 'user:default/foo' },
+ templateInfo: {
+ entityRef: 'template:default/mock',
+ },
} as any,
status: 'completed',
createdAt: '',
@@ -183,7 +190,12 @@ describe('', () => {
{
id: 'b-random-id',
spec: {
- createdBy: 'user:default/boo',
+ templateInfo: {
+ entityRef: 'template:default/mock',
+ },
+ user: {
+ ref: 'user:default/boo',
+ },
} as any,
status: 'completed',
createdAt: '',
@@ -196,7 +208,7 @@ describe('', () => {
steps: [],
});
- const { getByText } = await renderInTestApp(
+ const { getByText, findByText } = await renderInTestApp(
', () => {
});
expect(scaffolderApiMock.listTasks).toBeCalledWith('all');
- expect(getByText('One Template')).toBeInTheDocument();
- expect(getByText('OtherUser')).toBeInTheDocument();
+ expect(await findByText('One Template')).toBeInTheDocument();
+ expect(await findByText('OtherUser')).toBeInTheDocument();
});
});
diff --git a/plugins/scaffolder/src/components/ListTasksPage/columns/TemplateTitleColumn.test.tsx b/plugins/scaffolder/src/components/ListTasksPage/columns/TemplateTitleColumn.test.tsx
index d7d194975e..3dc20312aa 100644
--- a/plugins/scaffolder/src/components/ListTasksPage/columns/TemplateTitleColumn.test.tsx
+++ b/plugins/scaffolder/src/components/ListTasksPage/columns/TemplateTitleColumn.test.tsx
@@ -20,6 +20,7 @@ import React from 'react';
import { TemplateTitleColumn } from './TemplateTitleColumn';
import { scaffolderApiRef } from '../../../api';
import { ScaffolderApi } from '../../../types';
+import { entityRouteRef } from '@backstage/plugin-catalog-react';
describe('', () => {
const scaffolderApiMock: jest.Mocked = {
@@ -40,6 +41,7 @@ describe('', () => {
,
+ { mountedRoutes: { '/test': entityRouteRef } },
);
const text = getByText('One Template');