|
13 | 13 |
|
14 | 14 | import { strictEqual, ok, deepStrictEqual } from 'node:assert'; |
15 | 15 | import { delay } from '../../testUtils/delay.js'; |
| 16 | +import { getLocalStorage } from '../../testUtils/localStorage.js'; |
| 17 | +import { StorageKeysEnum } from '../../../public/common/enums/storageKeys.enum.js'; |
16 | 18 |
|
17 | 19 | const OBJECT_TREE_PAGE_PARAM = '?page=objectTree'; |
18 | 20 | const SORTING_BUTTON_PATH = 'header > div > div > div:nth-child(3) > div > button'; |
@@ -79,6 +81,73 @@ export const objectTreePageTests = async (url, page, timeout = 5000, testParent) |
79 | 81 | }, |
80 | 82 | ); |
81 | 83 |
|
| 84 | + await testParent.test( |
| 85 | + 'should have default panel width of 50% when width is null in localStorage', |
| 86 | + { timeout }, |
| 87 | + async () => { |
| 88 | + const defaultValue = '50%'; |
| 89 | + const panelWidth = await page.evaluate(() => |
| 90 | + document.querySelector('section > div > div > div:nth-child(1)').style.width); |
| 91 | + const personId = await page.evaluate(() => window.model.session.personid); |
| 92 | + const storedPanelWidth = await getLocalStorage( |
| 93 | + page, |
| 94 | + `${StorageKeysEnum.OBJECT_VIEW_LEFT_PANEL_WIDTH}-${personId}`, |
| 95 | + ); |
| 96 | + strictEqual(storedPanelWidth, null); |
| 97 | + strictEqual(panelWidth, defaultValue); |
| 98 | + }, |
| 99 | + ); |
| 100 | + |
| 101 | + await testParent.test( |
| 102 | + 'should change and store panel width when dragging the divider', |
| 103 | + { timeout }, |
| 104 | + async () => { |
| 105 | + const dragAmount = 35; |
| 106 | + const [container, divider] = await Promise.all([ |
| 107 | + page.$('body > div.absolute-fill.flex-column > div > section'), |
| 108 | + page.$('section > div > div > div:nth-child(2)'), |
| 109 | + ]); |
| 110 | + const [containerBB, dividerBB] = await Promise.all([container.boundingBox(), divider.boundingBox()]); |
| 111 | + |
| 112 | + const centerX = dividerBB.x + dividerBB.width / 2; |
| 113 | + const centerY = dividerBB.y + dividerBB.height / 2; |
| 114 | + const targetX = containerBB.x + containerBB.width * (dragAmount / 100); |
| 115 | + |
| 116 | + await page.mouse.move(centerX, centerY); |
| 117 | + await page.mouse.down(); |
| 118 | + await page.mouse.move(targetX, centerY, { steps: 5 }); |
| 119 | + await page.mouse.up(); |
| 120 | + await delay(300); |
| 121 | + |
| 122 | + const [personId, panelWidth] = await page.evaluate(() => [ |
| 123 | + window.model.session.personid, |
| 124 | + document.querySelector('section > div > div > div:nth-child(1)').style.width, |
| 125 | + ]); |
| 126 | + const storedWidth = await getLocalStorage(page, `${StorageKeysEnum.OBJECT_VIEW_LEFT_PANEL_WIDTH}-${personId}`); |
| 127 | + |
| 128 | + strictEqual(panelWidth, `${dragAmount}%`); |
| 129 | + strictEqual(storedWidth, dragAmount.toString()); |
| 130 | + }, |
| 131 | + ); |
| 132 | + |
| 133 | + await testParent.test( |
| 134 | + 'should maintain panel width from localStorage on page reload', |
| 135 | + { timeout }, |
| 136 | + async () => { |
| 137 | + const dragAmount = 35; |
| 138 | + await page.reload({ waitUntil: 'networkidle0' }); |
| 139 | + await page.evaluate(() => document.querySelector('tr.object-selectable:nth-child(2)').click()); |
| 140 | + await delay(500); |
| 141 | + await page.evaluate(() => document.querySelector('tr.object-selectable:nth-child(3)').click()); |
| 142 | + await delay(500); |
| 143 | + await page.evaluate(() => document.querySelector('tr.object-selectable:nth-child(4)').click()); |
| 144 | + await delay(1000); |
| 145 | + const panelWidth = await page.evaluate(() => |
| 146 | + document.querySelector('section > div > div > div:nth-child(1)').style.width); |
| 147 | + strictEqual(panelWidth, `${dragAmount}%`); |
| 148 | + }, |
| 149 | + ); |
| 150 | + |
82 | 151 | await testParent.test( |
83 | 152 | 'should correctly render the path as first in the object info panel', |
84 | 153 | { timeout }, |
|
0 commit comments