Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency updates #1944

Merged
merged 18 commits into from
Jul 25, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
further improved stories
  • Loading branch information
TheSlimvReal committed Jul 24, 2023
commit b7f596d4ab1c48b90804681056df4ad11cc4438d
3 changes: 3 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -3,12 +3,15 @@ import * as buffer from "buffer";
import * as MockDate from "mockdate";
import { Preview } from "@storybook/angular";
import { environment } from "../src/environments/environment";
import { SessionType } from "../src/app/core/session/session-type";

// fixing a mocked "TODAY" to have persistent stories for visual regression testing
MockDate.set(new Date("2023-06-09"));
// polyfill buffer here as well
window.Buffer = buffer.Buffer;
environment.production = false;
environment.session_type = SessionType.mock;
environment.demo_mode = false;

export const preview: Preview = {
parameters: {
1 change: 1 addition & 0 deletions .storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
"extends": "../tsconfig.json",
"include": [
"../src/**/*.stories.ts",
"../src/polyfills.ts",
"preview.ts"
],
"files": [
Original file line number Diff line number Diff line change
@@ -3,13 +3,10 @@ import { DemoChildGenerator } from "../../../children/demo-data-generators/demo-
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { Note } from "../../../notes/model/note";
import { StorybookBaseModule } from "../../../../utils/storybook-base.module";
import { mockEntityMapper } from "../../../../core/entity/mock-entity-mapper-service";
import { EntityMapperService } from "../../../../core/entity/entity-mapper.service";
import { importProvidersFrom } from "@angular/core";

const demoEvent = Note.create(new Date(), "coaching");
@@ -25,16 +22,7 @@ export default {
component: RollCallComponent,
decorators: [
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [RollCallComponent],
providers: [
{
provide: EntityMapperService,
useValue: mockEntityMapper(demoChildren),
},
],
providers: [importProvidersFrom(StorybookBaseModule.withData(demoChildren))],
}),
],
} as Meta;
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Meta, moduleMetadata, StoryFn } from "@storybook/angular";
import { RouterTestingModule } from "@angular/router/testing";
import { MatNativeDateModule } from "@angular/material/core";
import { AttendanceStatusSelectComponent } from "./attendance-status-select.component";
import { ConfigurableEnumService } from "../../../core/configurable-enum/configurable-enum.service";
import { defaultAttendanceStatusTypes } from "../../../core/config/default-config/default-attendance-status-types";
@@ -10,11 +8,6 @@ export default {
component: AttendanceStatusSelectComponent,
decorators: [
moduleMetadata({
imports: [
AttendanceStatusSelectComponent,
RouterTestingModule,
MatNativeDateModule,
],
providers: [
{
provide: ConfigurableEnumService,
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import {
Inject,
Input,
OnInit,
Optional,
ViewEncapsulation,
} from "@angular/core";
import { Note } from "../model/note";
@@ -66,14 +67,16 @@ export class NoteDetailsComponent implements OnInit {
constructor(
private configService: ConfigService,
private entityFormService: EntityFormService,
@Inject(MAT_DIALOG_DATA) data: { entity: Note }
@Optional() @Inject(MAT_DIALOG_DATA) data: { entity: Note },
) {
this.entity = data.entity;
if (data) {
this.entity = data.entity;
}
this.exportConfig = this.configService.getConfig<{
config: EntityListConfig;
}>("view:note").config.exportConfig;
const formConfig = this.configService.getConfig<any>(
"appConfig:note-details"
"appConfig:note-details",
);
this.topForm =
formConfig?.topForm?.map((field) => [toFormFieldConfig(field)]) ??
@@ -88,7 +91,7 @@ export class NoteDetailsComponent implements OnInit {
ngOnInit() {
this.form = this.entityFormService.createFormGroup(
this.middleForm.concat(...this.topForm, this.bottomForm),
this.entity
this.entity,
);
// create an object reflecting unsaved changes to use in template (e.g. for dynamic title)
this.tmpEntity = this.entity.copy();
Original file line number Diff line number Diff line change
@@ -7,9 +7,8 @@ import {
import { NoteDetailsComponent } from "./note-details.component";
import { Note } from "../model/note";
import { Child } from "../../children/model/child";
import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog";
import { ChildrenService } from "../../children/children.service";
import { NEVER, of } from "rxjs";
import { MatDialogRef } from "@angular/material/dialog";
import { NEVER } from "rxjs";
import { StorybookBaseModule } from "../../../utils/storybook-base.module";
import { importProvidersFrom } from "@angular/core";

@@ -24,18 +23,10 @@ export default {
}),
moduleMetadata({
providers: [
{
provide: MAT_DIALOG_DATA,
useValue: { data: { entity: Note.create(new Date()) } },
},
{
provide: MatDialogRef,
useValue: { backdropClick: () => NEVER, afterClosed: () => NEVER },
},
{
provide: ChildrenService,
useValue: { getChild: () => of(Child.create("John Doe")) },
},
],
}),
],
@@ -59,6 +50,6 @@ eventNote.addChild(demoChildren[0].getId());
eventNote.addChild(demoChildren[1].getId());

export const EventWithAttendance = Template.bind({});
Primary.args = {
EventWithAttendance.args = {
entity: eventNote,
};
Original file line number Diff line number Diff line change
@@ -48,9 +48,7 @@ describe("DashboardListWidgetComponent", () => {
beforeEach(async () => {
mockEntityMapper = jasmine.createSpyObj(["loadType", "receiveUpdates"]);
mockEntityUpdates = new Subject<UpdatedEntity<Note>>();
mockEntityMapper.receiveUpdates.and.returnValue(
mockEntityUpdates.asObservable(),
);
mockEntityMapper.receiveUpdates.and.returnValue(mockEntityUpdates);

await TestBed.configureTestingModule({
imports: [DashboardWidgetTestComponent],
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { Child } from "../../../../child-dev-project/children/model/child";
import { DisplayEntityArrayComponent } from "./display-entity-array.component";
import { StorybookBaseModule } from "../../../../utils/storybook-base.module";
import { EntityMapperService } from "../../../entity/entity-mapper.service";
import { mockEntityMapper } from "../../../entity/mock-entity-mapper-service";
import { ChildrenService } from "../../../../child-dev-project/children/children.service";
import { importProvidersFrom } from "@angular/core";

const child1 = new Child();
@@ -33,16 +25,16 @@ export default {
component: DisplayEntityArrayComponent,
decorators: [
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayEntityArrayComponent],
providers: [
{
provide: EntityMapperService,
useValue: mockEntityMapper([child1, child2, child3, child4, child5]),
},
{ provide: ChildrenService, useValue: null },
importProvidersFrom(
StorybookBaseModule.withData([
child1,
child2,
child3,
child4,
child5,
]),
),
],
}),
],
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { DisplayEntityComponent } from "./display-entity.component";
import { Child } from "../../../../child-dev-project/children/model/child";
import { School } from "../../../../child-dev-project/schools/model/school";
import { User } from "../../../user/user";
import { StorybookBaseModule } from "../../../../utils/storybook-base.module";
import { EntityMapperService } from "../../../entity/entity-mapper.service";
import { mockEntityMapper } from "../../../entity/mock-entity-mapper-service";
import { ChildrenService } from "../../../../child-dev-project/children/children.service";
import { importProvidersFrom } from "@angular/core";

export default {
@@ -21,13 +13,6 @@ export default {
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayEntityComponent],
providers: [
{ provide: EntityMapperService, useValue: mockEntityMapper([]) },
{ provide: ChildrenService, useValue: null },
],
}),
],
} as Meta;

Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@ export function generateFormFieldStory<T>(
};

const meta: Meta = {
title: "Core/Entities/Edit Properties/" + editComponent,
component: FormComponent,
decorators: [
applicationConfig({
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { StorybookBaseModule } from "../../../../../utils/storybook-base.module";
import { DisplayAgeComponent } from "./display-age.component";
import { DateWithAge } from "../../../../../child-dev-project/children/model/dateWithAge";
@@ -16,19 +11,16 @@ export default {
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayAgeComponent],
providers: [],
}),
],
} as Meta;

const Template: StoryFn<DisplayAgeComponent> = (args: DisplayAgeComponent) => ({
props: args,
});

const date = new DateWithAge("2001-12-25");
// currently Storybook can't handle classes extending Date - so this doesn't work: https://github.com/storybookjs/storybook/issues/14618
const date = new DateWithAge("2001-12-25");
(date as any)["age"] = "12";

export const Basic = Template.bind({});
Basic.args = {
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { StorybookBaseModule } from "../../../../../utils/storybook-base.module";
import { DisplayCheckmarkComponent } from "./display-checkmark.component";
import { importProvidersFrom } from "@angular/core";
@@ -15,10 +10,6 @@ export default {
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayCheckmarkComponent],
providers: [],
}),
],
} as Meta;

Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { StorybookBaseModule } from "../../../../../utils/storybook-base.module";
import { DisplayDateComponent } from "./display-date.component";
import { importProvidersFrom } from "@angular/core";
@@ -15,10 +10,6 @@ export default {
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayDateComponent],
providers: [],
}),
],
} as Meta;

Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { StorybookBaseModule } from "../../../../../utils/storybook-base.module";
import { DisplayMonthComponent } from "./display-month.component";
import { importProvidersFrom } from "@angular/core";
@@ -15,10 +10,6 @@ export default {
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayMonthComponent],
providers: [],
}),
],
} as Meta;

Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { DisplayPercentageComponent } from "./display-percentage.component";
import { StorybookBaseModule } from "../../../../../utils/storybook-base.module";
import { importProvidersFrom } from "@angular/core";
@@ -15,10 +10,6 @@ export default {
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayPercentageComponent],
providers: [],
}),
],
} as Meta;

Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
applicationConfig,
Meta,
moduleMetadata,
StoryFn,
} from "@storybook/angular";
import { applicationConfig, Meta, StoryFn } from "@storybook/angular";
import { StorybookBaseModule } from "../../../../../utils/storybook-base.module";
import { DisplayTextComponent } from "./display-text.component";
import { importProvidersFrom } from "@angular/core";
@@ -15,10 +10,6 @@ export default {
applicationConfig({
providers: [importProvidersFrom(StorybookBaseModule)],
}),
moduleMetadata({
imports: [DisplayTextComponent],
providers: [],
}),
],
} as Meta;

Loading