Refactor user management and logs viewing tests for improved stability and clarity

- Scoped button selectors to dialogs in user management tests to avoid strict mode violations.
- Added wait conditions for loading states and element visibility in user management and logs viewing tests.
- Updated navigation methods to use 'domcontentloaded' for better reliability.
- Enhanced mock data generation for log entries and improved filtering logic in logs viewing tests.
- Consolidated selector usage with data-testid attributes for consistency and maintainability.
- Removed skipped tests and ensured all scenarios are covered for logs viewing, including pagination and filtering.
This commit is contained in:
GitHub Actions
2026-02-10 09:02:26 +00:00
parent eee9f429d9
commit d29b8e9ce4
16 changed files with 1643 additions and 444 deletions
+5
View File
@@ -87,6 +87,7 @@ const Logs: FC = () => {
setSelectedLog(log.name);
setPage(0);
}}
data-testid={`log-file-${log.name}`}
className={`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors flex items-center ${
selectedLog === log.name
? 'bg-brand-500/10 text-brand-500 border border-brand-500/30'
@@ -173,6 +174,8 @@ const Logs: FC = () => {
size="sm"
onClick={() => setPage((p) => Math.max(0, p - 1))}
disabled={page === 0 || isLoadingContent}
data-testid="prev-page-button"
aria-label="Previous page"
>
<ChevronLeft className="w-4 h-4" />
</Button>
@@ -181,6 +184,8 @@ const Logs: FC = () => {
size="sm"
onClick={() => setPage((p) => p + 1)}
disabled={page >= totalPages - 1 || isLoadingContent}
data-testid="next-page-button"
aria-label="Next page"
>
<ChevronRight className="w-4 h-4" />
</Button>
+11 -11
View File
@@ -281,29 +281,29 @@ const TemplateForm: FC<{
return (
<form onSubmit={handleSubmit(onSubmit)} className="space-y-3">
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('common.name')}</label>
<input {...register('name', { required: true })} className="mt-1 block w-full rounded-md" />
<label htmlFor="template-name" className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('common.name')}</label>
<input id="template-name" data-testid="template-name" {...register('name', { required: true })} className="mt-1 block w-full rounded-md" />
</div>
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('common.description')}</label>
<input {...register('description')} className="mt-1 block w-full rounded-md" />
<label htmlFor="template-description" className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('common.description')}</label>
<input id="template-description" data-testid="template-description" {...register('description')} className="mt-1 block w-full rounded-md" />
</div>
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('notificationProviders.templateType')}</label>
<select {...register('template')} className="mt-1 block w-full rounded-md">
<label htmlFor="template-type" className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('notificationProviders.templateType')}</label>
<select id="template-type" data-testid="template-type" {...register('template')} className="mt-1 block w-full rounded-md">
<option value="minimal">{t('notificationProviders.minimal')}</option>
<option value="detailed">{t('notificationProviders.detailed')}</option>
<option value="custom">{t('notificationProviders.custom')}</option>
</select>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('notificationProviders.configJson')}</label>
<textarea {...register('config')} rows={6} className="mt-1 block w-full font-mono text-xs rounded-md" />
<label htmlFor="template-config" className="block text-sm font-medium text-gray-700 dark:text-gray-300">{t('notificationProviders.configJson')}</label>
<textarea id="template-config" data-testid="template-config" {...register('config')} rows={6} className="mt-1 block w-full font-mono text-xs rounded-md" />
</div>
<div className="flex justify-end gap-2">
<Button variant="secondary" onClick={onClose}>{t('common.cancel')}</Button>
<Button type="button" variant="secondary" onClick={handlePreview}>{t('notificationProviders.preview')}</Button>
<Button type="submit">{t('common.save')}</Button>
<Button variant="secondary" onClick={onClose} data-testid="template-cancel-btn">{t('common.cancel')}</Button>
<Button type="button" variant="secondary" onClick={handlePreview} data-testid="template-preview-btn">{t('notificationProviders.preview')}</Button>
<Button type="submit" data-testid="template-save-btn">{t('common.save')}</Button>
</div>
{previewErr && <div className="text-sm text-red-600">{previewErr}</div>}
{preview && (