diff --git a/e2e/commands/setupWebdavSync.ts b/e2e/commands/setupWebdavSync.ts index 433ea5e9f..c48842e99 100644 --- a/e2e/commands/setupWebdavSync.ts +++ b/e2e/commands/setupWebdavSync.ts @@ -1,59 +1,38 @@ -// eslint-disable-next-line @typescript-eslint/no-namespace -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace NightwatchCustomCommands { - interface Commands { - setupWebdavSync( - config: { - baseUrl: string; - username: string; - password: string; - syncFolderPath: string; - }, - callback?: () => void, - ): this; - } - } -} +import { NBrowser } from '../n-browser-interface'; module.exports = { - command: function setupWebdavSync( - this: any, + command( + this: NBrowser, config: { baseUrl: string; username: string; password: string; syncFolderPath: string; }, - callback?: () => void, ) { - this.url('http://localhost:4200/config') - .waitForElementVisible('body', 5000) - .pause(500) - // Navigate to sync settings - .click('a[href="/config/sync"]') - .waitForElementVisible('[data-cy="sync-provider-webdav"]', 5000) - // Select WebDAV provider - .click('[data-cy="sync-provider-webdav"]') - .pause(500) - // Fill in WebDAV configuration - .waitForElementVisible('input[ng-reflect-name="baseUrl"]', 2000) - .clearValue('input[ng-reflect-name="baseUrl"]') - .setValue('input[ng-reflect-name="baseUrl"]', config.baseUrl) - .clearValue('input[ng-reflect-name="userName"]') - .setValue('input[ng-reflect-name="userName"]', config.username) - .clearValue('input[ng-reflect-name="password"]') - .setValue('input[ng-reflect-name="password"]', config.password) - .clearValue('input[ng-reflect-name="syncFolderPath"]') - .setValue('input[ng-reflect-name="syncFolderPath"]', config.syncFolderPath) - // Save configuration - .click('button[type="submit"]') - .pause(1000); + // CSS‑Selektoren zentral definieren + const sel = { + syncBtn: 'button.sync-btn', + providerSelect: 'formly-field-mat-select mat-select', + providerOptionWebDAV: '#mat-option-3', // Eintrag „WebDAV“ + baseUrlInput: '.e2e-baseUrl input', + userNameInput: '.e2e-userName input', + passwordInput: '.e2e-password input', + saveBtn: 'mat-dialog-actions button[mat-stroked-button]', + }; - if (callback) { - callback.call(this); - } + return this.click(sel.syncBtn) + .waitForElementVisible(sel.providerSelect) + .pause(100) + .click(sel.providerSelect) + .click(sel.providerOptionWebDAV) + .pause(100) - return this; + .setValue(sel.baseUrlInput, 'http://localhost:2345') + .setValue(sel.userNameInput, 'alice') + .setValue(sel.passwordInput, 'alice') + .pause(100) + + .click(sel.saveBtn); }, }; diff --git a/e2e/commands/triggerSync.ts b/e2e/commands/triggerSync.ts index d834c1e12..06c10115d 100644 --- a/e2e/commands/triggerSync.ts +++ b/e2e/commands/triggerSync.ts @@ -1,27 +1,7 @@ -// eslint-disable-next-line @typescript-eslint/no-namespace -declare global { - // eslint-disable-next-line @typescript-eslint/no-namespace - namespace NightwatchCustomCommands { - interface Commands { - triggerSync(callback?: () => void): this; - } - } -} +import { NBrowser } from '../n-browser-interface'; module.exports = { - command: function triggerSync(this: any, callback?: () => void) { - this.url('http://localhost:4200/work-view') - .waitForElementVisible('body', 5000) - .pause(500) - // Find and click sync button - .waitForElementVisible('.sync-btn', 3000) - .click('.sync-btn') - .pause(2000); // Allow time for sync to complete - - if (callback) { - callback.call(this); - } - - return this; + command: function triggerSync(this: NBrowser) { + return this.waitForElementVisible('.sync-btn', 3000).click('.sync-btn').pause(1000); // Allow time for sync to complete }, }; diff --git a/e2e/n-browser-interface.ts b/e2e/n-browser-interface.ts index 52a73b163..c32c4523f 100644 --- a/e2e/n-browser-interface.ts +++ b/e2e/n-browser-interface.ts @@ -20,4 +20,11 @@ export interface NBrowser extends NightwatchAPI { navigateToPluginSettings: () => NBrowser; checkPluginStatus: (pluginName: string, expectedEnabled?: boolean) => NBrowser; enableTestPlugin: (pluginName?: string) => NBrowser; + setupWebdavSync: (config: { + baseUrl: string; + username: string; + password: string; + syncFolderPath: string; + }) => NBrowser; + triggerSync: () => NBrowser; } diff --git a/e2e/src/sync/webdav-basic.e2e.ts b/e2e/src/sync/webdav-basic.e2e.ts index d840eb1e2..26085e13b 100644 --- a/e2e/src/sync/webdav-basic.e2e.ts +++ b/e2e/src/sync/webdav-basic.e2e.ts @@ -9,11 +9,12 @@ module.exports = { browser: NBrowser, ) => { await browser + .navigateTo('http://localhost:4200') // Configure WebDAV sync .setupWebdavSync({ - baseUrl: 'http://localhost:8080/', + baseUrl: 'http://localhost:2345/', username: 'alice', - password: 'alicepassword', + password: 'alice', syncFolderPath: '/super-productivity-test', }) // Create a test task @@ -23,24 +24,8 @@ module.exports = { .triggerSync() // Verify sync completed .pause(3000) + .noError() .assert.not.elementPresent('.sync-btn mat-icon.spin') - // Log sync state for debugging - .execute( - () => { - const syncBtn = document.querySelector('.sync-btn'); - const icon = syncBtn?.querySelector('mat-icon'); - return { - iconText: icon?.textContent?.trim(), - hasSyncBtn: !!syncBtn, - syncBtnText: syncBtn?.textContent?.trim(), - }; - }, - [], - (result) => { - console.log('WebDAV sync state:', result.value); - const state = result.value as any; - browser.assert.ok(state.hasSyncBtn, 'Sync button should exist'); - }, - ); + .end(); }, }; diff --git a/src/app/features/config/form-cfgs/sync-form.const.ts b/src/app/features/config/form-cfgs/sync-form.const.ts index 50b6cce72..1fa263f3a 100644 --- a/src/app/features/config/form-cfgs/sync-form.const.ts +++ b/src/app/features/config/form-cfgs/sync-form.const.ts @@ -98,6 +98,7 @@ export const SYNC_FORM: ConfigFormSection = { { key: 'baseUrl', type: 'input', + className: 'e2e-baseUrl', templateOptions: { required: true, label: T.F.SYNC.FORM.WEB_DAV.L_BASE_URL, @@ -108,6 +109,7 @@ export const SYNC_FORM: ConfigFormSection = { { key: 'userName', type: 'input', + className: 'e2e-userName', templateOptions: { required: true, label: T.F.SYNC.FORM.WEB_DAV.L_USER_NAME, @@ -116,6 +118,7 @@ export const SYNC_FORM: ConfigFormSection = { { key: 'password', type: 'input', + className: 'e2e-password', templateOptions: { type: 'password', required: true,