Fix/action 404 (#1157)

* fix: 404 response

* test: 200 response
This commit is contained in:
ChengLei Shao 2022-11-28 17:31:05 +08:00 committed by GitHub
parent 3be27c262f
commit f7f58bfe99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 4 deletions

View File

@ -85,6 +85,7 @@ describe('add action', () => {
values: [t1.get('id'), t2.get('id')],
});
expect(response.status).toEqual(200);
expect(await p1.countTags()).toEqual(2);
// add with through values

View File

@ -74,6 +74,7 @@ describe('destroy action', () => {
filterByTk: p1.get('id'),
});
expect(response.statusCode).toEqual(200);
expect(await Post.repository.count()).toEqual(0);
});
@ -142,10 +143,7 @@ describe('destroy action', () => {
const postProfile = await Profile.repository.findOne();
const response = await app
.agent()
.resource('posts.profile', p1.get('id'))
.destroy();
const response = await app.agent().resource('posts.profile', p1.get('id')).destroy();
expect(await Profile.repository.count()).toEqual(0);
});

View File

@ -85,6 +85,8 @@ describe('set action', () => {
values: [t1.get('id'), t2.get('id')],
});
expect(response.statusCode).toEqual(200);
expect(await p1.countTags()).toEqual(2);
// add with through values

View File

@ -84,6 +84,7 @@ describe('toggle action', () => {
.toggle({
values: [t1.get('id'), t2.get('id')],
});
expect(response.statusCode).toEqual(200);
expect(await p1.countTags()).toEqual(2);

View File

@ -104,6 +104,7 @@ describe('update action', () => {
content: 'c0',
},
});
expect(response.statusCode).toEqual(200);
await c1.reload();
expect(c1.get('content')).toEqual('c0');

View File

@ -10,5 +10,8 @@ export async function add(ctx: Context, next) {
}
await (<HasManyRepository | BelongsToManyRepository>repository).add(ctx.action.params.values);
ctx.status = 200;
await next();
}