mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-31 19:50:44 +00:00
- 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.
68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import { NightwatchBrowser } from 'nightwatch';
|
|
|
|
module.exports = {
|
|
async command(
|
|
this: NightwatchBrowser,
|
|
pluginName: string,
|
|
expectedEnabled: boolean = true,
|
|
) {
|
|
return this.waitForElementVisible('plugin-management').execute(
|
|
(name: string) => {
|
|
// Find the plugin item (now in mat-card elements)
|
|
const items = Array.from(document.querySelectorAll('plugin-management mat-card'));
|
|
|
|
// Find by card title or card content
|
|
const pluginItem = items.find((item) => {
|
|
const cardTitle = item.querySelector('mat-card-title')?.textContent || '';
|
|
const cardContent = item.textContent || '';
|
|
return cardTitle.includes(name) || cardContent.includes(name);
|
|
});
|
|
|
|
if (!pluginItem) {
|
|
return {
|
|
found: false,
|
|
debug: {
|
|
totalCards: items.length,
|
|
cardTitles: items.map(
|
|
(item) =>
|
|
item.querySelector('mat-card-title')?.textContent?.trim() || 'No title',
|
|
),
|
|
searchName: name,
|
|
},
|
|
};
|
|
}
|
|
|
|
// Check if toggle is checked - Angular Material slide toggle
|
|
const toggleButton = pluginItem.querySelector(
|
|
'mat-slide-toggle button[role="switch"]',
|
|
) as HTMLButtonElement;
|
|
|
|
let enabled = false;
|
|
if (toggleButton) {
|
|
enabled = toggleButton.getAttribute('aria-checked') === 'true';
|
|
}
|
|
|
|
return {
|
|
found: true,
|
|
enabled,
|
|
name: pluginItem.querySelector('mat-card-title')?.textContent?.trim() || '',
|
|
};
|
|
},
|
|
[pluginName],
|
|
(result) => {
|
|
const data = result.value as any;
|
|
if (!data.found && data.debug) {
|
|
console.log('Plugin not found. Debug info:', data.debug);
|
|
}
|
|
this.assert.ok(data.found, `Plugin "${pluginName}" should be found`);
|
|
if (data.found) {
|
|
this.assert.equal(
|
|
data.enabled,
|
|
expectedEnabled,
|
|
`Plugin "${pluginName}" should be ${expectedEnabled ? 'enabled' : 'disabled'}`,
|
|
);
|
|
}
|
|
},
|
|
);
|
|
},
|
|
};
|