import React from 'react'; import { mocked } from 'jest-mock'; import { render, fireEvent, screen, findByRole as findByRoleInContainer } from '@testing-library/react'; import type { SerializedDocument } from '@atlassian/clientside-extensions-schema'; import useDiscovery from './debug/useDiscovery'; import type { ExtensionPointInfoProps } from './ExtensionPointInfo'; import ExtensionPointInfo from './ExtensionPointInfo'; jest.mock('./debug/useDiscovery'); const mockSchemaDocument: SerializedDocument = { objectTypes: { Schema: { name: 'Schema', description: '', descriptors: [ { description: 'Extension type', name: 'type', required: true, type: 'AvailableTypes!', }, { description: '', name: 'label', required: true, type: 'String!', }, { description: 'Glyph name', name: 'glyph', required: false, type: 'GlyphType', }, { description: 'Hidden flag to hide web-item', name: 'hidden', required: false, type: 'Boolean', }, { description: 'Callback triggered on user interaction with the Web-item. Signature depends on web-item type.', name: 'onAction', required: false, type: 'Function', }, ], }, FooInput: { name: 'FooInput', description: '', descriptors: [ { description: '', name: 'foo', required: true, type: 'String!', }, ], }, }, enumTypes: { GlyphType: { name: 'GlyphType', description: '', values: ['cross', 'tick'], }, }, unionTypes: { AvailableTypes: { name: 'AvailableTypes', description: '', types: ['ModalType', 'LinkType', 'ButtonType', 'PanelType'], }, }, scalars: { ModalType: { name: 'ModalType', description: 'The value must be the constant "modal".', }, LinkType: { name: 'LinkType', description: 'The value must be the constant "link".', }, ButtonType: { name: 'ButtonType', description: 'The value must be the constant "button".', }, PanelType: { name: 'PanelType', description: 'The value must be the constant "panel".', }, String: { name: 'String', description: 'The `String` type represents textual data.', }, Boolean: { name: 'Boolean', description: 'The `Boolean` type represents `true` or `false`.', }, Function: { name: 'Function', description: 'The `Function` type represents any javascript function.', }, }, }; const mockContextSchemaDocument: SerializedDocument = { objectTypes: { ContextSchema: { name: 'ContextSchema', description: '', descriptors: [ { description: '', name: 'value', required: false, type: 'Number', }, ], }, }, enumTypes: {}, unionTypes: {}, scalars: { Number: { name: 'Number', description: 'The value should be a number.', }, }, }; const findModalElement = () => screen.findByRole('dialog'); const findModalContentElement = async () => { const infoModalElm = await findModalElement(); return infoModalElm.querySelector('header + div'); }; const openModal = async (container: HTMLElement) => { const modalTriggerBtn = await findByRoleInContainer(container, 'button'); fireEvent.click(modalTriggerBtn); }; const TestComponent = ({ name, schemaDocuments }: ExtensionPointInfoProps) => { return ( <>
Test extension point