Skip to content

Commit

Permalink
refactor(EditComponentPromptComponent): Convert to standalone (#1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima authored Sep 23, 2024
1 parent 287d96d commit 9c421c3
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ComponentContent } from '../../../assets/wise5/common/ComponentContent';
import { TranslatableTextareaComponent } from '../../../assets/wise5/authoringTool/components/translatable-textarea/translatable-textarea.component';

@Component({
imports: [TranslatableTextareaComponent],
selector: 'edit-component-prompt',
standalone: true,
styles: ['.prompt {width: 100%; mat-form-field { width:100%} }'],
templateUrl: 'edit-component-prompt.component.html'
})
Expand Down
3 changes: 1 addition & 2 deletions src/app/teacher/component-authoring.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ import { RequiredErrorLabelComponent } from '../../assets/wise5/authoringTool/no
EditComponentMaxScoreComponent,
EditComponentMaxSubmitComponent,
EditComponentPeerGroupingTagComponent,
EditComponentPrompt,
EditComponentRubricComponent,
EditComponentSaveButtonComponent,
EditComponentSubmitButtonComponent,
Expand Down Expand Up @@ -176,6 +175,7 @@ import { RequiredErrorLabelComponent } from '../../assets/wise5/authoringTool/no
ComponentAuthoringComponent,
ComponentConstraintAuthoringComponent,
EditComponentAdvancedButtonComponent,
EditComponentPrompt,
EditComponentWidthComponent,
PeerGroupingAuthoringModule,
RequiredErrorLabelComponent,
Expand Down Expand Up @@ -208,7 +208,6 @@ import { RequiredErrorLabelComponent } from '../../assets/wise5/authoringTool/no
EditComponentMaxScoreComponent,
EditComponentMaxSubmitComponent,
EditComponentPeerGroupingTagComponent,
EditComponentPrompt,
EditComponentRubricComponent,
EditComponentSaveButtonComponent,
EditComponentSubmitButtonComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ describe('AiChatAuthoringComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AiChatAuthoringComponent,
EditComponentPrompt,
EditDialogGuidanceComputerAvatarComponent
],
declarations: [AiChatAuthoringComponent, EditDialogGuidanceComputerAvatarComponent],
imports: [
BrowserAnimationsModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatButtonToggleModule,
MatCheckboxModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ let fixture: ComponentFixture<AnimationAuthoring>;
describe('AnimationAuthoring', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AnimationAuthoring, EditComponentPrompt],
declarations: [AnimationAuthoring],
imports: [
BrowserAnimationsModule,
BrowserModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatFormFieldModule,
MatIconModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ describe('AudioOscillatorAuthoring', () => {
imports: [
BrowserAnimationsModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatCheckboxModule,
MatDialogModule,
MatInputModule,
ReactiveFormsModule,
StudentTeacherCommonServicesModule
],
declarations: [EditComponentPrompt, AudioOscillatorAuthoring],
declarations: [AudioOscillatorAuthoring],
providers: [
ProjectAssetService,
TeacherNodeService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import { TeacherNodeService } from '../../../services/teacherNodeService';
import { ComponentAuthoringModule } from '../../component-authoring.module';

@NgModule({
declarations: [ConceptMapAuthoring, EditComponentPrompt],
declarations: [ConceptMapAuthoring],
imports: [
CommonModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatCheckboxModule,
MatFormFieldModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import { ComponentAuthoringModule } from '../../component-authoring.module';
@NgModule({
declarations: [
DialogGuidanceAuthoringComponent,
EditComponentPrompt,
EditComponentMaxSubmitComponent,
EditFeedbackRulesComponent,
FeedbackRuleHelpComponent
],
imports: [
CommonModule,
ComponentAuthoringModule,
EditComponentPrompt,
DragDropModule,
FormsModule,
MatCheckboxModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import { TeacherNodeService } from '../../../services/teacherNodeService';
import { ComponentAuthoringModule } from '../../component-authoring.module';

@NgModule({
declarations: [DrawAuthoring, EditComponentPrompt],
declarations: [DrawAuthoring],
imports: [
CommonModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatCheckboxModule,
MatDialogModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import { EmbeddedAuthoring } from './embedded-authoring.component';
import { ComponentAuthoringModule } from '../../component-authoring.module';

@NgModule({
declarations: [EmbeddedAuthoring, EditComponentPrompt, AuthorUrlParametersComponent],
declarations: [EmbeddedAuthoring, AuthorUrlParametersComponent],
imports: [
CommonModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatCheckboxModule,
MatDialogModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ let fixture: ComponentFixture<GraphAuthoring>;
describe('GraphAuthoringComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [GraphAuthoring, EditComponentPrompt],
declarations: [GraphAuthoring],
imports: [
BrowserAnimationsModule,
BrowserModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatCheckboxModule,
MatDialogModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ let teacherProjectService: TeacherProjectService;
describe('MultipleChoiceAuthoringComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [EditComponentPrompt, MultipleChoiceAuthoring],
declarations: [MultipleChoiceAuthoring],
imports: [
BrowserAnimationsModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatDialogModule,
MatCheckboxModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { StudentTeacherCommonServicesModule } from '../../../../../app/student-t
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { TeacherNodeService } from '../../../services/teacherNodeService';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { ComponentAuthoringModule } from '../../component-authoring.module';
import { ProjectLocale } from '../../../../../app/domain/projectLocale';

const componentContent = {
id: 'qn3savv52r',
Expand Down Expand Up @@ -47,17 +49,21 @@ describe('PeerChatAuthoringComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [EditComponentPrompt, PeerChatAuthoringComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [BrowserAnimationsModule,
declarations: [PeerChatAuthoringComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [
BrowserAnimationsModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatDialogModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatSelectModule,
StudentTeacherCommonServicesModule],
providers: [
StudentTeacherCommonServicesModule
],
providers: [
ConfigService,
{ provide: TeacherNodeService, useClass: MockNodeService },
ProjectAssetService,
Expand All @@ -66,13 +72,17 @@ describe('PeerChatAuthoringComponent', () => {
TeacherProjectService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
}).compileComponents();
]
}).compileComponents();
});

beforeEach(() => {
spyOn(TestBed.inject(TeacherProjectService), 'getLocale').and.returnValue(
new ProjectLocale({ default: 'en-US' })
);
fixture = TestBed.createComponent(PeerChatAuthoringComponent);
component = fixture.componentInstance;
spyOn(TestBed.inject(TeacherProjectService), 'isDefaultLocale').and.returnValue(true);
spyOn(TestBed.inject(TeacherProjectService), 'getFlattenedProjectAsNodeIds').and.returnValue([
'node1',
'node2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { StudentTeacherCommonServicesModule } from '../../../../../app/student-t
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { TeacherNodeService } from '../../../services/teacherNodeService';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { ComponentAuthoringModule } from '../../component-authoring.module';
import { ProjectLocale } from '../../../../../app/domain/projectLocale';

describe('ShowGroupWorkAuthoringComponent', () => {
let component: ShowGroupWorkAuthoringComponent;
Expand All @@ -24,23 +26,37 @@ describe('ShowGroupWorkAuthoringComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [EditComponentPrompt, ShowGroupWorkAuthoringComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [BrowserAnimationsModule,
declarations: [ShowGroupWorkAuthoringComponent],
schemas: [NO_ERRORS_SCHEMA],
imports: [
BrowserAnimationsModule,
BrowserModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatCheckboxModule,
MatDialogModule,
MatFormFieldModule,
MatInputModule,
MatSelectModule,
StudentTeacherCommonServicesModule],
providers: [ProjectAssetService, TeacherNodeService, TeacherProjectService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
}).compileComponents();
StudentTeacherCommonServicesModule
],
providers: [
ProjectAssetService,
TeacherNodeService,
TeacherProjectService,
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
}).compileComponents();
});

beforeEach(() => {
spyOn(TestBed.inject(TeacherProjectService), 'getLocale').and.returnValue(
new ProjectLocale({ default: 'en-US' })
);
fixture = TestBed.createComponent(ShowGroupWorkAuthoringComponent);
spyOn(TestBed.inject(TeacherProjectService), 'isDefaultLocale').and.returnValue(true);
spyOn(TestBed.inject(TeacherProjectService), 'getFlattenedProjectAsNodeIds').and.returnValue([
nodeId1
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ describe('ShowMyWorkAuthoringComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [EditComponentPrompt, ShowMyWorkAuthoringComponent],
declarations: [ShowMyWorkAuthoringComponent],
imports: [
BrowserAnimationsModule,
BrowserModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatDialogModule,
MatFormFieldModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ let getComponentSpy;
describe('SummaryAuthoringComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [EditComponentPrompt, SummaryAuthoring],
declarations: [SummaryAuthoring],
imports: [
BrowserAnimationsModule,
BrowserModule,
CommonModule,
ComponentAuthoringModule,
EditComponentPrompt,
FormsModule,
MatCheckboxModule,
MatFormFieldModule,
Expand Down

0 comments on commit 9c421c3

Please sign in to comment.