You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by gi...@apache.org on 2026/06/09 21:57:01 UTC
(texera) branch gh-readonly-queue/main/pr-5584-7b7a5c69b83c88caee17b34b9029c7575bebe143 created (now 96fa3f099c)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-5584-7b7a5c69b83c88caee17b34b9029c7575bebe143
in repository https://gitbox.apache.org/repos/asf/texera.git
at 96fa3f099c test(frontend): add spec for FlarumComponent (#5584)
This branch includes the following new commits:
new 96fa3f099c test(frontend): add spec for FlarumComponent (#5584)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(texera) 01/01: test(frontend): add spec for FlarumComponent (#5584)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-5584-7b7a5c69b83c88caee17b34b9029c7575bebe143
in repository https://gitbox.apache.org/repos/asf/texera.git
commit 96fa3f099c00687bffafae88249e78fbe1de516b
Author: EmilySun621 <14...@users.noreply.github.com>
AuthorDate: Tue Jun 9 14:56:41 2026 -0700
test(frontend): add spec for FlarumComponent (#5584)
### What changes were proposed in this PR?
Adds a behavior-focused unit test spec for `FlarumComponent`. Tests
cover:
- DomSanitizer call with "forum" URL at construction
- `SafeResourceUrl` exposed as `flarumUrl`
- iframe `[src]` binding
### Any related issues, documentation, discussions?
Related to #5167
### How was this PR tested?
Spec verified with `npx ng test --watch=false
--include='**/flarum.component.spec.ts'`. 3 tests passing.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Anthropic)
Co-authored-by: Claude Opus 4.7 (1M context) <no...@anthropic.com>
---
.../component/user/flarum/flarum.component.spec.ts | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/frontend/src/app/dashboard/component/user/flarum/flarum.component.spec.ts b/frontend/src/app/dashboard/component/user/flarum/flarum.component.spec.ts
new file mode 100644
index 0000000000..15ed6926c6
--- /dev/null
+++ b/frontend/src/app/dashboard/component/user/flarum/flarum.component.spec.ts
@@ -0,0 +1,60 @@
+/**
+ * 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 { ComponentFixture, TestBed } from "@angular/core/testing";
+import { DomSanitizer } from "@angular/platform-browser";
+
+import { FlarumComponent } from "./flarum.component";
+
+describe("FlarumComponent", () => {
+ let fixture: ComponentFixture<FlarumComponent>;
+ let component: FlarumComponent;
+ let bypassSpy: ReturnType<typeof vi.spyOn>;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({ imports: [FlarumComponent] });
+
+ // Spy on the real sanitizer before the component is constructed, so the
+ // constructor's call to bypassSecurityTrustResourceUrl is recorded.
+ const sanitizer = TestBed.inject(DomSanitizer);
+ bypassSpy = vi.spyOn(sanitizer, "bypassSecurityTrustResourceUrl");
+
+ fixture = TestBed.createComponent(FlarumComponent);
+ component = fixture.componentInstance;
+ });
+
+ it("asks DomSanitizer to trust the forum resource url at construction time", () => {
+ expect(bypassSpy).toHaveBeenCalledExactlyOnceWith("forum");
+ });
+
+ it("exposes the sanitizer's SafeResourceUrl as flarumUrl", () => {
+ // The spy returns the real SafeResourceUrl produced by Angular's sanitizer.
+ expect(component.flarumUrl).toBe(bypassSpy.mock.results[0].value);
+ });
+
+ it("renders an iframe whose [src] binding is driven by flarumUrl", () => {
+ fixture.detectChanges();
+ const iframe = fixture.nativeElement.querySelector("iframe") as HTMLIFrameElement | null;
+
+ expect(iframe).not.toBeNull();
+ // We don't assert on the concrete URL string — DomSanitizer's serialised
+ // output is an implementation detail. We just check that the binding fired.
+ expect(iframe!.hasAttribute("src")).toBe(true);
+ });
+});