You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "mengw15 (via GitHub)" <gi...@apache.org> on 2026/07/14 22:42:17 UTC

[PR] test(frontend): add unit test coverage for MarkdownDescriptionComponent [texera]

mengw15 opened a new pull request, #6431:
URL: https://github.com/apache/texera/pull/6431

   ### What changes were proposed in this PR?
   
   Adds a behavior-focused Vitest spec for `MarkdownDescriptionComponent`
   (`frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.ts`),
   which previously had no spec (~46% coverage).
   
   > Note: issue #6428 lists the path as `workspace/component/markdown-description/`;
   > the component actually lives under `dashboard/component/user/markdown-description/`.
   
   14 tests (TestBed + `detectChanges()`, `MarkdownService` stubbed, `NZ_MODAL_DATA`
   provided only for the modal cases) cover:
   
   - `should create` and render the preview template.
   - The `editable` input toggling the preview-mode Edit action (shown / hidden).
   - `ngOnInit` — inline case: starts in `preview`, seeds `editingContent` from `description`; modal case: `editable = true`, `currentMode = "edit"`, `description` pulled from modal data (and defaulted to `""` when omitted).
   - `ngOnChanges` — refreshes `editingContent` + re-renders on a non-first `description` change in preview mode; leaves it untouched under the edit-mode guard; ignores the first change.
   - `enterEditMode` — switches to edit mode only when `editable`.
   - `save` — emits `descriptionChange` with the edited content; returns to `preview` inline but stays in `edit` when opened in a modal.
   - `cancel` — restores `editingContent` from `description` and returns to `preview`.
   - `renderMarkdown` — renders non-empty input and clears on blank input without parsing.
   
   No production code was changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6428
   
   ### How was this PR tested?
   
   New unit tests, run locally in `frontend/` (all green; the failure path was
   verified by deliberately breaking an assertion to confirm the suite goes red):
   
   ```
   ng test --watch=false --include src/app/dashboard/component/user/markdown-description/markdown-description.component.spec.ts
   # Test Files 1 passed (1) | Tests 14 passed (14)
   prettier --write <spec>   # formatted
   eslint  <spec>            # clean
   ```
   
   `MarkdownService.parse` is stubbed and `NZ_MODAL_DATA` is injected via the test
   module, so the suite makes no network calls and needs no real markdown config
   (see `frontend/TESTING.md`).
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8 [1M context])
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): add unit test coverage for MarkdownDescriptionComponent [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6431:
URL: https://github.com/apache/texera/pull/6431#issuecomment-4974686551

   <!-- texera-reviewer-suggestion -->
   ### Automated Reviewer Suggestions
   
   Based on the `git blame` history of the changed files, we recommend the following reviewers:
   
   - No candidates found from `git blame` history.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): add unit test coverage for MarkdownDescriptionComponent [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #6431:
URL: https://github.com/apache/texera/pull/6431#discussion_r3583137406


##########
frontend/src/app/dashboard/component/user/markdown-description/markdown-description.component.spec.ts:
##########
@@ -0,0 +1,225 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Provider, SimpleChange } from "@angular/core";
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { NZ_MODAL_DATA } from "ng-zorro-antd/modal";
+import { MarkdownService } from "ngx-markdown";
+import { MarkdownDescriptionComponent } from "./markdown-description.component";
+
+describe("MarkdownDescriptionComponent", () => {
+  // Echo non-empty markdown as trivial HTML so `renderedDescription` is observable
+  // without pulling in the real (config-dependent) ngx-markdown parser.
+  const parse = vi.fn((text: string) => (text ? `<p>${text}</p>` : ""));
+
+  // Passing `modalData` provides NZ_MODAL_DATA (the "opened in a modal" case);
+  // omitting it leaves the optional injection null (the inline case).
+  async function createFixture(modalData?: {
+    description?: string;
+  }): Promise<ComponentFixture<MarkdownDescriptionComponent>> {
+    const providers: Provider[] = [{ provide: MarkdownService, useValue: { parse } }];
+    if (modalData !== undefined) {
+      providers.push({ provide: NZ_MODAL_DATA, useValue: modalData });
+    }
+    await TestBed.configureTestingModule({
+      imports: [MarkdownDescriptionComponent],
+      providers,
+    }).compileComponents();
+    return TestBed.createComponent(MarkdownDescriptionComponent);
+  }
+
+  // A non-first change of the `description` input.
+  const descriptionChange = (previous: string, current: string): { description: SimpleChange } => ({
+    description: new SimpleChange(previous, current, false),
+  });
+
+  beforeEach(() => parse.mockClear());
+
+  it("should create and render the preview template when not opened in a modal", async () => {
+    const fixture = await createFixture();
+    fixture.componentInstance.description = "hello";
+    fixture.detectChanges();
+    await fixture.whenStable();
+
+    expect(fixture.componentInstance).toBeTruthy();
+    expect(fixture.nativeElement.querySelector(".preview-box")).toBeTruthy();
+  });
+
+  it("shows the Edit action in preview mode when editable", async () => {
+    const fixture = await createFixture();
+    fixture.componentInstance.editable = true;
+    fixture.detectChanges();
+    expect(fixture.nativeElement.querySelector(".md-actions")).toBeTruthy();
+  });
+
+  it("hides the Edit action in preview mode when not editable", async () => {
+    const fixture = await createFixture();
+    fixture.componentInstance.editable = false;
+    fixture.detectChanges();
+    expect(fixture.nativeElement.querySelector(".md-actions")).toBeNull();
+  });
+

Review Comment:
   Issue #6428 calls out covering the `enableViewMore` `@Input` binding, but this spec currently has no assertions around it. Adding a small test that toggles `enableViewMore` and verifies the preview box’s `collapsed` class binding would align the suite with the task requirements and guard regressions in the view-more feature gate.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): add unit test coverage for MarkdownDescriptionComponent [texera]

Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan merged PR #6431:
URL: https://github.com/apache/texera/pull/6431


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): add unit test coverage for MarkdownDescriptionComponent [texera]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6431:
URL: https://github.com/apache/texera/pull/6431#issuecomment-4975345267

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/6431?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 68.16%. Comparing base ([`d561da8`](https://app.codecov.io/gh/apache/texera/commit/d561da8f3ca8b3ee6ce39b9a66320372d295f186?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`732f021`](https://app.codecov.io/gh/apache/texera/commit/732f021303499bc49df09f5d076ee6c18843ec68?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #6431      +/-   ##
   ============================================
   - Coverage     69.90%   68.16%   -1.74%     
   + Complexity     3382     3379       -3     
   ============================================
     Files          1142     1142              
     Lines         44844    44970     +126     
     Branches       4949     4949              
   ============================================
   - Hits          31347    30655     -692     
   - Misses        11841    12665     +824     
   + Partials       1656     1650       -6     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
   |---|---|---|---|
   | [access-control-service](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.00% <ø> (ø)` | | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [agent-service](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `51.58% <ø> (-25.18%)` | :arrow_down: | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [amber](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.56% <ø> (-0.11%)` | :arrow_down: | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `9.97% <ø> (ø)` | | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [config-service](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `52.30% <ø> (ø)` | | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [file-service](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `63.97% <ø> (ø)` | | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [frontend](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `68.51% <ø> (+0.19%)` | :arrow_up: | |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.94% <ø> (ø)` | | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [pyamber](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `91.18% <ø> (-0.02%)` | :arrow_down: | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/6431/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.14% <ø> (ø)` | | Carriedforward from [4773117](https://app.codecov.io/gh/apache/texera/commit/477311780bb4bb383cb47382e364d48517b31d6b?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   *This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/6431?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org