Skip to content

Commit d55a668

Browse files
authored
PR_26171_037 align idea board add actions
Align Idea Board Add Idea and Add Note actions to the left. Validation: - node --check toolbox/idea-board/index.js - node --check tests/playwright/tools/IdeaBoardTableNotes.spec.mjs - node --check tests/playwright/tools/ToolboxRoutePages.spec.mjs - npx playwright test tests/playwright/tools/IdeaBoardTableNotes.spec.mjs --project=playwright --workers=1 --reporter=line - npx playwright test tests/playwright/tools/ToolboxRoutePages.spec.mjs --project=playwright --workers=1 --reporter=line -g "Idea Board launches"
1 parent bb5c459 commit d55a668

3 files changed

Lines changed: 45 additions & 4 deletions

File tree

tests/playwright/tools/IdeaBoardTableNotes.spec.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ async function expectIdeaChevron(page, ideaId, iconName) {
3636
expect(metrics.maskImage).toContain(iconName);
3737
}
3838

39+
async function expectButtonLeftAligned(page, buttonSelector, containerSelector) {
40+
const metrics = await page.locator(buttonSelector).evaluate((button, selector) => {
41+
const container = button.ownerDocument.querySelector(selector);
42+
const buttonRect = button.getBoundingClientRect();
43+
const containerRect = container.getBoundingClientRect();
44+
const containerStyles = getComputedStyle(container);
45+
return {
46+
buttonLeft: buttonRect.left,
47+
containerLeft: containerRect.left,
48+
containerWidth: containerRect.width,
49+
expectedLeft: containerRect.left + Number.parseFloat(containerStyles.paddingLeft || "0"),
50+
};
51+
}, containerSelector);
52+
expect(Math.abs(metrics.buttonLeft - metrics.expectedLeft)).toBeLessThanOrEqual(2);
53+
expect(metrics.buttonLeft).toBeLessThan(metrics.containerLeft + metrics.containerWidth / 2);
54+
}
55+
3956
test("Idea Board uses DB-shaped accordion table ideas and notes", async ({ page }) => {
4057
const server = await startRepoServer();
4158
const previousApiUrl = process.env.GAMEFOUNDRY_API_URL;
@@ -78,6 +95,9 @@ test("Idea Board uses DB-shaped accordion table ideas and notes", async ({ page
7895
await expect(page.locator("[data-idea-board-idea-row]")).toHaveCount(3);
7996
await expect(page.locator("[data-idea-board-expanded-row]")).toHaveCount(0);
8097
await expect(page.locator("[data-idea-board-add-idea-row]")).toHaveCount(1);
98+
await expect(page.locator("[data-idea-board-add-idea]")).toHaveText("Add Idea");
99+
await expectButtonLeftAligned(page, "[data-idea-board-add-idea]", "[data-idea-board-add-idea-row] > td");
100+
await expect(page.getByText(/another/i)).toHaveCount(0);
81101
await expect(page.locator("[data-idea-board-notes-chevron]")).toHaveCount(0);
82102
await expect(page.getByText("Selected idea context")).toHaveCount(0);
83103
await expect(page.getByText("Notes for Sky Orchard")).toHaveCount(0);
@@ -109,6 +129,8 @@ test("Idea Board uses DB-shaped accordion table ideas and notes", async ({ page
109129
await expect(page.locator("[data-idea-board-expanded-row='top-thoughts'] :is(h1,h2,h3,h4,h5,h6)").filter({ hasText: /^Notes$/ })).toHaveCount(0);
110130
await expect(page.locator("[data-idea-board-expanded-row='top-thoughts'] > td > .content-stack")).toHaveCount(0);
111131
await expect(page.locator("[data-idea-board-notes-table='top-thoughts'] th[scope='col']")).toHaveText(["Note", "Actions"]);
132+
await expect(page.locator("[data-idea-board-add-note='top-thoughts']")).toHaveText("Add Note");
133+
await expectButtonLeftAligned(page, "[data-idea-board-add-note='top-thoughts']", "[data-idea-board-expanded-row='top-thoughts'] > td");
112134
await expect(page.locator("[data-idea-board-notes-table] th[scope='col']", { hasText: "Type" })).toHaveCount(0);
113135
await expect(page.locator("[data-idea-board-notes-table] th[scope='col']", { hasText: "Created By" })).toHaveCount(0);
114136
await expect(page.locator("[data-idea-board-notes-table] th[scope='col']", { hasText: "Created" })).toHaveCount(0);

tests/playwright/tools/ToolboxRoutePages.spec.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,23 @@ async function expectIdeaChevron(page, ideaId, iconName) {
138138
expect(metrics.maskImage).toContain(iconName);
139139
}
140140

141+
async function expectButtonLeftAligned(page, buttonSelector, containerSelector) {
142+
const metrics = await page.locator(buttonSelector).evaluate((button, selector) => {
143+
const container = button.ownerDocument.querySelector(selector);
144+
const buttonRect = button.getBoundingClientRect();
145+
const containerRect = container.getBoundingClientRect();
146+
const containerStyles = getComputedStyle(container);
147+
return {
148+
buttonLeft: buttonRect.left,
149+
containerLeft: containerRect.left,
150+
containerWidth: containerRect.width,
151+
expectedLeft: containerRect.left + Number.parseFloat(containerStyles.paddingLeft || "0"),
152+
};
153+
}, containerSelector);
154+
expect(Math.abs(metrics.buttonLeft - metrics.expectedLeft)).toBeLessThanOrEqual(2);
155+
expect(metrics.buttonLeft).toBeLessThan(metrics.containerLeft + metrics.containerWidth / 2);
156+
}
157+
141158
test("tools route aliases render toolbox tool pages", async ({ page }) => {
142159
const server = await startRepoServer();
143160
const failedRequests = [];
@@ -249,6 +266,9 @@ test("Idea Board launches from Toolbox with accordion table notes model", async
249266
await expect(page.locator("[data-idea-board-table] > thead th[scope='col']")).toHaveText(["Idea", "Pitch", "Status", "Updated", "Notes", "Actions"]);
250267
await expect(page.locator("[data-idea-board-idea-row]")).toHaveCount(3);
251268
await expect(page.locator("[data-idea-board-expanded-row]")).toHaveCount(0);
269+
await expect(page.locator("[data-idea-board-add-idea]")).toHaveText("Add Idea");
270+
await expectButtonLeftAligned(page, "[data-idea-board-add-idea]", "[data-idea-board-add-idea-row] > td");
271+
await expect(page.getByText(/another/i)).toHaveCount(0);
252272
await expect(page.locator("[data-idea-board-notes-count='top-thoughts']")).toHaveText("3 Notes");
253273
await expect(page.locator("[data-idea-board-notes-count='sky-orchard']")).toHaveText("3 Notes");
254274
await expect(page.locator("[data-idea-board-notes-count='clockwork-courier']")).toHaveText("0 Notes");
@@ -268,6 +288,8 @@ test("Idea Board launches from Toolbox with accordion table notes model", async
268288
await expect(page.getByText("Selected idea context")).toHaveCount(0);
269289
await expect(page.getByText("Selected")).toHaveCount(0);
270290
await expect(page.locator("[data-idea-board-add-note='top-thoughts']")).toBeVisible();
291+
await expect(page.locator("[data-idea-board-add-note='top-thoughts']")).toHaveText("Add Note");
292+
await expectButtonLeftAligned(page, "[data-idea-board-add-note='top-thoughts']", "[data-idea-board-expanded-row='top-thoughts'] > td");
271293
await expect(page.locator("[data-idea-board-create-project]")).toBeVisible();
272294
await expect(page.locator("[data-idea-board-create-project]")).toBeDisabled();
273295
await expect(page.locator("style, [style], script:not([src])")).toHaveCount(0);

toolbox/idea-board/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,8 @@ function renderExpandedNotesRow(tbody, record) {
306306
function renderAddIdeaRow(tbody) {
307307
const row = document.createElement("tr");
308308
row.dataset.ideaBoardAddIdeaRow = "true";
309-
const prompt = document.createElement("td");
310-
prompt.colSpan = 5;
311-
prompt.textContent = "Add another idea";
312-
row.append(prompt);
313309
const actions = document.createElement("td");
310+
actions.colSpan = 6;
314311
const addIdea = actionButton("Add Idea", "add", "ideaBoardIdeaAction", "primary");
315312
addIdea.dataset.ideaBoardAddIdea = "true";
316313
actions.append(addIdea);

0 commit comments

Comments
 (0)