Copilot commented on code in PR #6831:
URL: https://github.com/apache/texera/pull/6831#discussion_r3636494110
##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.spec.ts:
##########
@@ -1384,4 +1385,191 @@ describe("HuggingFaceComponent (TestBed)", () => {
expect(component.loading).toBe(false);
});
});
+
+ // ── Rendered-template interactions (the (click)/(ngModelChange) bindings)
──
+
+ describe("template interactions", () => {
+ it("clicking a model item selects it", () => {
+ initComponent("text-generation", buildModels(3));
+ fixture.detectChanges();
+
+ const item = fixture.debugElement.query(By.css(".hf-model-item"));
+ expect(item).toBeTruthy();
+ item.triggerEventHandler("click", null);
+
+ expect(component.formControl.value).toBe("model/model-0");
+ });
+
+ it("clicking the close icon on the selected model clears the value", () =>
{
+ initComponent("text-generation", buildModels(3));
+ component.formControl.setValue("model/model-0");
+ fixture.detectChanges();
+
+ const closeIcon = fixture.debugElement.query(By.css(".hf-selected-model
i"));
+ expect(closeIcon).toBeTruthy();
+ closeIcon.triggerEventHandler("click", null);
+
+ expect(component.formControl.value).toBe("");
+ });
+
+ it("the pagination buttons move to the next and previous page", () => {
+ initComponent("text-generation", buildModels(120)); // 3 pages of 50
+ fixture.detectChanges();
+
+ const next = fixture.debugElement.queryAll(By.css(".hf-pagination
button"))[1];
+ next.triggerEventHandler("click", null);
+ expect(component.currentPage).toBe(1);
+
+ fixture.detectChanges();
+ const prev = fixture.debugElement.queryAll(By.css(".hf-pagination
button"))[0];
+ prev.triggerEventHandler("click", null);
+ expect(component.currentPage).toBe(0);
Review Comment:
The pagination interaction test indexes into queryAll(...)[1]/[0] without
asserting the buttons exist first. If the template changes (or pagination
doesn’t render for some reason), this will fail with a cryptic "Cannot read
properties of undefined" rather than a helpful assertion failure. Consider
asserting the expected button count and then using the array elements.
--
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]