super-productivity/e2e/commands/enableTestPlugin.ts
Johannes Millan a8081de69f fix(e2e): update plugin e2e tests to use correct selectors and improve navigation
- Fix navigateToPluginSettings to properly expand collapsible section using .collapsible-header
- Update all plugin tests to use button[role="switch"] selector instead of input for mat-slide-toggle
- Fix enableTestPlugin command to check aria-checked attribute for toggle state
- Update plugin-upload test to use correct path for test-plugin.zip
- Improve error handling and debug output in plugin test commands

These changes address the failing plugin e2e tests by correctly interacting with the Angular Material components and ensuring the plugin section is properly expanded before attempting to interact with plugin management.
2025-06-27 20:05:50 +02:00

48 lines
1.6 KiB
TypeScript

import { NBrowser } from '../n-browser-interface';
module.exports = {
async command(this: NBrowser, pluginName: string = 'API Test Plugin') {
return this.navigateToPluginSettings()
.pause(1000)
.execute(
(name: string) => {
const cards = Array.from(
document.querySelectorAll('plugin-management mat-card'),
);
const targetCard = cards.find((card) => {
const title = card.querySelector('mat-card-title')?.textContent || '';
return title.includes(name);
});
if (targetCard) {
const toggleButton = targetCard.querySelector(
'mat-slide-toggle button[role="switch"]',
) as HTMLButtonElement;
if (toggleButton) {
const wasChecked = toggleButton.getAttribute('aria-checked') === 'true';
if (!wasChecked) {
toggleButton.click();
}
return {
enabled: true,
found: true,
wasChecked,
nowChecked: toggleButton.getAttribute('aria-checked') === 'true',
clicked: !wasChecked,
};
}
return { enabled: false, found: true, error: 'No toggle found' };
}
return { enabled: false, found: false };
},
[pluginName],
(result) => {
const data = result.value as any;
this.assert.ok(data.found, `Plugin "${pluginName}" should be found`);
console.log(`Plugin "${pluginName}" enable state:`, data);
},
)
.pause(2000); // Wait for plugin to initialize
},
};