Skip to content

Commit

Permalink
fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Oct 6, 2022
1 parent a2e2002 commit db890cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
24 changes: 14 additions & 10 deletions tests/api-tests/access-control/mutations-list-item.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import { apiTestConfig, expectAccessDenied, expectAccessReturnError } from '../u
const runner = setupTestRunner({
config: apiTestConfig({
lists: {
// Item access control
User: list({
access: {
operation: allowAll,
filter: () => {
return {
filter: {
query: () => ({
name: { not: { equals: 'hidden' } },
};
}),
update: () => ({
name: { not: { equals: 'hidden' } },
}),
delete: () => ({
name: { not: { equals: 'hidden' } },
}),
},
item: {
create: ({ inputData }) => {
Expand All @@ -34,18 +39,17 @@ const runner = setupTestRunner({
}),
BadAccess: list({
access: {
operation: allowAll,
// intentionally returns filters for testing purposes
item: {
// @ts-ignore Intentionally return a filter for testing purposes
create: () => {
return { name: { not: { equals: 'bad' } } };
return { name: { not: { equals: 'bad' } } } as any;
},
// @ts-ignore Intentionally return a filter for testing purposes
update: () => {
return { name: { not: { equals: 'bad' } } };
return { name: { not: { equals: 'bad' } } } as any;
},
// @ts-ignore Intentionally return a filter for testing purposes
delete: async () => {
return { name: { not: { startsWtih: 'no delete' } } };
return { name: { not: { startsWtih: 'no delete' } } } as any;
},
},
},
Expand Down
16 changes: 6 additions & 10 deletions tests/api-tests/queries/filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ const runner = setupTestRunner({
filterTrue: integer({ isFilterable: true }),
filterFunctionFalse: integer({ isFilterable: () => false }),
filterFunctionTrue: integer({ isFilterable: () => true }),
// @ts-ignore
filterFunctionOtherFalsey: integer({ isFilterable: () => null }),
// @ts-ignore
filterFunctionOtherTruthy: integer({ isFilterable: () => ({}) }),
filterFunctionOtherFalsey: integer({ isFilterable: () => null } as any), // as any for tests
filterFunctionOtherTruthy: integer({ isFilterable: () => ({}) } as any), // as any for tests
},
}),
SecondaryList: list({
Expand All @@ -53,9 +51,9 @@ const runner = setupTestRunner({
defaultIsFilterable: false,
}),
DefaultFilterTrue: list({
access: allowAll,
fields: { a: integer(), b: integer({ isFilterable: true }) },
// @ts-ignore
defaultIsFilterable: true,
defaultIsFilterable: true as any, // not actually allowed
}),
DefaultFilterFunctionFalse: list({
access: allowAll,
Expand All @@ -70,14 +68,12 @@ const runner = setupTestRunner({
DefaultFilterFunctionFalsey: list({
access: allowAll,
fields: { a: integer(), b: integer({ isFilterable: true }) },
// @ts-ignore
defaultIsFilterable: () => null,
defaultIsFilterable: (() => null) as any, // not actually allowed
}),
DefaultFilterFunctionTruthy: list({
access: allowAll,
fields: { a: integer(), b: integer({ isFilterable: true }) },
// @ts-ignore
defaultIsFilterable: () => ({}),
defaultIsFilterable: () => ({} as any), // not actually allowed
}),
},
}),
Expand Down

0 comments on commit db890cd

Please sign in to comment.