diff --git a/e2e/layers-list.spec.ts b/e2e/layers-list.spec.ts index 56c3529b..85cdd4a1 100644 --- a/e2e/layers-list.spec.ts +++ b/e2e/layers-list.spec.ts @@ -1,4 +1,4 @@ -import { beforeEach, describe, test } from "./utils/fixtures"; +import { beforeEach, describe, expect, test } from "./utils/fixtures"; import { MaputnikDriver } from "./maputnik-driver"; describe("layers list", () => { @@ -47,6 +47,14 @@ describe("layers list", () => { }); }); + test("should title the visibility button with the action it performs", async () => { + const key = "layer-list-item:" + id + ":toggle-visibility"; + // A visible layer is about to be hidden, and a hidden one to be shown. + await expect(get.elementByTestId(key)).toHaveAttribute("title", "hide"); + await when.click(key); + await expect(get.elementByTestId(key)).toHaveAttribute("title", "show"); + }); + describe("when clicking hide", () => { beforeEach(async () => { await when.click("layer-list-item:" + id + ":toggle-visibility"); diff --git a/src/components/LayerListItem.tsx b/src/components/LayerListItem.tsx index 94fd1f95..f4d9d475 100644 --- a/src/components/LayerListItem.tsx +++ b/src/components/LayerListItem.tsx @@ -32,6 +32,8 @@ const DraggableLabel: React.FC = (props) => { type IconActionProps = { action: string + /** Tooltip text, for buttons whose action reads differently from their icon. */ + title?: string onClick(...args: unknown[]): unknown wdKey?: string classBlockName?: string @@ -62,7 +64,7 @@ class IconAction extends React.Component { return