mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
test: update ng-update integration test to test v13 migrations (#44016)
Updates the `ng-update` migration integration test to run against v13 migrations. We have removed all older migrations so this integration test needs to be updated. PR Close #44016
This commit is contained in:
parent
78569f088e
commit
8cbc0e9d0e
12 changed files with 3567 additions and 5273 deletions
|
|
@ -1,20 +1 @@
|
|||
<!--The content below is only a placeholder and can be replaced.-->
|
||||
<div style="text-align:center">
|
||||
<h1>
|
||||
Welcome to {{ title }}!
|
||||
</h1>
|
||||
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
|
||||
</div>
|
||||
<h2>Here are some links to help you start: </h2>
|
||||
<ul>
|
||||
<li>
|
||||
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<button [routerLink]=""></button>
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<button [routerLink]="[]"></button>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
import {Component, NgModule} from '@angular/core';
|
||||
import {NG_ASYNC_VALIDATORS} from '@angular/forms';
|
||||
|
||||
export const hostBindings = {
|
||||
class: 'test-base-comp',
|
||||
};
|
||||
|
||||
const nonExportedStyleUrlsVar = ['./base-component.css'];
|
||||
|
||||
@Component({
|
||||
selector: 'base-comp',
|
||||
template: `
|
||||
<span>This is the template.</span>
|
||||
`,
|
||||
host: hostBindings,
|
||||
styleUrls: nonExportedStyleUrlsVar,
|
||||
providers: [
|
||||
{provide: NG_ASYNC_VALIDATORS, useValue: null},
|
||||
]
|
||||
})
|
||||
export class BaseComponentFromOtherFile {}
|
||||
|
||||
@NgModule({declarations: [BaseComponentFromOtherFile]})
|
||||
export class BaseComponentModule {}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
import {Component, Directive, NgModule, NgZone, Injectable} from '@angular/core';
|
||||
|
||||
export class ComponentTypeProvider {}
|
||||
export class ComponentDontNeedCase {}
|
||||
export class ComponentProvider {}
|
||||
export class ComponentProvider2 {}
|
||||
|
||||
@Component({
|
||||
template: '',
|
||||
viewProviders: [ComponentTypeProvider, [
|
||||
{provide: ComponentDontNeedCase, useClass: ComponentProvider}]
|
||||
],
|
||||
providers: [ComponentProvider2]
|
||||
})
|
||||
export class ProvidersTestComponent {}
|
||||
|
||||
export class DirectiveTypeProvider {}
|
||||
export class DirectiveDontNeedCase {}
|
||||
export class DirectiveProvider {}
|
||||
|
||||
@Directive({
|
||||
selector: 'test-dir',
|
||||
providers: [DirectiveTypeProvider, [
|
||||
{provide: DirectiveDontNeedCase, useClass: DirectiveProvider}]
|
||||
],
|
||||
})
|
||||
export class ProvidersTestDirective {}
|
||||
|
||||
export class TypeCase {}
|
||||
|
||||
@Injectable()
|
||||
class BaseProviderCase {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
|
||||
export class EmptyProviderLiteralCase {}
|
||||
|
||||
export class ProviderClass extends BaseProviderCase {}
|
||||
|
||||
export class DontNeedCase {}
|
||||
|
||||
@Directive()
|
||||
export class DirectiveCase {}
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
TypeCase,
|
||||
{provide: EmptyProviderLiteralCase},
|
||||
{provide: DontNeedCase, useValue: 0},
|
||||
{provide: DontNeedCase, useFactory: () => null},
|
||||
{provide: DontNeedCase, useExisting: TypeCase},
|
||||
{provide: DontNeedCase, useClass: ProviderClass},
|
||||
DirectiveCase,
|
||||
],
|
||||
declarations: [ProvidersTestDirective, ProvidersTestComponent],
|
||||
})
|
||||
export class ProvidersTestModule {}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
import {Component, Directive, NgModule, NgZone, Injectable} from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class ComponentTypeProvider {}
|
||||
export class ComponentDontNeedCase {}
|
||||
@Injectable()
|
||||
export class ComponentProvider {}
|
||||
@Injectable()
|
||||
export class ComponentProvider2 {}
|
||||
|
||||
@Component({
|
||||
template: '',
|
||||
viewProviders: [ComponentTypeProvider, [
|
||||
{provide: ComponentDontNeedCase, useClass: ComponentProvider}]
|
||||
],
|
||||
providers: [ComponentProvider2]
|
||||
})
|
||||
export class ProvidersTestComponent {}
|
||||
|
||||
@Injectable()
|
||||
export class DirectiveTypeProvider {}
|
||||
export class DirectiveDontNeedCase {}
|
||||
@Injectable()
|
||||
export class DirectiveProvider {}
|
||||
|
||||
@Directive({
|
||||
selector: 'test-dir',
|
||||
providers: [DirectiveTypeProvider, [
|
||||
{provide: DirectiveDontNeedCase, useClass: DirectiveProvider}]
|
||||
],
|
||||
})
|
||||
export class ProvidersTestDirective {}
|
||||
|
||||
@Injectable()
|
||||
export class TypeCase {}
|
||||
|
||||
@Injectable()
|
||||
class BaseProviderCase {
|
||||
constructor(zone: NgZone) {}
|
||||
}
|
||||
|
||||
export class EmptyProviderLiteralCase {}
|
||||
|
||||
@Injectable()
|
||||
export class ProviderClass extends BaseProviderCase {}
|
||||
|
||||
export class DontNeedCase {}
|
||||
|
||||
@Directive()
|
||||
export class DirectiveCase {}
|
||||
|
||||
@NgModule({
|
||||
providers: [
|
||||
TypeCase,
|
||||
{ provide: EmptyProviderLiteralCase, useValue: undefined },
|
||||
{provide: DontNeedCase, useValue: 0},
|
||||
{provide: DontNeedCase, useFactory: () => null},
|
||||
{provide: DontNeedCase, useExisting: TypeCase},
|
||||
{provide: DontNeedCase, useClass: ProviderClass},
|
||||
DirectiveCase,
|
||||
],
|
||||
declarations: [ProvidersTestDirective, ProvidersTestComponent],
|
||||
})
|
||||
export class ProvidersTestModule {}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
import {
|
||||
Component,
|
||||
Directive,
|
||||
ElementRef,
|
||||
HostBinding,
|
||||
HostListener,
|
||||
Injectable,
|
||||
Input,
|
||||
NgModule,
|
||||
Pipe
|
||||
} from '@angular/core';
|
||||
|
||||
export class NonAngularBaseClass {
|
||||
greet() {}
|
||||
}
|
||||
|
||||
export class BaseClass extends NonAngularBaseClass {
|
||||
@Input() enabled = true;
|
||||
}
|
||||
|
||||
export class SecondBaseClass extends BaseClass {
|
||||
toggleEnabled() {
|
||||
this.enabled = !this.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
export class ThirdBaseClass extends SecondBaseClass {
|
||||
@HostListener('focus') onFocus() {}
|
||||
}
|
||||
|
||||
export class FourthBaseClass extends ThirdBaseClass {
|
||||
focus() {
|
||||
this.onFocus();
|
||||
}
|
||||
}
|
||||
|
||||
export class FifthBaseClass {
|
||||
constructor(private _elementRef: ElementRef) {}
|
||||
protected calculatePosition(): any {}
|
||||
}
|
||||
|
||||
export class MyCompSuperBase {
|
||||
@HostBinding('class.hello') hello = true;
|
||||
}
|
||||
|
||||
export class MyCompBase extends MyCompSuperBase {}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '',
|
||||
})
|
||||
export class MyComp extends MyCompBase {}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '',
|
||||
})
|
||||
export class WrappedMyComp extends MyComp {}
|
||||
|
||||
@NgModule({declarations: [MyComp, WrappedMyComp]})
|
||||
export class TestModule {}
|
||||
|
||||
@Directive({selector: null})
|
||||
export class AbstractDir {}
|
||||
|
||||
export class DerivedAbstractDir extends AbstractDir {}
|
||||
|
||||
export class WrappedDerivedAbstractDir extends DerivedAbstractDir {}
|
||||
|
||||
export class UndecoratedService {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
||||
export class UndecoratedPipeBase {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
||||
export class WithDirectiveLifecycleHook {
|
||||
ngOnInit() {}
|
||||
}
|
||||
|
||||
// This class is already decorated and should not be migrated. i.e. no TODO
|
||||
// or Angular decorator should be added. `@Injectable` is sufficient.
|
||||
@Injectable()
|
||||
export class MyService {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
||||
// This class is already decorated and should not be migrated. i.e. no TODO
|
||||
// or Angular decorator should be added. `@Injectable` is sufficient.
|
||||
@Pipe({name: 'my-pipe'})
|
||||
export class MyPipe {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
import {
|
||||
Component,
|
||||
Directive,
|
||||
ElementRef,
|
||||
HostBinding,
|
||||
HostListener,
|
||||
Injectable,
|
||||
Input,
|
||||
NgModule,
|
||||
Pipe
|
||||
} from '@angular/core';
|
||||
|
||||
export class NonAngularBaseClass {
|
||||
greet() {}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class BaseClass extends NonAngularBaseClass {
|
||||
@Input() enabled = true;
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class SecondBaseClass extends BaseClass {
|
||||
toggleEnabled() {
|
||||
this.enabled = !this.enabled;
|
||||
}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class ThirdBaseClass extends SecondBaseClass {
|
||||
@HostListener('focus') onFocus() {}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class FourthBaseClass extends ThirdBaseClass {
|
||||
focus() {
|
||||
this.onFocus();
|
||||
}
|
||||
}
|
||||
|
||||
export class FifthBaseClass {
|
||||
constructor(private _elementRef: ElementRef) {}
|
||||
protected calculatePosition(): any {}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class MyCompSuperBase {
|
||||
@HostBinding('class.hello') hello = true;
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class MyCompBase extends MyCompSuperBase {}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '',
|
||||
})
|
||||
export class MyComp extends MyCompBase {}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp',
|
||||
template: '',
|
||||
})
|
||||
export class WrappedMyComp extends MyComp {}
|
||||
|
||||
@NgModule({declarations: [MyComp, WrappedMyComp]})
|
||||
export class TestModule {}
|
||||
|
||||
@Directive({selector: null})
|
||||
export class AbstractDir {}
|
||||
|
||||
@Directive()
|
||||
export class DerivedAbstractDir extends AbstractDir {}
|
||||
|
||||
@Directive()
|
||||
export class WrappedDerivedAbstractDir extends DerivedAbstractDir {}
|
||||
|
||||
// TODO: Add Angular decorator.
|
||||
export class UndecoratedService {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
||||
// TODO: Add Angular decorator.
|
||||
export class UndecoratedPipeBase {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export class WithDirectiveLifecycleHook {
|
||||
ngOnInit() {}
|
||||
}
|
||||
|
||||
// This class is already decorated and should not be migrated. i.e. no TODO
|
||||
// or Angular decorator should be added. `@Injectable` is sufficient.
|
||||
@Injectable()
|
||||
export class MyService {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
||||
// This class is already decorated and should not be migrated. i.e. no TODO
|
||||
// or Angular decorator should be added. `@Injectable` is sufficient.
|
||||
@Pipe({name: 'my-pipe'})
|
||||
export class MyPipe {
|
||||
ngOnDestroy() {}
|
||||
}
|
||||
|
|
@ -12,7 +12,9 @@ declare const require: any;
|
|||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting()
|
||||
platformBrowserDynamicTesting(), {
|
||||
teardown: { destroyAfterEach: false }
|
||||
}
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
|
|
|
|||
22
integration/ng_update_migrations/src/test_expected.ts
Normal file
22
integration/ng_update_migrations/src/test_expected.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
declare const require: any;
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting(), {
|
||||
teardown: { destroyAfterEach: false }
|
||||
}
|
||||
);
|
||||
// Then we find all the tests.
|
||||
const context = require.context('./', true, /\.spec\.ts$/);
|
||||
// And load the modules.
|
||||
context.keys().map(context);
|
||||
|
|
@ -16,10 +16,10 @@ const diff = require('diff');
|
|||
const projectDir = __dirname;
|
||||
const cliBinPath = path.join(projectDir, 'node_modules/@angular/cli/bin/ng');
|
||||
|
||||
const expectationFiles = glob.sync('**/*_expected.ts', {cwd: projectDir});
|
||||
const expectationFiles = glob.sync('**/*_expected.+(ts|html)', {cwd: projectDir});
|
||||
|
||||
const fromVersion = '9.0.0';
|
||||
const toVersion = '10.0.0';
|
||||
const fromVersion = '12.0.0';
|
||||
const toVersion = '13.0.0';
|
||||
// Note that we need to specify "--allow-dirty" as the repository will become dirty
|
||||
// if dependencies for the integration test are installed (i.e. modified lock files)
|
||||
const updateCommandArgs = ['@angular/core', '--migrate-only', '--from', fromVersion,
|
||||
|
|
@ -43,7 +43,7 @@ let testsPassing = true;
|
|||
|
||||
// Check if each expectation file matches the actual file in the CLI project.
|
||||
expectationFiles.forEach(relativeFilePath => {
|
||||
const actualFilePath = relativeFilePath.replace(/_expected.ts$/, '.ts');
|
||||
const actualFilePath = relativeFilePath.replace(/_expected.(ts)$/, '.$1');
|
||||
const expectedContent = fs.readFileSync(path.join(projectDir, relativeFilePath), 'utf8');
|
||||
const actualContent = fs.readFileSync(path.join(projectDir, actualFilePath), 'utf8');
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue