diff --git a/projects/cdk/schematics/ng-update/v4/steps/constants/attrs-to-replace.ts b/projects/cdk/schematics/ng-update/v4/steps/constants/attrs-to-replace.ts index 0518e7a97e08..d343cfe08876 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/constants/attrs-to-replace.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/constants/attrs-to-replace.ts @@ -296,4 +296,13 @@ export const ATTRS_TO_REPLACE: ReplacementAttribute[] = [ attrName: '*ngFor', }, }, + { + from: { + attrName: 'tuiResizeable', + withTagNames: ['*'], + }, + to: { + attrName: 'tuiResizable', + }, + }, ]; diff --git a/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts b/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts index 2eac26d4eb7f..2b39f2407956 100644 --- a/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts +++ b/projects/cdk/schematics/ng-update/v4/steps/constants/identifiers-to-replace.ts @@ -2533,4 +2533,15 @@ export const IDENTIFIERS_TO_REPLACE: ReplacementIdentifierMulti[] = [ from: {name: 'TuiObscuredModule', moduleSpecifier: '@taiga-ui/cdk'}, to: {name: 'TuiObscured', moduleSpecifier: '@taiga-ui/cdk'}, }, + { + from: {name: 'TuiResizerModule', moduleSpecifier: '@taiga-ui/cdk'}, + to: [ + {name: 'TuiResizable', moduleSpecifier: '@taiga-ui/cdk'}, + {name: 'TuiResizer', moduleSpecifier: '@taiga-ui/cdk'}, + ], + }, + { + from: {name: 'TuiResizeableDirective', moduleSpecifier: '@taiga-ui/cdk'}, + to: {name: 'TuiResizable', moduleSpecifier: '@taiga-ui/cdk'}, + }, ]; diff --git a/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-resizer.spec.ts b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-resizer.spec.ts new file mode 100644 index 000000000000..0906f28af4be --- /dev/null +++ b/projects/cdk/schematics/ng-update/v4/tests/schematic-migrate-resizer.spec.ts @@ -0,0 +1,96 @@ +import {join} from 'node:path'; + +import {HostTree} from '@angular-devkit/schematics'; +import {SchematicTestRunner, UnitTestTree} from '@angular-devkit/schematics/testing'; +import type {TuiSchema} from '@taiga-ui/cdk/schematics/ng-add/schema'; +import { + createProject, + createSourceFile, + resetActiveProject, + saveActiveProject, + setActiveProject, +} from 'ng-morph'; + +import {createAngularJson} from '../../../utils/create-angular-json'; + +const collectionPath = join(__dirname, '../../../migration.json'); + +const COMPONENT_BEFORE = ` +import { TuiResizerModule, TuiResizeableDirective } from "@taiga-ui/cdk"; + +@Component({ + standalone: true, + templateUrl: './test.template.html', + imports: [TuiResizerModule] +}) +export class Test { + @ViewChild(TuiResizeableDirective, {static: true}) + private readonly resizable?: ElementRef; +}`; + +const COMPONENT_AFTER = ` +import { TuiResizable, TuiResizer } from "@taiga-ui/cdk"; + +@Component({ + standalone: true, + templateUrl: './test.template.html', + imports: [TuiResizable, TuiResizer] +}) +export class Test { + @ViewChild(TuiResizable, {static: true}) + private readonly resizable?: ElementRef; +}`; + +const TEMPLATE_BEFORE = ` +
+
+
+`; + +const TEMPLATE_AFTER = ` +
+
+
+`; + +describe('ng-update', () => { + let host: UnitTestTree; + let runner: SchematicTestRunner; + + beforeEach(() => { + host = new UnitTestTree(new HostTree()); + runner = new SchematicTestRunner('schematics', collectionPath); + + setActiveProject(createProject(host)); + + createMainFiles(); + + saveActiveProject(); + }); + + it('should migrate resizable references', async () => { + const tree = await runner.runSchematic( + 'updateToV4', + {'skip-logs': process.env['TUI_CI'] === 'true'} as Partial, + host, + ); + + expect(tree.readContent('test/app/test.template.html')).toEqual(TEMPLATE_AFTER); + expect(tree.readContent('test/app/test.component.ts')).toEqual(COMPONENT_AFTER); + }); + + afterEach(() => { + resetActiveProject(); + }); +}); + +function createMainFiles(): void { + createSourceFile('test/app/test.component.ts', COMPONENT_BEFORE); + createSourceFile('test/app/test.template.html', TEMPLATE_BEFORE); + + createAngularJson(); + createSourceFile( + 'package.json', + '{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/addon-commerce": "~3.42.0"}}', + ); +}