Skip to content

Commit

Permalink
fixes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
arjankowski committed Apr 30, 2024
1 parent 4517893 commit 56b5896
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions tests/integration_test/__tests__/metadata.test.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,68 @@
'use strict';

const { getAppClient } = require('../context');
const { createBoxTestFolder } = require('../objects/box-test-folder');
const { createBoxTestFile } = require('../objects/box-test-file');
const {getAppClient} = require('../context');
const {createBoxTestFolder} = require('../objects/box-test-folder');
const {createBoxTestFile} = require('../objects/box-test-file');
const utils = require('../lib/utils');
const path = require('path');
const context = {};

beforeAll(async () => {
beforeAll(async() => {
context.appClient = await getAppClient();
let folder = await createBoxTestFolder(context.appClient);
context.folder = folder;
});

afterAll(async () => {
afterAll(async() => {
await context.folder.dispose();
context.folder = null;
});

test('test metadata search', async () => {
test('test metadata search', async() => {
const templateKey = `template_${utils.randomName()}`;
const fields = [
{
type: 'float',
key: 'testFloatValue',
displayName: 'testFloatValue'
}
displayName: 'testFloatValue',
},
];

const metadataTemplate = await context.appClient.metadata.createTemplate(templateKey, fields, {
scope: 'enterprise',
templateKey: templateKey
templateKey,
});

expect(metadataTemplate.id).toBeDefined();
expect(metadataTemplate.templateKey).toBe(templateKey);
expect(metadataTemplate.displayName).toBe(templateKey);
try {
expect(metadataTemplate.id).toBeDefined();
expect(metadataTemplate.templateKey).toBe(templateKey);
expect(metadataTemplate.displayName).toBe(templateKey);
const file = await createBoxTestFile(context.appClient, path.join(__dirname, '../resources/blank.pdf'), 'blank_sign_1.pdf', context.folder.id);
try {
const metadata = await context.appClient.files.addMetadata(file.id, 'enterprise', templateKey, { testFloatValue: 150 });
const metadata = await context.appClient.files.addMetadata(file.id, 'enterprise', templateKey, {testFloatValue: 150});
expect(metadata.$template).toBe(templateKey);
expect(metadata.testFloatValue).toBe(150);

const searchForm = `${metadataTemplate.scope}.${metadataTemplate.templateKey}`;
const ancestorFolderId = '0';
const queryOptions = {
query: 'testFloatValue >= :arg',
query_params: { arg: '100' },
query_params: {arg: '100'},
limit: 1,
order_by: [
{
'field_key': 'testFloatValue',
'direction': 'asc'
}
]
field_key: 'testFloatValue',
direction: 'asc',
},
],
};
const searchResults = await context.appClient.metadata.query(searchForm, ancestorFolderId, queryOptions);
expect(searchResults.entries.length).toBe(1);
expect(searchResults.entries[0].name).toBe(file.name);


} finally {
expect(searchResults.entries.length).toBeGreaterThanOrEqual(1);
}
finally {
await file.dispose();
}
} finally {
}
finally {
await context.appClient.metadata.deleteTemplate('enterprise', metadataTemplate.templateKey);
}
}, 120000);
Expand Down

0 comments on commit 56b5896

Please sign in to comment.