Skip to content

Commit

Permalink
feat(all): upgrade to ngrx 19 , fix tests
Browse files Browse the repository at this point in the history
Upgraded all packages to to required ngrx 19 versions, fixed broken tests

BREAKING CHANGE: requires ngrx 19

Fix #150
  • Loading branch information
Gabriel Guerrero authored and gabrielguerrero committed Jan 13, 2025
1 parent 6f55515 commit c76947d
Show file tree
Hide file tree
Showing 16 changed files with 1,574 additions and 1,001 deletions.
1 change: 1 addition & 0 deletions apps/example-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '@angular/core';

@Component({
selector: 'ngrx-traits-root',
standalone: false,
template: `<router-outlet />`,
styleUrls: ['./app.component.scss'],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { JsonPipe } from '@angular/common';
import { ChangeDetectionStrategy, Component, model } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { MatFormFieldModule } from '@angular/material/form-field';
Expand All @@ -24,7 +23,7 @@ import { ProductFilter } from '../../models';
`,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [FormsModule, MatFormFieldModule, MatInputModule, JsonPipe],
imports: [FormsModule, MatFormFieldModule, MatInputModule],
})
export class ProductSearchFormComponent {
searchProduct = model<ProductFilter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';

import { ProductsBranchDropdownComponent } from './products-branch-dropdown.component';
import { ProductsBranchListComponent } from './products-branch-list.component';
import { ProductsBranchStore } from './products-branch.store';

@Component({
selector: 'infinite-scroll-page',
standalone: true,
imports: [
CommonModule,
ProductsBranchDropdownComponent,
ProductsBranchListComponent,
],
imports: [CommonModule, ProductsBranchDropdownComponent],
template: `<products-branch-dropdown />`,
styles: ``,
providers: [ProductsBranchStore],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { toSignal } from '@angular/core/rxjs-interop';
import { FormsModule } from '@angular/forms';
import { MatButton } from '@angular/material/button';
import { MatFormField, MatLabel } from '@angular/material/form-field';
import { MatIcon } from '@angular/material/icon';
import { MatInput } from '@angular/material/input';
import { MatList, MatListItem } from '@angular/material/list';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
Expand All @@ -28,7 +27,6 @@ import { ProductsBranchStore } from './products-branch.store';
MatList,
MatListItem,
MatButton,
MatIcon,
MatFormField,
MatInput,
FormsModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AsyncPipe, JsonPipe } from '@angular/common';
import { Component, inject, OnInit } from '@angular/core';
import { Component, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { RouterLink } from '@angular/router';
import { Sort } from '@ngrx-traits/common';
Expand Down Expand Up @@ -100,9 +99,7 @@ import { ProductsLocalStore } from './product.store';
ProductListComponent,
MatPaginatorModule,
MatButtonModule,
AsyncPipe,
ProductDetailComponent,
JsonPipe,
RouterLink,
],
providers: [ProductsLocalStore],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { Sort } from '@ngrx-traits/common';

import { ProductBasketComponent } from '../../../../components/product-basket/product-basket.component';
import { ProductDetailComponent } from '../../../../components/product-detail/product-detail.component';
import { Product } from '../../../../models';
import { ProductsShopStore } from '../../products-shop.store';
import { SmartProductDetailComponent } from '../smart-product-detail/smart-product-detail.component';
Expand Down Expand Up @@ -86,8 +84,6 @@ import { SmartProductDetailComponent } from '../smart-product-detail/smart-produ
MatProgressSpinnerModule,
ProductBasketComponent,
MatButtonModule,
ProductDetailComponent,
AsyncPipe,
SmartProductDetailComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AsyncPipe } from '@angular/common';
import { Component, computed, inject } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
Expand Down Expand Up @@ -85,7 +84,6 @@ import { ProductsShopStore } from '../../products-shop.store';
MatButtonModule,
ProductListComponent,
ProductDetailComponent,
AsyncPipe,
MatPaginator,
],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AsyncPipe } from '@angular/common';
import { Component, inject } from '@angular/core';
import { MatBadgeModule } from '@angular/material/badge';
import { MatIconModule } from '@angular/material/icon';
Expand Down Expand Up @@ -59,7 +58,6 @@ import { ProductsShopStore } from './products-shop.store';
MatIconModule,
MatBadgeModule,
RouterOutlet,
AsyncPipe,
],
})
export class ProductShopPageContainerComponent {
Expand Down
12 changes: 6 additions & 6 deletions libs/ngrx-traits/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"postinstall": "ngcc"
},
"peerDependencies": {
"@angular/core": "^18.0.5",
"@ngrx/effects": "^18.0.1",
"@ngrx/entity": "^18.0.1",
"@ngrx/store": "^18.0.1",
"@ngrx-traits/core": "^18.0.0"
"@angular/core": "^19.0.0",
"@ngrx/effects": "^19.0.0",
"@ngrx/entity": "^19.0.0",
"@ngrx/store": "^19.0.0",
"@ngrx-traits/core": "^19.0.0"
},
"optionalDependencies": {
"@angular/router": "^18.0.5"
"@angular/router": "^19.0.0"
},
"sideEffects": false,
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions libs/ngrx-traits/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"postinstall": "ngcc"
},
"peerDependencies": {
"@angular/core": "^18.0.5",
"@ngrx/effects": "^18.0.1",
"@ngrx/entity": "^18.0.1",
"@ngrx/store": "^18.0.1",
"@angular/core": "^19.0.0",
"@ngrx/effects": "^19.0.0",
"@ngrx/entity": "^19.0.0",
"@ngrx/store": "^19.0.0",
"rxjs": "^7.8.1"
},
"sideEffects": false,
Expand Down
6 changes: 3 additions & 3 deletions libs/ngrx-traits/signals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"build": "ng-packagr -p package.json"
},
"peerDependencies": {
"@angular/core": "^18.0.5",
"@ngrx/signals": "^18.1.0",
"@angular/core": "^19.0.0",
"@ngrx/signals": "^19.0.0",
"rxjs": "^7.8.1"
},
"optionalDependencies": {
"@angular/cdk": "^18.0.5"
"@angular/cdk": "^19.0.0"
},
"sideEffects": false,
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('withEntitiesLocalFilter', () => {
patchState(store, setAllEntities(mockProducts));
store.setLoaded();
TestBed.flushEffects();
tick();
expect(store.entities().length).toEqual(2);
expect(store.entities()).toEqual([
{
Expand Down Expand Up @@ -162,6 +163,7 @@ describe('withEntitiesLocalFilter', () => {
patchState(store, setAllEntities(mockProducts));
store.setLoaded();
TestBed.flushEffects();
tick();
expect(store.entities().length).toEqual(2);
expect(store.entities()).toEqual([
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
import {
discardPeriodicTasks,
fakeAsync,
flush,
TestBed,
tick,
} from '@angular/core/testing';
import { signalStore, type, withState } from '@ngrx/signals';
import { withEntities } from '@ngrx/signals/entities';
import { of } from 'rxjs';
Expand Down Expand Up @@ -221,10 +227,7 @@ describe('withEntitiesRemoteFilter', () => {
expect(store.entities().length).toEqual(mockProducts.length);
tick(400);
expect(store.entities().length).toEqual(2);
store.filterEntities({
filter: { search: 'zero', foo: 'bar' },
forceLoad: true,
});
expect(store.entitiesFilter()).toEqual({ search: 'zero', foo: 'bar' });
});
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('withEntitiesRemotePagination', () => {
expect(store.entitiesCurrentPage().hasNext).toEqual(true);

store.loadEntitiesPage({ pageIndex: 2 });

tick();
// check the third page
expect(store.entitiesCurrentPage().entities.length).toEqual(5);
expect(store.entitiesCurrentPage().entities).toEqual(
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('withEntitiesRemotePagination', () => {
expect(store.entitiesCurrentPage().hasNext).toEqual(true);

store.loadEntitiesPage({ pageIndex: 2 });

tick();
// check the third page
expect(store.entitiesCurrentPage().entities.length).toEqual(5);
expect(store.entitiesCurrentPage().entities).toEqual(
Expand Down Expand Up @@ -682,7 +682,7 @@ describe('withEntitiesRemotePagination', () => {
expect(store.productsCurrentPage().hasNext).toEqual(true);

store.loadProductsPage({ pageIndex: 2 });

tick();
// check the third page
expect(store.productsCurrentPage().entities.length).toEqual(5);
expect(store.productsCurrentPage().entities).toEqual(
Expand Down Expand Up @@ -1123,6 +1123,7 @@ describe('withEntitiesRemotePagination', () => {
expect(store.entitiesCurrentPage.hasNext()).toEqual(true);

store.loadEntitiesPage({ pageIndex: 1 });
tick();
// check the second page
expect(store.entitiesCurrentPage.entities().length).toEqual(10);
expect(store.entitiesCurrentPage.entities()).toEqual(
Expand Down
Loading

0 comments on commit c76947d

Please sign in to comment.