feat(editor): Make PDF and Audio binary-data viewable in the UI (#7367)
fixes #7361
This commit is contained in:
committed by
GitHub
parent
732b15a1fa
commit
8187be1b7d
@@ -6,30 +6,102 @@ import RunData from '@/components/RunData.vue';
|
||||
import { STORES, VIEWS } from '@/constants';
|
||||
import { SETTINGS_STORE_DEFAULT_STATE } from '@/__tests__/utils';
|
||||
import { createComponentRenderer } from '@/__tests__/render';
|
||||
|
||||
const renderComponent = createComponentRenderer(RunData, {
|
||||
props: {
|
||||
nodeUi: {
|
||||
name: 'Test Node',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
canPinData: true,
|
||||
};
|
||||
},
|
||||
global: {
|
||||
mocks: {
|
||||
$route: {
|
||||
name: VIEWS.WORKFLOW,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
import type { IRunDataDisplayMode } from '@/Interface';
|
||||
|
||||
describe('RunData', () => {
|
||||
it('should render data correctly even when "item.json" has another "json" key', async () => {
|
||||
const { html, getByText, getAllByTestId, getByTestId } = renderComponent({
|
||||
const { getByText, getAllByTestId, getByTestId } = render(
|
||||
[
|
||||
{
|
||||
json: {
|
||||
id: 1,
|
||||
name: 'Test 1',
|
||||
json: {
|
||||
data: 'Json data 1',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
json: {
|
||||
id: 2,
|
||||
name: 'Test 2',
|
||||
json: {
|
||||
data: 'Json data 2',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
'schema',
|
||||
);
|
||||
|
||||
await userEvent.click(getByTestId('ndv-pin-data'));
|
||||
await waitFor(() => getAllByTestId('run-data-schema-item'), { timeout: 1000 });
|
||||
expect(getByText('Test 1')).toBeInTheDocument();
|
||||
expect(getByText('Json data 1')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render view and download buttons for PDFs', async () => {
|
||||
const { getByTestId } = render(
|
||||
[
|
||||
{
|
||||
json: {},
|
||||
binary: {
|
||||
data: {
|
||||
fileName: 'test.pdf',
|
||||
fileType: 'pdf',
|
||||
mimeType: 'application/pdf',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
'binary',
|
||||
);
|
||||
expect(getByTestId('ndv-view-binary-data')).toBeInTheDocument();
|
||||
expect(getByTestId('ndv-download-binary-data')).toBeInTheDocument();
|
||||
expect(getByTestId('ndv-binary-data_0')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not render a view button for unknown content-type', async () => {
|
||||
const { getByTestId, queryByTestId } = render(
|
||||
[
|
||||
{
|
||||
json: {},
|
||||
binary: {
|
||||
data: {
|
||||
fileName: 'test.xyz',
|
||||
mimeType: 'application/octet-stream',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
'binary',
|
||||
);
|
||||
expect(queryByTestId('ndv-view-binary-data')).not.toBeInTheDocument();
|
||||
expect(getByTestId('ndv-download-binary-data')).toBeInTheDocument();
|
||||
expect(getByTestId('ndv-binary-data_0')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const render = (outputData: unknown[], displayMode: IRunDataDisplayMode) =>
|
||||
createComponentRenderer(RunData, {
|
||||
props: {
|
||||
nodeUi: {
|
||||
name: 'Test Node',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
canPinData: true,
|
||||
showData: true,
|
||||
};
|
||||
},
|
||||
global: {
|
||||
mocks: {
|
||||
$route: {
|
||||
name: VIEWS.WORKFLOW,
|
||||
},
|
||||
},
|
||||
},
|
||||
})({
|
||||
props: {
|
||||
nodeUi: {
|
||||
id: '1',
|
||||
@@ -49,7 +121,7 @@ describe('RunData', () => {
|
||||
},
|
||||
[STORES.NDV]: {
|
||||
output: {
|
||||
displayMode: 'schema',
|
||||
displayMode,
|
||||
},
|
||||
activeNodeName: 'Test Node',
|
||||
},
|
||||
@@ -89,28 +161,7 @@ describe('RunData', () => {
|
||||
startTime: new Date().getTime(),
|
||||
executionTime: new Date().getTime(),
|
||||
data: {
|
||||
main: [
|
||||
[
|
||||
{
|
||||
json: {
|
||||
id: 1,
|
||||
name: 'Test 1',
|
||||
json: {
|
||||
data: 'Json data 1',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
json: {
|
||||
id: 2,
|
||||
name: 'Test 2',
|
||||
json: {
|
||||
data: 'Json data 2',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
main: [outputData],
|
||||
},
|
||||
source: [null],
|
||||
},
|
||||
@@ -123,10 +174,4 @@ describe('RunData', () => {
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
await userEvent.click(getByTestId('ndv-pin-data'));
|
||||
await waitFor(() => getAllByTestId('run-data-schema-item'), { timeout: 1000 });
|
||||
expect(getByText('Test 1')).toBeInTheDocument();
|
||||
expect(getByText('Json data 1')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user