@@ -53,6 +53,43 @@ async function expectButtonLeftAligned(page, buttonSelector, containerSelector)
5353 expect ( metrics . buttonLeft ) . toBeLessThan ( metrics . containerLeft + metrics . containerWidth / 2 ) ;
5454}
5555
56+ async function expectExpandedNotesChildIndentation ( page , ideaId , expectedInputRows = 0 ) {
57+ const metrics = await page . locator ( `[data-idea-board-expanded-row='${ ideaId } ']` ) . evaluate ( ( row , targetIdeaId ) => {
58+ const expandedCell = row . querySelector ( ":scope > td" ) ;
59+ const childSurface = row . querySelector ( ".idea-board-notes-child-surface" ) ;
60+ const noteCell = row . querySelector ( `[data-idea-board-notes-table='${ targetIdeaId } '] tbody tr td:first-child` ) ;
61+ const noteInput = row . querySelector ( "[data-idea-board-note-input]" ) ;
62+ const addNote = row . querySelector ( `[data-idea-board-add-note='${ targetIdeaId } ']` ) ;
63+ const addNoteActions = row . querySelector ( ".idea-board-notes-child-actions" ) ;
64+ const expandedStyles = getComputedStyle ( expandedCell ) ;
65+ const noteCellStyles = getComputedStyle ( noteCell ) ;
66+ const addNoteActionStyles = getComputedStyle ( addNoteActions ) ;
67+ const expandedRect = expandedCell . getBoundingClientRect ( ) ;
68+ const childRect = childSurface . getBoundingClientRect ( ) ;
69+ const noteCellRect = noteCell . getBoundingClientRect ( ) ;
70+ const expandedPadding = Number . parseFloat ( expandedStyles . paddingLeft || "0" ) ;
71+ const noteCellPadding = Number . parseFloat ( noteCellStyles . paddingLeft || "0" ) ;
72+ return {
73+ addNoteLeft : addNote . getBoundingClientRect ( ) . left ,
74+ childSurfaceLeft : childRect . left ,
75+ expandedContentLeft : expandedRect . left + expandedPadding ,
76+ expectedContentLeft : expandedRect . left + 2 * ( expandedPadding + noteCellPadding ) ,
77+ inputLeft : noteInput ? noteInput . getBoundingClientRect ( ) . left : null ,
78+ inputRows : row . querySelectorAll ( "[data-idea-board-note-input-row]" ) . length ,
79+ noteContentLeft : noteCellRect . left + noteCellPadding ,
80+ actionContentLeft : addNoteActions . getBoundingClientRect ( ) . left + Number . parseFloat ( addNoteActionStyles . paddingLeft || "0" ) ,
81+ } ;
82+ } , ideaId ) ;
83+ expect ( metrics . childSurfaceLeft ) . toBeGreaterThan ( metrics . expandedContentLeft ) ;
84+ expect ( Math . abs ( metrics . noteContentLeft - metrics . expectedContentLeft ) ) . toBeLessThanOrEqual ( 2 ) ;
85+ expect ( Math . abs ( metrics . addNoteLeft - metrics . expectedContentLeft ) ) . toBeLessThanOrEqual ( 2 ) ;
86+ expect ( Math . abs ( metrics . actionContentLeft - metrics . expectedContentLeft ) ) . toBeLessThanOrEqual ( 2 ) ;
87+ expect ( metrics . inputRows ) . toBe ( expectedInputRows ) ;
88+ if ( expectedInputRows > 0 ) {
89+ expect ( Math . abs ( metrics . inputLeft - metrics . expectedContentLeft ) ) . toBeLessThanOrEqual ( 2 ) ;
90+ }
91+ }
92+
5693test ( "Idea Board uses DB-shaped accordion table ideas and notes" , async ( { page } ) => {
5794 const server = await startRepoServer ( ) ;
5895 const previousApiUrl = process . env . GAMEFOUNDRY_API_URL ;
@@ -130,7 +167,7 @@ test("Idea Board uses DB-shaped accordion table ideas and notes", async ({ page
130167 await expect ( page . locator ( "[data-idea-board-expanded-row='top-thoughts'] > td > .content-stack" ) ) . toHaveCount ( 0 ) ;
131168 await expect ( page . locator ( "[data-idea-board-notes-table='top-thoughts'] th[scope='col']" ) ) . toHaveText ( [ "Note" , "Actions" ] ) ;
132169 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 ") ;
170+ await expectExpandedNotesChildIndentation ( page , "top-thoughts" ) ;
134171 await expect ( page . locator ( "[data-idea-board-notes-table] th[scope='col']" , { hasText : "Type" } ) ) . toHaveCount ( 0 ) ;
135172 await expect ( page . locator ( "[data-idea-board-notes-table] th[scope='col']" , { hasText : "Created By" } ) ) . toHaveCount ( 0 ) ;
136173 await expect ( page . locator ( "[data-idea-board-notes-table] th[scope='col']" , { hasText : "Created" } ) ) . toHaveCount ( 0 ) ;
@@ -141,13 +178,15 @@ test("Idea Board uses DB-shaped accordion table ideas and notes", async ({ page
141178 await expect ( systemNote . locator ( "[data-idea-board-note-action='delete']" ) ) . toHaveCount ( 0 ) ;
142179 await systemNote . locator ( "[data-idea-board-note-action='edit']" ) . click ( ) ;
143180 await expect ( page . locator ( "[data-idea-board-note-input-row] [data-idea-board-note-action]" ) ) . toHaveText ( [ "Save" , "Cancel" ] ) ;
181+ await expectExpandedNotesChildIndentation ( page , "top-thoughts" , 1 ) ;
144182 await page . locator ( "[data-idea-board-note-input]" ) . fill ( "System note can be edited in-place." ) ;
145183 await page . locator ( "[data-idea-board-note-action='save']" ) . click ( ) ;
146184 await expect ( page . locator ( "[data-idea-board-notes-table='top-thoughts']" ) ) . toContainText ( "System note can be edited in-place." ) ;
147185 await expect ( page . locator ( "[data-idea-board-system-note] [data-idea-board-note-action='delete']" ) ) . toHaveCount ( 0 ) ;
148186
149187 await page . locator ( "[data-idea-board-add-note='top-thoughts']" ) . click ( ) ;
150188 await expect ( page . locator ( "[data-idea-board-note-input-row] [data-idea-board-note-action]" ) ) . toHaveText ( [ "Save" , "Cancel" ] ) ;
189+ await expectExpandedNotesChildIndentation ( page , "top-thoughts" , 1 ) ;
151190 await page . locator ( "[data-idea-board-note-input]" ) . fill ( "Add a fourth table-shaped note." ) ;
152191 await page . locator ( "[data-idea-board-note-action='save']" ) . click ( ) ;
153192 await expect ( page . locator ( "[data-idea-board-notes-table='top-thoughts']" ) ) . toContainText ( "Add a fourth table-shaped note." ) ;
0 commit comments