diff --git a/packages/aggrid/tests/basic.html b/packages/aggrid/tests/basic.html index b085f6e211..cfbc01b70c 100644 --- a/packages/aggrid/tests/basic.html +++ b/packages/aggrid/tests/basic.html @@ -6,8 +6,9 @@ This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. --> - + + Ag-Grid basic @@ -50,7 +51,7 @@ }; const gridDiv = document.querySelector('div.ag-theme-ix'); - const grid = new agGrid.Grid(gridDiv, gridOptions); + new agGrid.Grid(gridDiv, gridOptions); })(); diff --git a/packages/aggrid/tests/basic_v28.html b/packages/aggrid/tests/basic_v28.html index 39498ee389..d3649ed5be 100644 --- a/packages/aggrid/tests/basic_v28.html +++ b/packages/aggrid/tests/basic_v28.html @@ -6,8 +6,9 @@ This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. --> - + + Ag-Grid version 28 @@ -50,7 +51,7 @@ }; const gridDiv = document.querySelector('div.ag-theme-ix'); - const grid = new agGrid.Grid(gridDiv, gridOptions); + new agGrid.Grid(gridDiv, gridOptions); })(); diff --git a/packages/aggrid/tests/basic_v29.html b/packages/aggrid/tests/basic_v29.html index 9be3356973..42765dd5ca 100644 --- a/packages/aggrid/tests/basic_v29.html +++ b/packages/aggrid/tests/basic_v29.html @@ -6,8 +6,9 @@ This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. --> - + + Ag-Grid version 29 @@ -50,7 +51,7 @@ }; const gridDiv = document.querySelector('div.ag-theme-ix'); - const grid = new agGrid.Grid(gridDiv, gridOptions); + new agGrid.Grid(gridDiv, gridOptions); })(); diff --git a/packages/aggrid/tests/basic_v30.html b/packages/aggrid/tests/basic_v30.html index 12391df1ba..f676838619 100644 --- a/packages/aggrid/tests/basic_v30.html +++ b/packages/aggrid/tests/basic_v30.html @@ -6,8 +6,9 @@ This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. --> - + + Ag-Grid version 30 @@ -50,8 +51,7 @@ }; const gridDiv = document.querySelector('div.ag-theme-ix'); - const grid = new agGrid.Grid(gridDiv, gridOptions); + new agGrid.Grid(gridDiv, gridOptions); })(); - - + diff --git a/packages/aggrid/tests/basic_v31.html b/packages/aggrid/tests/basic_v31.html index f2da9f5722..d741acb5ff 100644 --- a/packages/aggrid/tests/basic_v31.html +++ b/packages/aggrid/tests/basic_v31.html @@ -6,8 +6,9 @@ This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. --> - + + Ag-Grid version 31 @@ -50,7 +51,7 @@ }; const gridDiv = document.querySelector('div.ag-theme-ix'); - const grid = new agGrid.Grid(gridDiv, gridOptions); + new agGrid.Grid(gridDiv, gridOptions); })(); diff --git a/packages/aggrid/tests/basic_v32.html b/packages/aggrid/tests/basic_v32.html index b085f6e211..78cffce307 100644 --- a/packages/aggrid/tests/basic_v32.html +++ b/packages/aggrid/tests/basic_v32.html @@ -6,8 +6,9 @@ This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. --> - + + Ag-Grid version 32 @@ -50,7 +51,7 @@ }; const gridDiv = document.querySelector('div.ag-theme-ix'); - const grid = new agGrid.Grid(gridDiv, gridOptions); + new agGrid.Grid(gridDiv, gridOptions); })(); diff --git a/packages/aggrid/tests/pagination.html b/packages/aggrid/tests/pagination.html index 960fc775d2..a7986ccf94 100644 --- a/packages/aggrid/tests/pagination.html +++ b/packages/aggrid/tests/pagination.html @@ -6,8 +6,9 @@ This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. --> - + + Ag-Grid pagination @@ -55,7 +56,7 @@ }; const gridDiv = document.querySelector('div.ag-theme-ix'); - const grid = new agGrid.Grid(gridDiv, gridOptions); + new agGrid.Grid(gridDiv, gridOptions); })(); diff --git a/packages/core/src/components/category-filter/category-filter.tsx b/packages/core/src/components/category-filter/category-filter.tsx index bf1d502b70..5d10b5e1d4 100644 --- a/packages/core/src/components/category-filter/category-filter.tsx +++ b/packages/core/src/components/category-filter/category-filter.tsx @@ -194,7 +194,7 @@ export class CategoryFilter { } private onInput() { - this.inputValue = this.textInput?.current?.value || ''; + this.inputValue = this.textInput?.current?.value ?? ''; const inputState = new InputState(this.inputValue, this.category); this.inputChanged.emit(inputState); diff --git a/packages/core/src/components/validation-tooltip/validation-tooltip.tsx b/packages/core/src/components/validation-tooltip/validation-tooltip.tsx index cb514c5ca0..fa79593980 100644 --- a/packages/core/src/components/validation-tooltip/validation-tooltip.tsx +++ b/packages/core/src/components/validation-tooltip/validation-tooltip.tsx @@ -221,8 +221,8 @@ export class ValidationTooltip { top: '0', left: '0', transform: `translate(${Math.round( - this.tooltipPosition?.x || 0 - )}px,${Math.round(this.tooltipPosition?.y || 0)}px)`, + this.tooltipPosition?.x ?? 0 + )}px,${Math.round(this.tooltipPosition?.y ?? 0)}px)`, }} class="validation-tooltip text-default" > diff --git a/packages/core/src/tests/utils/test/page.ts b/packages/core/src/tests/utils/test/page.ts index 97755b010b..8cbb721f21 100644 --- a/packages/core/src/tests/utils/test/page.ts +++ b/packages/core/src/tests/utils/test/page.ts @@ -16,13 +16,13 @@ import { async function extendPageFixture(page: Page, testInfo: TestInfo) { const originalGoto = page.goto.bind(page); - const originalSceenshot = page.screenshot.bind(page); + const originalScreenshot = page.screenshot.bind(page); const theme = testInfo.project.metadata?.theme ?? 'theme-classic-dark'; testInfo.annotations.push({ type: theme, }); page.goto = async (url: string, options) => { - if ((testInfo as any).componentTest) { + if (testInfo.config.metadata['componentTest'] === true) { return originalGoto(url, options); } @@ -37,12 +37,56 @@ async function extendPageFixture(page: Page, testInfo: TestInfo) { page.screenshot = async (options?: PageScreenshotOptions) => { await page.waitForTimeout(150); - return originalSceenshot(options); + return originalScreenshot(options); }; return page; } +async function mountComponent( + page: Page, + selector: string, + config?: { + headTags?: string[]; + } +): Promise> { + return page.evaluateHandle( + async ({ componentSelector, config }) => { + if (config?.headTags) { + config.headTags.forEach((tag) => { + const head = document.querySelector('head'); + if (!head) { + throw new Error('No head tag found in the document.'); + } + + head.innerHTML += tag; + }); + } + + const loadScript = document.createElement('script'); + loadScript.src = '/scripts/e2e/load-e2e-runtime.js'; + document.body.appendChild(loadScript); + + await new Promise((resolve) => { + loadScript.onload = async () => { + resolve(); + }; + }); + + await window.customElements.whenDefined('ix-button'); + const mount = document.querySelector('#mount'); + + if (!mount) { + throw new Error('No mount point found in the document.'); + } + + mount.innerHTML = componentSelector; + return mount.children.item(0) as HTMLElement; + }, + { componentSelector: selector, config } + ); +} + export const regressionTest = testBase.extend<{ mount: ( selector: string, @@ -79,7 +123,7 @@ export const regressionTest = testBase.extend<{ ); }, mount: async ({ page }, use, testInfo) => { - (testInfo as any).componentTest = true; + testInfo.config.metadata['componentTest'] = true; const theme = testInfo.project.metadata?.theme ?? 'theme-classic-dark'; testInfo.annotations.push({ type: theme, @@ -87,50 +131,7 @@ export const regressionTest = testBase.extend<{ await page.goto( `http://127.0.0.1:8080/src/tests/utils/ct/index.html?theme=${theme}` ); - use( - ( - selector: string, - config?: { - headTags?: string[]; - } - ) => { - return page.evaluateHandle( - async ({ componentSelector, config }) => { - if (config?.headTags) { - config.headTags.forEach((tag) => { - const head = document.querySelector('head'); - if (!head) { - throw new Error('No head tag found in the document.'); - } - - head.innerHTML += tag; - }); - } - - const loadScript = document.createElement('script'); - loadScript.src = '/scripts/e2e/load-e2e-runtime.js'; - document.body.appendChild(loadScript); - - await new Promise((resolve) => { - loadScript.onload = async () => { - resolve(); - }; - }); - - await window.customElements.whenDefined('ix-button'); - const mount = document.querySelector('#mount'); - - if (!mount) { - throw new Error('No mount point found in the document.'); - } - - mount.innerHTML = componentSelector; - return mount.children.item(0) as HTMLElement; - }, - { componentSelector: selector, config } - ); - } - ); + await use((selector, config) => mountComponent(page, selector, config)); }, });