Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+28
@@ -0,0 +1,28 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { Progress } from ".";
|
||||
|
||||
describe("Progress accessibility wrapper", () => {
|
||||
it("uses its string label as an accessible-name fallback", () => {
|
||||
render(<Progress label="Project progress" value={50} />);
|
||||
expect(screen.getByRole("progressbar", { name: "Project progress" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("preserves explicit aria-label and aria-labelledby contracts", () => {
|
||||
const { rerender } = render(<Progress aria-label="Explicit progress" label="Visible label" value={50} />);
|
||||
expect(screen.getByRole("progressbar", { name: "Explicit progress" })).toBeInTheDocument();
|
||||
|
||||
rerender(
|
||||
<>
|
||||
<span id="external-progress-label">External progress</span>
|
||||
<Progress aria-labelledby="external-progress-label" label="Visible label" value={50} />
|
||||
</>
|
||||
);
|
||||
const progress = screen.getByRole("progressbar", { name: "External progress" });
|
||||
expect(progress).not.toHaveAttribute("aria-label");
|
||||
});
|
||||
});
|
||||
+12
-2
@@ -1,5 +1,7 @@
|
||||
"use client";
|
||||
import { Progress as ProgressComponent } from "./Progress";
|
||||
import React from "react";
|
||||
|
||||
import { Progress as ProgressComponent, type ProgressRootProps } from "./Progress";
|
||||
|
||||
/**
|
||||
* Add wrapper components and business logic here.
|
||||
@@ -7,4 +9,12 @@ import { Progress as ProgressComponent } from "./Progress";
|
||||
* Learn more: https://docs.subframe.com/concepts/syncing-components#wrapping-components
|
||||
*/
|
||||
|
||||
export const Progress = ProgressComponent;
|
||||
const ProgressRoot = React.forwardRef<HTMLDivElement, ProgressRootProps>(function ProgressRoot(props, ref) {
|
||||
const accessibleLabel =
|
||||
props["aria-label"] ?? (props["aria-labelledby"] ? undefined : typeof props.label === "string" ? props.label : undefined);
|
||||
return <ProgressComponent {...props} aria-label={accessibleLabel} ref={ref} />;
|
||||
});
|
||||
|
||||
export const Progress = Object.assign(ProgressRoot, {
|
||||
Indicator: ProgressComponent.Indicator,
|
||||
});
|
||||
Reference in new issue
Block a user