mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
console: fixes incorrect data type shown in GDC modify tab
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8180 GitOrigin-RevId: 0b4272f7161759541b28ae04bf0a517fb9e42823
This commit is contained in:
parent
8064d6fe2b
commit
aa39203e13
@ -1,15 +1,11 @@
|
|||||||
// Button.stories.ts|tsx
|
// Button.stories.ts|tsx
|
||||||
|
import { userEvent, waitFor, within } from '@storybook/testing-library';
|
||||||
|
import { expect } from '@storybook/jest';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ReactQueryDecorator } from '../../../storybook/decorators/react-query';
|
import { ReactQueryDecorator } from '../../../storybook/decorators/react-query';
|
||||||
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
||||||
import { ModifyTable } from './ModifyTable';
|
import { ModifyTable } from './ModifyTable';
|
||||||
|
import { handlers } from './mock/handlers';
|
||||||
const props = {
|
|
||||||
table: ['Customer'],
|
|
||||||
dataSourceName: 'music_db',
|
|
||||||
tableName: 'Customer',
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
/* 👇 The title prop is optional.
|
/* 👇 The title prop is optional.
|
||||||
@ -17,9 +13,43 @@ export default {
|
|||||||
* to learn how to generate automatic titles
|
* to learn how to generate automatic titles
|
||||||
*/
|
*/
|
||||||
component: ModifyTable,
|
component: ModifyTable,
|
||||||
|
|
||||||
decorators: [ReactQueryDecorator()],
|
decorators: [ReactQueryDecorator()],
|
||||||
} as ComponentMeta<typeof ModifyTable>;
|
} as ComponentMeta<typeof ModifyTable>;
|
||||||
|
|
||||||
export const Primary: ComponentStory<typeof ModifyTable> = () => (
|
export const Primary: ComponentStory<typeof ModifyTable> = args => (
|
||||||
<ModifyTable {...props} />
|
<ModifyTable {...args} />
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Primary.args = {
|
||||||
|
table: ['Customer'],
|
||||||
|
dataSourceName: 'sqlite',
|
||||||
|
tableName: 'Customer',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TestData = Primary.bind({});
|
||||||
|
|
||||||
|
TestData.args = {
|
||||||
|
table: ['Customer'],
|
||||||
|
dataSourceName: 'sqlite',
|
||||||
|
tableName: 'Customer',
|
||||||
|
};
|
||||||
|
|
||||||
|
TestData.parameters = {
|
||||||
|
msw: {
|
||||||
|
handlers: handlers(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
TestData.play = async ({ canvasElement }) => {
|
||||||
|
const c = within(canvasElement);
|
||||||
|
const dataTypeBadge = await c.findByTestId(
|
||||||
|
`CustomerId-ui-data-type`,
|
||||||
|
{},
|
||||||
|
{ timeout: 3000 }
|
||||||
|
);
|
||||||
|
const hiddenDataInput = await c.findByTestId('CustomerId-data');
|
||||||
|
const correctDataType = await hiddenDataInput.dataset['dataType'];
|
||||||
|
await expect(correctDataType).toBeTruthy();
|
||||||
|
await expect(dataTypeBadge).toHaveTextContent(correctDataType as string);
|
||||||
|
};
|
||||||
|
@ -10,6 +10,13 @@ export const TableColumnDescription: React.VFC<{
|
|||||||
}> = ({ column, onEdit }) => {
|
}> = ({ column, onEdit }) => {
|
||||||
return (
|
return (
|
||||||
<div key={column.name} className="flex gap-4 items-center mb-2">
|
<div key={column.name} className="flex gap-4 items-center mb-2">
|
||||||
|
{/* To assist with tests */}
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
data-data-type={column.dataType?.toLowerCase()}
|
||||||
|
data-console-data-type={column.consoleDataType}
|
||||||
|
data-testid={`${column.name}-data`}
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -37,7 +44,9 @@ export const TableColumnDescription: React.VFC<{
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Badge color="gray">
|
<Badge color="gray">
|
||||||
{column.consoleDataType || column.dataType || 'unknown type'}
|
<span data-testid={`${column.name}-ui-data-type`}>
|
||||||
|
{column.dataType?.toLowerCase() || 'Unknown'}
|
||||||
|
</span>
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
|||||||
|
import { rest } from 'msw';
|
||||||
|
import { introspection, mockMetadata, tableInfo } from './data';
|
||||||
|
|
||||||
|
export const handlers = () => [
|
||||||
|
rest.post(`http://localhost:8080/v1/metadata`, async (req, res, ctx) => {
|
||||||
|
const body = (await req.json()) as Record<string, any>;
|
||||||
|
|
||||||
|
switch (body.type) {
|
||||||
|
case 'export_metadata':
|
||||||
|
return res(ctx.json(mockMetadata));
|
||||||
|
case 'get_table_info':
|
||||||
|
return res(ctx.json(tableInfo));
|
||||||
|
default:
|
||||||
|
return res(ctx.json({}));
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
rest.post(`http://localhost:8080/v1/graphql`, async (req, res, ctx) => {
|
||||||
|
return res(ctx.json(introspection));
|
||||||
|
}),
|
||||||
|
];
|
Loading…
Reference in New Issue
Block a user