Skip to content

Commit

Permalink
fix: include maxwidth in settings schema (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia authored Apr 26, 2024
1 parent 2d74d26 commit 78352fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/services/item/fluent-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MAX_ITEM_NAME_LENGTH,
MAX_TARGETS_FOR_MODIFY_REQUEST,
MAX_TARGETS_FOR_READ_REQUEST,
MaxWidth,
PermissionLevel,
} from '@graasp/sdk';

Expand Down Expand Up @@ -35,7 +36,9 @@ const settings = S.object()
.prop('enableSaveActions', S.boolean())
// link settings
.prop('showLinkIframe', S.boolean())
.prop('showLinkButton', S.boolean());
.prop('showLinkButton', S.boolean())
// file settings
.prop('maxWidth', S.enum(Object.values(MaxWidth)));

export const partialMember = S.object()
.additionalProperties(false)
Expand Down
12 changes: 11 additions & 1 deletion src/services/item/plugins/file/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StatusCodes } from 'http-status-codes';
import path from 'path';
import { In } from 'typeorm';

import { HttpMethod, ItemType, PermissionLevel, S3FileItemExtra } from '@graasp/sdk';
import { HttpMethod, ItemType, MaxWidth, PermissionLevel, S3FileItemExtra } from '@graasp/sdk';

import build, { clearDatabase } from '../../../../../../test/app';
import { MULTIPLE_ITEMS_LOADING_TIME } from '../../../../../../test/constants';
Expand Down Expand Up @@ -498,6 +498,16 @@ describe('File Item routes tests', () => {
expect(response.json().extra[FILE_ITEM_TYPE].altText).toEqual('new name');
});

it('Edit file item maxWidth', async () => {
const response = await app.inject({
method: HttpMethod.Patch,
url: `${ITEMS_ROUTE_PREFIX}/${item.id}`,
payload: { settings: { maxWidth: MaxWidth.Small } },
});
console.log(response.json());
expect(response.json().settings.maxWidth).toEqual(MaxWidth.Small);
});

it('Cannot edit another file item field', async () => {
const response = await app.inject({
method: HttpMethod.Patch,
Expand Down

0 comments on commit 78352fb

Please sign in to comment.