1- import { Shared } from '@strapi/strapi' ;
2- import { setupStrapi , stopStrapi } from '../../../../../../playground/tests/helpers' ;
1+ import { setupStrapi , stopStrapi } from '../../../../../playground/tests/helpers' ;
32import { disableContentType } from '../disable' ;
4- import { pluginId } from '../../../ util/pluginId' ;
3+ import { pluginId } from '../../util/pluginId' ;
54
65beforeAll ( async ( ) => {
76 await setupStrapi ( ) ;
@@ -14,29 +13,27 @@ afterAll(async () => {
1413describe ( 'Hooks' , ( ) => {
1514 describe ( 'Disable' , ( ) => {
1615 it ( 'Should delete all the entries for a content type when it is disabled' , async ( ) => {
17- const entry = await strapi . entityService . create ( " api::test.test" , {
16+ const entry = await strapi . documents ( ' api::test.test' ) . create ( {
1817 data : {
1918 title : 'Some amazing new page' ,
2019 } ,
21- populate : [ 'url_alias' ]
20+ populate : [ 'url_alias' ] ,
2221 } ) ;
2322
24- const urlAlias = entry . url_alias ;
23+ const urlAlias = entry . url_alias as { documentId : string , url_path : string } [ ] ;
2524 expect ( urlAlias ) . toBeDefined ( ) ;
26-
27- const id : number | string = urlAlias [ 0 ] . id ;
28- const urlPath : string | null = urlAlias . url_path ;
25+
26+ const { documentId, url_path : urlPath } = urlAlias [ 0 ] ;
2927 expect ( urlPath ) . not . toBeNull ( ) ;
3028
3129 const oldContentTypes = strapi . contentTypes ;
32- const contentTypes : Shared . ContentTypes = {
30+ const contentTypes = {
3331 ...oldContentTypes ,
3432 'api::test.test' : {
3533 ...oldContentTypes [ 'api::test.test' ] ,
3634 pluginOptions : {
3735 ...oldContentTypes [ 'api::test.test' ] . pluginOptions ,
3836 webtools : {
39- // @ts -expect-error - This is a test case and it should be able to set this to false
4037 enabled : false ,
4138 } ,
4239 } ,
@@ -47,8 +44,9 @@ describe('Hooks', () => {
4744 await disableContentType ( { oldContentTypes, contentTypes } ) ;
4845
4946 // The url alias should be deleted now
50- // @ts -expect-error - fix types for tests
51- const deletedEntry = await strapi . entityService . findOne ( `plugin::${ pluginId } .url-alias` , id ) ;
47+ const deletedEntry = await strapi . documents ( `plugin::${ pluginId } .url-alias` ) . findOne ( {
48+ documentId,
49+ } ) ;
5250 expect ( deletedEntry ) . toBeNull ( ) ;
5351 } ) ;
5452 } ) ;
0 commit comments