chore: updating tests and making them work properly

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-08-09 11:21:16 +02:00
parent ab70dc33d7
commit 4bc224cc83
11 changed files with 32 additions and 7 deletions
@@ -49,6 +49,7 @@ describe('ApiBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -121,6 +122,7 @@ describe('ApiBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -40,6 +40,7 @@ describe('AppRootElementBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -23,7 +23,6 @@ import {
createExtension,
createExtensionInput,
} from '../wiring';
import { each } from 'lodash';
describe('AppRootWrapperBlueprint', () => {
it('should return an extension with sensible defaults', () => {
@@ -38,7 +37,7 @@ describe('AppRootWrapperBlueprint', () => {
"$$type": "@backstage/ExtensionDefinition",
"attachTo": {
"id": "app/root",
"input": "elements",
"input": "wrappers",
},
"configSchema": undefined,
"disabled": false,
@@ -50,6 +49,7 @@ describe('AppRootWrapperBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { ComponentType, PropsWithChildren } from 'react';
import { createExtensionBlueprint } from '../wiring';
@@ -20,7 +21,7 @@ import { createAppRootWrapperExtension } from './createAppRootWrapperExtension';
export const AppRootWrapperBlueprint = createExtensionBlueprint({
kind: 'app-root-wrapper',
attachTo: { id: 'app/root', input: 'elements' },
attachTo: { id: 'app/root', input: 'wrappers' },
output: [createAppRootWrapperExtension.componentDataRef],
dataRefs: {
component: createAppRootWrapperExtension.componentDataRef,
@@ -60,6 +60,7 @@ describe('NavItemBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -43,6 +43,7 @@ describe('NavLogoBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -76,6 +76,7 @@ describe('PageBlueprint', () => {
"toString": [Function],
},
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -52,6 +52,7 @@ describe('RouterBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { SignInPageBlueprint } from './SignInPageBlueprint';
import { createExtensionTester } from '@backstage/frontend-test-utils';
import { waitFor } from '@testing-library/react';
import { screen, waitFor } from '@testing-library/react';
import { coreExtensionData, createExtension } from '../wiring';
describe('SignInPageBlueprint', () => {
it('should create an extension with sensible defaults', () => {
@@ -41,6 +43,7 @@ describe('SignInPageBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -51,17 +54,29 @@ describe('SignInPageBlueprint', () => {
const MockSignInPage = () => <div data-testid="mock-sign-in" />;
const extension = SignInPageBlueprint.make({
name: 'test',
params: { loader: async () => () => <MockSignInPage /> },
});
const tester = createExtensionTester(extension);
expect(tester.data(SignInPageBlueprint.dataRefs.component)).toBeDefined();
const { getByTestId } = tester.render();
createExtensionTester(
createExtension({
name: 'dummy',
attachTo: { id: 'ignored', input: 'ignored' },
output: {
element: coreExtensionData.reactElement,
},
factory: () => ({ element: <div /> }),
}),
)
.add(extension)
.render();
// todo(blam): need a better way to test this, currently fails.
await waitFor(() => {
expect(getByTestId('mock-sign-in')).toBeInTheDocument();
expect(screen.getByTestId('mock-sign-in')).toBeInTheDocument();
});
});
});
@@ -44,6 +44,7 @@ describe('ThemeBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}
@@ -60,6 +60,7 @@ describe('TranslationBlueprint', () => {
"output": [
[Function],
],
"override": [Function],
"toString": [Function],
"version": "v2",
}