fix: Hide AI Repair button in config tab

Co-authored-by: Alois Klink <alois@aloisklink.com>
This commit is contained in:
Sidharth Vinod
2025-05-26 23:14:45 +05:30
co-authored by Alois Klink
parent 5ce27dd981
commit 400f3ecf95
5 changed files with 60 additions and 12 deletions
+34
View File
@@ -0,0 +1,34 @@
import { test } from './test';
test.describe('Error display tests', () => {
test('should show AI Repair button for syntax errors in Code tab', async ({ editPage }) => {
// Enter code with syntax error
await editPage.clearEditor();
await editPage.typeInEditor('graph TD\nA --> B -->');
// Verify error is displayed
await editPage.checkError('Syntax error');
// Verify AI Repair button and help text is shown in Code tab
await editPage.checkAIHelperVisibility(true);
});
test('should not show AI Repair button for errors in Config tab', async ({ editPage }) => {
// First enter valid diagram
await editPage.clearEditor();
await editPage.typeInEditor('graph TD\nA --> B');
// Switch to Config tab
await editPage.setEditorMode('Config');
// Enter invalid JSON in config
await editPage.clearEditor();
await editPage.typeInEditor('{\n "theme": "default",\n invalid json');
// Verify error is displayed
await editPage.checkError('Syntax error');
// Verify AI Repair button and help text is NOT shown in Config tab
await editPage.checkAIHelperVisibility(false);
});
});
+7
View File
@@ -103,6 +103,13 @@ export class EditorPage {
`Switch to ${theme === 'light' ? 'dark' : 'light'} theme`
);
}
async checkAIHelperVisibility(shouldBeVisible: boolean) {
const button = this.page.getByTestId(TID.aiRepairButton);
const helpText = this.page.getByTestId(TID.aiHelpText);
await expect(button)[shouldBeVisible ? 'toBeVisible' : 'toBeHidden']();
await expect(helpText)[shouldBeVisible ? 'toBeVisible' : 'toBeHidden']();
}
}
export const test = base.extend<{ editPage: EditorPage }>({