|
@@ -1,3 +1,4 @@
|
|
|
|
+import { faker } from '@faker-js/faker';
|
|
import React from 'react';
|
|
import React from 'react';
|
|
import { render, screen, waitFor } from '../../../../../../tests/test-utils';
|
|
import { render, screen, waitFor } from '../../../../../../tests/test-utils';
|
|
import { AppWithInfo } from '../../../../core/types';
|
|
import { AppWithInfo } from '../../../../core/types';
|
|
@@ -9,7 +10,7 @@ import { AppDetailsPage } from './AppDetailsPage';
|
|
describe('AppDetailsPage', () => {
|
|
describe('AppDetailsPage', () => {
|
|
it('should render', async () => {
|
|
it('should render', async () => {
|
|
// Arrange
|
|
// Arrange
|
|
- render(<AppDetailsPage appId="nothing" />);
|
|
|
|
|
|
+ render(<AppDetailsPage appId="nothing" refTitle="" refSlug="" />);
|
|
|
|
|
|
// Assert
|
|
// Assert
|
|
await waitFor(() => {
|
|
await waitFor(() => {
|
|
@@ -17,22 +18,6 @@ describe('AppDetailsPage', () => {
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
- it('should correctly pass the appId to the AppDetailsContainer', async () => {
|
|
|
|
- // Arrange
|
|
|
|
- const props = AppDetailsPage.getInitialProps?.({ query: { id: 'random' } } as any);
|
|
|
|
-
|
|
|
|
- // Assert
|
|
|
|
- expect(props).toHaveProperty('appId', 'random');
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- it('should transform the appId to a string', async () => {
|
|
|
|
- // Arrange
|
|
|
|
- const props = AppDetailsPage.getInitialProps?.({ query: { id: [123] } } as any);
|
|
|
|
-
|
|
|
|
- // Assert
|
|
|
|
- expect(props).toHaveProperty('appId', '123');
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
it('should set the breadcrumb prop of the Layout component to an array containing two elements with the correct name and href properties', async () => {
|
|
it('should set the breadcrumb prop of the Layout component to an array containing two elements with the correct name and href properties', async () => {
|
|
// Arrange
|
|
// Arrange
|
|
const app = createAppEntity({}) as AppWithInfo;
|
|
const app = createAppEntity({}) as AppWithInfo;
|
|
@@ -42,7 +27,11 @@ describe('AppDetailsPage', () => {
|
|
response: app,
|
|
response: app,
|
|
}),
|
|
}),
|
|
);
|
|
);
|
|
- render(<AppDetailsPage appId={app.id} />);
|
|
|
|
|
|
+
|
|
|
|
+ const testSlug = faker.lorem.slug();
|
|
|
|
+ const testTitle = faker.lorem.sentence();
|
|
|
|
+
|
|
|
|
+ render(<AppDetailsPage appId={app.id} refSlug={testSlug} refTitle={testTitle} />);
|
|
await waitFor(() => {
|
|
await waitFor(() => {
|
|
expect(screen.getByTestId('app-details')).toBeInTheDocument();
|
|
expect(screen.getByTestId('app-details')).toBeInTheDocument();
|
|
});
|
|
});
|
|
@@ -52,10 +41,10 @@ describe('AppDetailsPage', () => {
|
|
const breadcrumbsLinks = await screen.findAllByTestId('breadcrumb-link');
|
|
const breadcrumbsLinks = await screen.findAllByTestId('breadcrumb-link');
|
|
|
|
|
|
// Assert
|
|
// Assert
|
|
- expect(breadcrumbs[0]).toHaveTextContent('Apps');
|
|
|
|
- expect(breadcrumbsLinks[0]).toHaveAttribute('href', '/apps');
|
|
|
|
|
|
+ expect(breadcrumbs[0]).toHaveTextContent(testTitle);
|
|
|
|
+ expect(breadcrumbsLinks[0]).toHaveAttribute('href', `/${testSlug}`);
|
|
|
|
|
|
expect(breadcrumbs[1]).toHaveTextContent(app.info.name);
|
|
expect(breadcrumbs[1]).toHaveTextContent(app.info.name);
|
|
- expect(breadcrumbsLinks[1]).toHaveAttribute('href', `/apps/${app.id}`);
|
|
|
|
|
|
+ expect(breadcrumbsLinks[1]).toHaveAttribute('href', `/${testSlug}/${app.id}`);
|
|
});
|
|
});
|
|
});
|
|
});
|