Skip to content

Commit d854721

Browse files
committed
Restore DB source palettes and remove user colors on unpin - PR_26156_173-palette-source-list-and-unpin-delete
1 parent 2f9b715 commit d854721

6 files changed

Lines changed: 32 additions & 11 deletions

docs_build/dev/reports/coverage_changed_js_guardrail.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Missing changed runtime JS files are WARN, not FAIL.
66
Source: Playwright/Chromium built-in V8 coverage from the active Playwright run.
77

88
Changed runtime JS files considered:
9-
(86%) toolbox/colors/palette-workspace-repository.js - executed lines 1103/1103; executed functions 107/124
9+
(87%) toolbox/colors/palette-workspace-repository.js - executed lines 1118/1118; executed functions 110/127
1010
(95%) toolbox/colors/colors.js - executed lines 745/745; executed functions 74/78
1111
(100%) toolbox/colors/palette-source-mock-db.js - executed lines 927/927; executed functions 6/6
1212

docs_build/dev/reports/palette-source-list-and-unpin-delete-report.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ PASS
1212
- Ensured active user palette removal updates the mock DB `palette_colors` table, count, and selected state.
1313
- Ensured active user palette removal does not remove source palette records.
1414
- Kept source pinning duplicate-safe.
15+
- Removed the selected/base color from Color Harmony Schemes output so harmony swatches only show distinct generated colors.
1516

1617
## Implementation Notes
1718
- Source palette records are provided by `toolbox/colors/palette-source-mock-db.js` and loaded by `createPaletteToolMockDbTables()`.
1819
- Source labels come from mock DB records, so dropdown labels render as `8-color set`, `16-color set`, `32-color set`, `W3C`, and `JavaScript`.
1920
- Palette options sort by label with numeric-aware ordering.
2021
- `repository.removeSwatch(symbol)` removes a specific active palette color and clears selection when the removed color was selected.
22+
- Harmony suggestions filter out the selected swatch RGB and renumber calculated labels after filtering.
2123
- The active palette pin indicator now receives pointer events through the existing reusable Theme V2 swatch pin pattern.
2224

2325
## Validation

docs_build/dev/reports/playwright_v8_coverage_report.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ Exercised tool entry points detected:
1717
(83%) Theme V2 Shared JS - exercised 2 runtime JS files
1818

1919
Changed runtime JS files covered:
20-
(86%) toolbox/colors/palette-workspace-repository.js - executed lines 1103/1103; executed functions 107/124
20+
(87%) toolbox/colors/palette-workspace-repository.js - executed lines 1118/1118; executed functions 110/127
2121
(95%) toolbox/colors/colors.js - executed lines 745/745; executed functions 74/78
2222
(100%) toolbox/colors/palette-source-mock-db.js - executed lines 927/927; executed functions 6/6
2323

2424
Files with executed line/function counts where available:
2525
(65%) toolbox/project-workspace/project-workspace-mock-repository.js - executed lines 402/402; executed functions 20/31
2626
(75%) toolbox/toolRegistry.js - executed lines 1754/1754; executed functions 27/36
2727
(80%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 205/205; executed functions 16/20
28-
(86%) toolbox/colors/palette-workspace-repository.js - executed lines 1103/1103; executed functions 107/124
2928
(87%) assets/theme-v2/js/tool-display-mode.js - executed lines 201/201; executed functions 13/15
29+
(87%) toolbox/colors/palette-workspace-repository.js - executed lines 1118/1118; executed functions 110/127
3030
(95%) toolbox/colors/colors.js - executed lines 745/745; executed functions 74/78
3131
(100%) toolbox/colors/palette-source-mock-db.js - executed lines 927/927; executed functions 6/6
3232

@@ -35,6 +35,6 @@ Uncovered or low-coverage changed JS files:
3535

3636
Changed JS files considered:
3737
(0%) tests/playwright/tools/PaletteToolMockRepository.spec.mjs - changed JS file not collected as browser runtime coverage
38-
(86%) toolbox/colors/palette-workspace-repository.js - changed JS file with browser V8 coverage
38+
(87%) toolbox/colors/palette-workspace-repository.js - changed JS file with browser V8 coverage
3939
(95%) toolbox/colors/colors.js - changed JS file with browser V8 coverage
4040
(100%) toolbox/colors/palette-source-mock-db.js - changed JS file with browser V8 coverage

docs_build/dev/reports/testing_lane_execution_report.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ PASS
3636
- Palette Colors count updates after add/remove: PASS.
3737
- Selected state clears when selected color is removed: PASS.
3838
- Source palette records remain available after active color removal: PASS.
39+
- Color Harmony Schemes does not render the selected/base swatch: PASS.
40+
- Harmony Add Selected and Add All continue from the remaining generated swatches: PASS.
3941

4042
## Impacted Lane
4143
- Palette Tool runtime/UI lane.

tests/playwright/tools/PaletteToolMockRepository.spec.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ test("Palette repository owns active project swatches without mutating invalid p
263263
expect(repository.createHarmonySuggestions(repository.findSwatch("R"), {
264264
matchSource: "calculated",
265265
schemeId: "triadic"
266-
})).toHaveLength(3);
266+
})).toHaveLength(2);
267267

268268
repository.selectSwatch("R");
269269
repository.recordSwatchUsage({ assetId: "asset.color.red", symbol: "R", toolId: "assets" });
@@ -346,10 +346,9 @@ test("Palette Tool adds, updates, pins, validates, and shows project-owned detai
346346
await page.locator("[data-palette-source-pin-all]").click();
347347
await expect(page.locator("[data-palette-count]")).toHaveText("1");
348348
await expect(page.locator("[data-palette-log]")).toContainText("0 pinned, 1 already pinned");
349-
await expect(page.locator("[data-palette-harmony-choice]")).toHaveCount(2);
349+
await expect(page.locator("[data-palette-harmony-choice]")).toHaveCount(0);
350350
await expect(page.locator("[data-palette-harmony-list]")).not.toContainText(/Complementary \d:/);
351-
await expect(page.locator("[data-palette-harmony-choice]").first()).toHaveAttribute("title", /^Scheme: Complementary\nLabel: Complementary 1\nHex: #[0-9A-F]{6}$/);
352-
await expect(page.locator("[data-palette-harmony-choice]").first()).toHaveAttribute("aria-label", /Complementary 1 #[0-9A-F]{6} from Complementary/);
351+
await expect(page.locator("[data-palette-harmony-list]")).toContainText("No harmony scheme colors available.");
353352
await page.locator("[data-palette-user-list] [data-palette-swatch-name='Black'] [data-palette-pin-indicator]").click();
354353
await expect(page.locator("[data-palette-count]")).toHaveText("0");
355354
await expect(page.locator("[data-palette-selected-summary]")).toHaveText("None");
@@ -410,8 +409,10 @@ test("Palette Tool adds, updates, pins, validates, and shows project-owned detai
410409
await expect(page.locator("[data-palette-selected-details]")).toHaveCount(0);
411410
await expect(page.locator("[data-palette-project-accordion]")).not.toContainText(/Symbol:|Hex:|Name:|Source:|Tags:/);
412411
await expect(page.locator("[data-palette-table-counts]")).toContainText("palette_colors");
413-
await expect(page.locator("[data-palette-harmony-choice]")).toHaveCount(2);
412+
await expect(page.locator("[data-palette-harmony-choice]")).toHaveCount(1);
414413
await expect(page.locator("[data-palette-harmony-list]")).not.toContainText(/Complementary \d:/);
414+
await expect(page.locator("[data-palette-harmony-choice]").first()).toHaveAttribute("title", /^Scheme: Complementary\nLabel: Complementary 1\nHex: #[0-9A-F]{6}$/);
415+
await expect(page.locator("[data-palette-harmony-choice]").first()).toHaveAttribute("aria-label", /Complementary 1 #[0-9A-F]{6} from Complementary/);
415416

416417
const activePreviewTile = page.locator("[data-palette-swatch-row='H']");
417418
await page.locator("[data-palette-user-sort] [data-palette-sort-key='hue']").click();
@@ -461,7 +462,7 @@ test("Palette Tool adds, updates, pins, validates, and shows project-owned detai
461462
await expect(page.locator("[data-palette-log]")).toHaveText("Editor form cleared.");
462463

463464
await page.locator("[data-palette-harmony-scheme]").selectOption("triadic");
464-
await expect(page.locator("[data-palette-harmony-choice]")).toHaveCount(3);
465+
await expect(page.locator("[data-palette-harmony-choice]")).toHaveCount(2);
465466
await expect(page.locator("[data-palette-harmony-list]")).not.toContainText(/Triadic \d:/);
466467
await expect(page.locator("[data-palette-harmony-choice='1']")).toHaveAttribute("title", /^Scheme: Triadic\nLabel: Triadic 2\nHex: #[0-9A-F]{6}$/);
467468
await expect(page.locator("[data-palette-harmony-choice='1']")).toHaveAttribute("aria-label", /Triadic 2 #[0-9A-F]{6} from Triadic/);

toolbox/colors/palette-workspace-repository.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,22 @@ function uniqueSuggestions(suggestions) {
463463
});
464464
}
465465

466+
function withoutBaseColorSuggestions(suggestions, baseHex, schemeLabel) {
467+
let calculatedIndex = 0;
468+
return suggestions
469+
.filter((suggestion) => rgbKey(suggestion.hex) !== rgbKey(baseHex))
470+
.map((suggestion) => {
471+
if (suggestion.sourceName !== "Calculated") {
472+
return suggestion;
473+
}
474+
calculatedIndex += 1;
475+
return {
476+
...suggestion,
477+
name: `${schemeLabel} ${calculatedIndex}`
478+
};
479+
});
480+
}
481+
466482
function harmonyForSwatch(swatch, options = {}, sourcePaletteData = null) {
467483
const rgb = hexToRgb(swatch?.hex);
468484
if (!rgb) {
@@ -501,7 +517,7 @@ function harmonyForSwatch(swatch, options = {}, sourcePaletteData = null) {
501517
};
502518
});
503519

504-
return uniqueSuggestions(calculated);
520+
return withoutBaseColorSuggestions(uniqueSuggestions(calculated), swatch.hex, scheme.label);
505521
}
506522

507523
function nextAvailableSymbol(existingSwatches, seedText = "") {

0 commit comments

Comments
 (0)