Ma77Ball opened a new issue, #5466:
URL: https://github.com/apache/texera/issues/5466
### Task Summary
`FlarumComponent`
(`frontend/src/app/dashboard/component/user/flarum/flarum.component.ts`)
has no `*.spec.ts` file. It is a 27-line component that builds a single
`SafeResourceUrl` (`flarumUrl`) by passing `"forum"` through Angular's
`DomSanitizer`. A
short spec confirming the component is created and that the sanitizer is
used is enough.
### What to do (step by step)
1. Create the spec next to the component, with the Apache license header.
2. Provide a mock `DomSanitizer` whose `bypassSecurityTrustResourceUrl` is a
`vi.fn()`
returning a sentinel value (e.g. `"SAFE_URL"`).
3. Assert the component is created, `bypassSecurityTrustResourceUrl` was
called with
`"forum"`, and `flarumUrl` is the sentinel value.
4. Run `yarn test -- flarum`, then `yarn lint`.
### Cover
- `should create`.
- `bypassSecurityTrustResourceUrl` is called with `"forum"`.
- `flarumUrl` equals the value returned by the sanitizer.
### Starter skeleton
```ts
// <Apache license header>
import { ComponentFixture, TestBed } from "@angular/core/testing";
import { DomSanitizer } from "@angular/platform-browser";
import { FlarumComponent } from "./flarum.component";
describe("FlarumComponent", () => {
const sanitizerSpy = { bypassSecurityTrustResourceUrl:
vi.fn().mockReturnValue("SAFE_URL") };
let component: FlarumComponent;
let fixture: ComponentFixture<FlarumComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FlarumComponent],
providers: [{ provide: DomSanitizer, useValue: sanitizerSpy }],
}).compileComponents();
fixture = TestBed.createComponent(FlarumComponent);
component = fixture.componentInstance;
});
it("builds a trusted forum url", () => {
expect(component).toBeTruthy();
expect(sanitizerSpy.bypassSecurityTrustResourceUrl).toHaveBeenCalledWith("forum");
expect(component.flarumUrl).toBe("SAFE_URL");
});
});
```
### Task Type
- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [x] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]