Skip to content

Commit

Permalink
refactor: sonarqube (#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
nuke-ellington authored Feb 18, 2025
1 parent 093c783 commit 9f78d84
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 67 deletions.
5 changes: 3 additions & 2 deletions packages/aggrid/tests/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<html>
<html lang="en">
<head>
<title>Ag-Grid basic</title>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@32/dist/ag-grid-community.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@32/styles/ag-grid.css" />
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@32/styles/ag-theme-alpine.css" />
Expand Down Expand Up @@ -50,7 +51,7 @@
};

const gridDiv = document.querySelector('div.ag-theme-ix');
const grid = new agGrid.Grid(gridDiv, gridOptions);
new agGrid.Grid(gridDiv, gridOptions);
})();
</script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions packages/aggrid/tests/basic_v28.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<html>
<html lang="en">
<head>
<title>Ag-Grid version 28</title>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@28/dist/ag-grid-community.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@28/styles/ag-grid.css" />
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@28/styles/ag-theme-alpine.css" />
Expand Down Expand Up @@ -50,7 +51,7 @@
};

const gridDiv = document.querySelector('div.ag-theme-ix');
const grid = new agGrid.Grid(gridDiv, gridOptions);
new agGrid.Grid(gridDiv, gridOptions);
})();
</script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions packages/aggrid/tests/basic_v29.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<html>
<html lang="en">
<head>
<title>Ag-Grid version 29</title>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@29/dist/ag-grid-community.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@29/styles/ag-grid.css" />
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@29/styles/ag-theme-alpine.css" />
Expand Down Expand Up @@ -50,7 +51,7 @@
};

const gridDiv = document.querySelector('div.ag-theme-ix');
const grid = new agGrid.Grid(gridDiv, gridOptions);
new agGrid.Grid(gridDiv, gridOptions);
})();
</script>
</body>
Expand Down
8 changes: 4 additions & 4 deletions packages/aggrid/tests/basic_v30.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<html>
<html lang="en">
<head>
<title>Ag-Grid version 30</title>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@30/dist/ag-grid-community.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@30/styles/ag-grid.css" />
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@30/styles/ag-theme-alpine.css" />
Expand Down Expand Up @@ -50,8 +51,7 @@
};

const gridDiv = document.querySelector('div.ag-theme-ix');
const grid = new agGrid.Grid(gridDiv, gridOptions);
new agGrid.Grid(gridDiv, gridOptions);
})();
</script>
</body>
</script> </body>
</html>
5 changes: 3 additions & 2 deletions packages/aggrid/tests/basic_v31.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<html>
<html lang="en">
<head>
<title>Ag-Grid version 31</title>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@31/dist/ag-grid-community.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@31/styles/ag-grid.css" />
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@31/styles/ag-theme-alpine.css" />
Expand Down Expand Up @@ -50,7 +51,7 @@
};

const gridDiv = document.querySelector('div.ag-theme-ix');
const grid = new agGrid.Grid(gridDiv, gridOptions);
new agGrid.Grid(gridDiv, gridOptions);
})();
</script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions packages/aggrid/tests/basic_v32.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<html>
<html lang="en">
<head>
<title>Ag-Grid version 32</title>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@32/dist/ag-grid-community.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@32/styles/ag-grid.css" />
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community@32/styles/ag-theme-alpine.css" />
Expand Down Expand Up @@ -50,7 +51,7 @@
};

const gridDiv = document.querySelector('div.ag-theme-ix');
const grid = new agGrid.Grid(gridDiv, gridOptions);
new agGrid.Grid(gridDiv, gridOptions);
})();
</script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions packages/aggrid/tests/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
<html>
<html lang="en">
<head>
<title>Ag-Grid pagination</title>
<script src="https://cdn.jsdelivr.net/npm/ag-grid-community@32.1/dist/ag-grid-community.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community/styles/ag-grid.css" />
<link rel="stylesheet" href="https://unpkg.com/ag-grid-community/styles/ag-theme-alpine.css" />
Expand Down Expand Up @@ -55,7 +56,7 @@
};

const gridDiv = document.querySelector('div.ag-theme-ix');
const grid = new agGrid.Grid(gridDiv, gridOptions);
new agGrid.Grid(gridDiv, gridOptions);
})();
</script>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand Down
97 changes: 49 additions & 48 deletions packages/core/src/tests/utils/test/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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<ElementHandle<HTMLElement>> {
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<void>((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,
Expand Down Expand Up @@ -79,58 +123,15 @@ 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,
});
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<void>((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));
},
});

Expand Down

0 comments on commit 9f78d84

Please sign in to comment.