@@ -8103,12 +8103,20 @@ test.describe("Workspace Manager V2 bootstrap", () => {
81038103
81048104 await page.locator("#harmonyMatchSourceSelect").selectOption("calculated");
81058105 await page.locator("#harmonySchemeSelect").selectOption("complementary");
8106- await expect(page.locator("#harmonyColorList [data-harmony-index='0']")).toHaveAttribute("data-harmony-hex", "#00FFFF");
8107- await expect(page.locator("#harmonyColorList [data-harmony-index='0'] .palette-manager-v2__harmony-text")).toHaveText("Complementary - +180 deg");
8108- await expect(page.locator("#harmonyColorList [data-harmony-index='0'] .palette-manager-v2__harmony-meta")).toHaveText("#00FFFF");
8106+ const calculatedHarmonyTile = page.locator("#harmonyColorList [data-harmony-index='0']");
8107+ await expect(calculatedHarmonyTile).toHaveAttribute("data-harmony-hex", "#00FFFF");
8108+ await expect(calculatedHarmonyTile).toHaveAttribute("data-harmony-label", "Complementary - +180 deg");
8109+ await expect(calculatedHarmonyTile).toHaveAttribute("title", /Name: Complementary - \+180 deg[\s\S]*Hex: #00FFFF/);
8110+ await expect(calculatedHarmonyTile).toHaveText("");
8111+ const calculatedHarmonyTileBox = await calculatedHarmonyTile.boundingBox();
8112+ expect(Math.round(calculatedHarmonyTileBox.width)).toBe(40);
8113+ expect(Math.round(calculatedHarmonyTileBox.height)).toBe(40);
81098114 await page.locator("#addSelectedHarmonyButton").click();
81108115 await expect(page.locator("#userPaletteCount")).toHaveText("2 user swatches");
81118116 await expect(page.locator("#paletteStatus")).toHaveText(/OK Added selected harmony color/);
8117+ await expect.poll(async () => {
8118+ return page.evaluate(() => window.paletteManagerV2App.getPaletteValue().swatches.at(-1).name);
8119+ }).toBe("Complementary - +180 deg");
81128120
81138121 await page.locator('#userSwatchList [aria-label="Edit Harmony Base Red"]').click();
81148122 await expect(page.locator("#harmonyColorList [data-harmony-index='0']")).toHaveAttribute("data-harmony-hex", "#00FFFF");
@@ -8134,18 +8142,24 @@ test.describe("Workspace Manager V2 bootstrap", () => {
81348142 const harmonyHex = harmonyButton.dataset.harmonyHex;
81358143 const paletteName = harmonyButton.dataset.harmonyPalette;
81368144 const swatchName = harmonyButton.dataset.harmonySwatchName;
8137- const label = harmonyButton.querySelector(".palette-manager-v2__harmony-text").textContent;
8138- const meta = harmonyButton.querySelector(".palette-manager-v2__harmony-meta").textContent;
8145+ const label = harmonyButton.dataset.harmonyLabel;
8146+ const readout = harmonyButton.getAttribute("title");
8147+ const ariaLabel = harmonyButton.getAttribute("aria-label");
8148+ const textContent = harmonyButton.textContent;
81398149 const expectedPaletteName = formatPaletteName(window.paletteList.SOURCE_PALETTE_LABELS[sourceId] || sourceId);
81408150 const sourceMatch = (window.paletteList.SOURCE_PALETTES[sourceId] || [])
81418151 .find((swatch) => swatch.hex.toUpperCase() === harmonyHex && swatch.name === swatchName);
8142- return { expectedPaletteName, harmonyHex, isFromCurrentSource: Boolean(sourceMatch), label, meta, paletteName , swatchName };
8152+ return { ariaLabel, expectedPaletteName, harmonyHex, isFromCurrentSource: Boolean(sourceMatch), label, paletteName, readout , swatchName, textContent };
81438153 });
81448154 expect(sourceMatchState.isFromCurrentSource).toBe(true);
81458155 expect(sourceMatchState.paletteName).toBe(sourceMatchState.expectedPaletteName);
81468156 expect(sourceMatchState.label).toBe(`${sourceMatchState.expectedPaletteName} - ${sourceMatchState.swatchName}`);
81478157 expect(sourceMatchState.label).not.toContain("Closest");
8148- expect(sourceMatchState.meta).toBe(sourceMatchState.harmonyHex);
8158+ expect(sourceMatchState.textContent).toBe("");
8159+ expect(sourceMatchState.readout).toContain(`Palette: ${sourceMatchState.expectedPaletteName}`);
8160+ expect(sourceMatchState.readout).toContain(`Name: ${sourceMatchState.swatchName}`);
8161+ expect(sourceMatchState.readout).toContain(`Hex: ${sourceMatchState.harmonyHex}`);
8162+ expect(sourceMatchState.ariaLabel).toContain(sourceMatchState.harmonyHex);
81498163
81508164 await page.locator("#harmonyMatchSourceSelect").selectOption("all-palettes");
81518165 const allMatchState = await page.evaluate(() => {
@@ -8154,21 +8168,78 @@ test.describe("Workspace Manager V2 bootstrap", () => {
81548168 const harmonyHex = harmonyButton.dataset.harmonyHex;
81558169 const paletteName = harmonyButton.dataset.harmonyPalette;
81568170 const swatchName = harmonyButton.dataset.harmonySwatchName;
8157- const label = harmonyButton.querySelector(".palette-manager-v2__harmony-text").textContent;
8158- const meta = harmonyButton.querySelector(".palette-manager-v2__harmony-meta").textContent;
8171+ const label = harmonyButton.dataset.harmonyLabel;
8172+ const readout = harmonyButton.getAttribute("title");
8173+ const textContent = harmonyButton.textContent;
81598174 const allMatch = Object.entries(window.paletteList.SOURCE_PALETTES)
81608175 .flatMap(([sourceId, swatches]) => swatches.map((swatch) => ({ sourceId, swatch })))
81618176 .find(({ sourceId, swatch }) => {
81628177 return swatch.hex.toUpperCase() === harmonyHex
81638178 && swatch.name === swatchName
81648179 && formatPaletteName(window.paletteList.SOURCE_PALETTE_LABELS[sourceId] || sourceId) === paletteName;
81658180 });
8166- return { harmonyHex, isFromAnySource: Boolean(allMatch), label, meta, paletteName , swatchName };
8181+ return { harmonyHex, isFromAnySource: Boolean(allMatch), label, paletteName, readout , swatchName, textContent };
81678182 });
81688183 expect(allMatchState.isFromAnySource).toBe(true);
81698184 expect(allMatchState.label).toBe(`${allMatchState.paletteName} - ${allMatchState.swatchName}`);
81708185 expect(allMatchState.label).not.toContain("Closest");
8171- expect(allMatchState.meta).toBe(allMatchState.harmonyHex);
8186+ expect(allMatchState.textContent).toBe("");
8187+ expect(allMatchState.readout).toContain(`Palette: ${allMatchState.paletteName}`);
8188+ expect(allMatchState.readout).toContain(`Name: ${allMatchState.swatchName}`);
8189+ expect(allMatchState.readout).toContain(`Hex: ${allMatchState.harmonyHex}`);
8190+
8191+ await page.locator('#userSwatchList [aria-label="Edit Harmony Base Red"]').click();
8192+ await page.locator("#harmonyMatchSourceSelect").selectOption("source-palette");
8193+ await page.locator("#harmonySchemeSelect").selectOption("achromatic");
8194+ const matchedBlackTile = page.locator("#harmonyColorList [data-harmony-index='1']");
8195+ await expect(matchedBlackTile).toHaveAttribute("data-harmony-swatch-name", "Black");
8196+ await expect(matchedBlackTile).toHaveText("");
8197+ await expect(matchedBlackTile).toHaveAttribute("aria-label", /Palette: .*Name: Black.*Hex:/);
8198+ const matchedBlackTileBox = await matchedBlackTile.boundingBox();
8199+ expect(Math.round(matchedBlackTileBox.width)).toBe(40);
8200+ expect(Math.round(matchedBlackTileBox.height)).toBe(40);
8201+ await matchedBlackTile.focus();
8202+ await expect(matchedBlackTile).toBeFocused();
8203+ await matchedBlackTile.click();
8204+ const matchedBlackState = await matchedBlackTile.evaluate((button) => ({
8205+ hex: button.dataset.harmonyHex,
8206+ label: button.dataset.harmonyLabel,
8207+ paletteName: button.dataset.harmonyPalette,
8208+ swatchName: button.dataset.harmonySwatchName
8209+ }));
8210+ await page.locator("#addSelectedHarmonyButton").click();
8211+ await expect(page.locator("#userPaletteCount")).toHaveText("5 user swatches");
8212+ const addedBlackSwatch = await page.evaluate(() => window.paletteManagerV2App.getPaletteValue().swatches.at(-1));
8213+ expect(addedBlackSwatch.hex).toBe(matchedBlackState.hex);
8214+ expect(addedBlackSwatch.name).toBe("Black");
8215+ expect(addedBlackSwatch.name).toBe(matchedBlackState.swatchName);
8216+ expect(addedBlackSwatch.name).not.toContain(matchedBlackState.paletteName);
8217+ expect(matchedBlackState.label).toBe(`${matchedBlackState.paletteName} - Black`);
8218+
8219+ await page.locator('#userSwatchList [aria-label="Edit Harmony Base Red"]').click();
8220+ await page.locator("#harmonyMatchSourceSelect").selectOption("source-palette");
8221+ await page.locator("#harmonySchemeSelect").selectOption("achromatic");
8222+ const sourceAchromaticMatches = await page.evaluate(() => {
8223+ return Array.from(document.querySelectorAll("#harmonyColorList [data-harmony-index]"))
8224+ .map((button) => ({
8225+ hex: button.dataset.harmonyHex,
8226+ paletteName: button.dataset.harmonyPalette,
8227+ swatchName: button.dataset.harmonySwatchName
8228+ }));
8229+ });
8230+ const beforeAddAllCount = await page.evaluate(() => window.paletteManagerV2App.getPaletteValue().swatches.length);
8231+ await page.locator("#addAllHarmonyButton").click();
8232+ await expect(page.locator("#paletteStatus")).toHaveText(/OK Added \d+ harmony colors\. Skipped \d+ duplicates\./);
8233+ const addAllNamingState = await page.evaluate((beforeCount) => {
8234+ return window.paletteManagerV2App.getPaletteValue().swatches.slice(beforeCount);
8235+ }, beforeAddAllCount);
8236+ expect(addAllNamingState.length).toBeGreaterThan(0);
8237+ addAllNamingState.forEach((swatch) => {
8238+ const match = sourceAchromaticMatches.find((candidate) => candidate.hex === swatch.hex);
8239+ expect(match).toBeTruthy();
8240+ expect(swatch.name).toBe(match.swatchName);
8241+ expect(swatch.name).not.toContain(match.paletteName);
8242+ });
81728243 expect(pageErrors).toEqual([]);
81738244 } finally {
81748245 await workspaceV2CoverageReporter.stop(page);
0 commit comments