test(core): enable no-floating-promises rule for tests (#11915)

Sometimes, missing `await` in the test code can cause timing issues, leading to test failures. This PR enables the `no-floating-promises` rule for the test code to ensure that such errors do not occur.
This commit is contained in:
L-Sun
2025-04-23 08:17:41 +00:00
parent 200015a811
commit a9ad01491c
28 changed files with 136 additions and 121 deletions
@@ -30,6 +30,10 @@ export class ChatPanelUtils {
await page.getByTestId('right-sidebar-toggle').click({
delay: 200,
});
await page.waitForTimeout(500); // wait the sidebar stable
}
if (await page.getByTestId('notification-close-button').isVisible()) {
await page.getByTestId('notification-close-button').click();
}
await page.getByTestId('sidebar-tab-chat').click();
await expect(page.getByTestId('sidebar-tab-content-chat')).toBeVisible();
@@ -291,14 +295,14 @@ export class ChatPanelUtils {
}
public static async enableNetworkSearch(page: Page) {
const networkSearch = await page.getByTestId('chat-network-search');
const networkSearch = page.getByTestId('chat-network-search');
if ((await networkSearch.getAttribute('data-active')) === 'false') {
await networkSearch.click();
}
}
public static async disableNetworkSearch(page: Page) {
const networkSearch = await page.getByTestId('chat-network-search');
const networkSearch = page.getByTestId('chat-network-search');
if ((await networkSearch.getAttribute('data-active')) === 'true') {
await networkSearch.click();
}
@@ -51,7 +51,7 @@ export class EditorUtils {
public static async switchToEdgelessMode(page: Page) {
const editor = await page.waitForSelector('page-editor');
await page.getByTestId('switch-edgeless-mode-button').click();
editor.waitForElementState('hidden');
await editor.waitForElementState('hidden');
await page.waitForSelector('edgeless-editor');
try {
const edgelessNotificationClose = page.getByTestId(
@@ -408,9 +408,7 @@ export class EditorUtils {
checkCodeError: this.createAction(page, () =>
page.getByTestId('action-check-code-error').click()
),
continueWithAi: async () => {
page.getByTestId('action-continue-with-ai').click();
},
continueWithAi: () => page.getByTestId('action-continue-with-ai').click(),
continueWriting: this.createAction(page, () =>
page.getByTestId('action-continue-writing').click()
),
@@ -596,9 +594,7 @@ export class EditorUtils {
checkCodeError: this.createAction(page, () =>
page.getByTestId('action-check-code-error').click()
),
continueWithAi: async () => {
page.getByTestId('action-continue-with-ai').click();
},
continueWithAi: () => page.getByTestId('action-continue-with-ai').click(),
continueWriting: this.createAction(page, () =>
page.getByTestId('action-continue-writing').click()
),