Skip to content

Commit

Permalink
fix: test and visual testing update for otter training
Browse files Browse the repository at this point in the history
  • Loading branch information
cpaulve-1A committed Dec 19, 2024
1 parent 6f662e5 commit 3b0e4b2
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CodeEditorViewComponent,
} from './code-editor-view.component';

describe('ViewComponent', () => {
describe('CodeEditorViewComponent', () => {
let component: CodeEditorViewComponent;
let fixture: ComponentFixture<CodeEditorViewComponent>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export class CodeEditorViewComponent implements OnDestroy {
*/
private readonly monacoPromise = firstValueFrom(this.newMonacoEditorCreated.pipe(
map(() => window.monaco)
));
)).catch(
(err) => console.error(err)
);

/**
* Configuration for the Monaco Editor
Expand Down Expand Up @@ -309,6 +311,9 @@ export class CodeEditorViewComponent implements OnDestroy {
}
});
void this.monacoPromise.then((monaco) => {
if (!monaco) {
return;
}
monaco.editor.registerEditorOpener({
openCodeEditor: (_source: Monaco.editor.ICodeEditor, resource: Monaco.Uri, selectionOrPosition?: Monaco.IRange | Monaco.IPosition) => {
const filePath = resource.path.slice(1);
Expand Down Expand Up @@ -388,23 +393,27 @@ export class CodeEditorViewComponent implements OnDestroy {
*/
private async cleanAllModelsFromMonaco() {
const monaco = await this.monacoPromise;
monaco.editor.getModels().forEach((m) => m.dispose());
if (monaco) {
monaco.editor.getModels().forEach((m) => m.dispose());
}
}

/**
* Load all the files from `this.project` as Models in the global monaco editor.
*/
private async loadAllProjectFilesToMonaco() {
const monaco = await this.monacoPromise;
const flatFiles = flattenTree(this.project().files);
flatFiles.forEach(({ filePath, content }) => {
const language = editorOptionsLanguage[filePath.split('.').at(-1) || ''] || '';
monaco.editor.createModel(content, language, monaco.Uri.from({ scheme: 'file', path: filePath }));
});
// Refresh tsconfig paths mapping
monaco.languages.typescript.typescriptDefaults.setCompilerOptions(
monaco.languages.typescript.typescriptDefaults.getCompilerOptions()
);
if (monaco) {
const flatFiles = flattenTree(this.project().files);
flatFiles.forEach(({ filePath, content }) => {
const language = editorOptionsLanguage[filePath.split('.').at(-1) || ''] || '';
monaco.editor.createModel(content, language, monaco.Uri.from({ scheme: 'file', path: filePath }));
});
// Refresh tsconfig paths mapping
monaco.languages.typescript.typescriptDefaults.setCompilerOptions(
monaco.languages.typescript.typescriptDefaults.getCompilerOptions()
);
}
}

/**
Expand All @@ -426,7 +435,9 @@ export class CodeEditorViewComponent implements OnDestroy {
{ filePath: 'file:///node_modules/@ama-sdk/client-fetch/index.d.ts', content: 'export * from "./src/public_api.d.ts";' }
];
const monaco = await this.monacoPromise;
monaco.languages.typescript.typescriptDefaults.setExtraLibs(declarationTypes);
if (monaco) {
monaco.languages.typescript.typescriptDefaults.setExtraLibs(declarationTypes);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [],
providers: [NgbActiveModal],
templateUrl: './save-code-dialog.template.html'
})
export class SaveCodeDialogComponent {
Expand Down

0 comments on commit 3b0e4b2

Please sign in to comment.