Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## **WORK IN PROGRESS**

- (copilot) **FIXED**: Fixed Promise scope issues in integration testing examples - use proper `(resolve, reject)` parameters and error handling (Fixes #15)
- (copilot) **NEW**: Added fully automated ioBroker Copilot setup with zero manual steps (Fixes #26)
- (copilot) **NEW**: Created initial-setup-automation.md template for comprehensive automated setup and validation
- (copilot) **NEW**: Added weekly-version-check-action.yml GitHub Action for automated template monitoring
Expand Down
36 changes: 26 additions & 10 deletions template.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ tests.integration(path.join(__dirname, '..'), {
harness = getHarness();
});

it('should configure and start adapter', () => new Promise(async (resolve) => {
it('should configure and start adapter', () => new Promise(async (resolve, reject) => {
// Get adapter object and configure
harness.objects.getObject('system.adapter.brightsky.0', async (err, obj) => {
if (err) {
console.error('Error getting adapter object:', err);
resolve();
reject(err);
return;
}

Expand All @@ -119,10 +119,16 @@ tests.integration(path.join(__dirname, '..'), {
setTimeout(() => {
// Verify states were created
harness.states.getState('brightsky.0.info.connection', (err, state) => {
if (err) {
reject(err);
return;
}
if (state && state.val === true) {
console.log('✅ Adapter started successfully');
resolve();
} else {
reject(new Error('Adapter failed to start - connection state is not true'));
}
resolve();
});
}, 15000); // Allow time for API calls
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] 15000 is a magic number; consider extracting these timeouts to a named constant (e.g., const STATE_CHECK_DELAY_MS = 15000) and using it consistently (also at line 223 which uses 10000) to make intent clear and reduce flakiness relative to the overall test timeout.

Copilot uses AI. Check for mistakes.
});
Expand All @@ -138,16 +144,16 @@ tests.integration(path.join(__dirname, '..'), {

```javascript
// Example: Testing successful configuration
it('should configure and start adapter with valid configuration', () => new Promise(async (resolve) => {
it('should configure and start adapter with valid configuration', () => new Promise(async (resolve, reject) => {
// ... successful configuration test as shown above
})).timeout(30000);

// Example: Testing failure scenarios
it('should fail gracefully with invalid configuration', () => new Promise(async (resolve) => {
it('should fail gracefully with invalid configuration', () => new Promise(async (resolve, reject) => {
harness.objects.getObject('system.adapter.brightsky.0', async (err, obj) => {
if (err) {
console.error('Error getting adapter object:', err);
resolve();
reject(err);
return;
}

Expand All @@ -163,12 +169,17 @@ it('should fail gracefully with invalid configuration', () => new Promise(async
setTimeout(() => {
// Verify adapter handled the error properly
harness.states.getState('brightsky.0.info.connection', (err, state) => {
if (err) {
reject(err);
return;
}
if (state && state.val === false) {
console.log('✅ Adapter properly failed with invalid configuration');
resolve();
} else {
console.log('❌ Adapter should have failed but connection shows true');
reject(new Error('Adapter should have failed with invalid configuration'));
}
resolve();
});
}, 15000);
} catch (error) {
Expand All @@ -179,11 +190,11 @@ it('should fail gracefully with invalid configuration', () => new Promise(async
})).timeout(30000);

// Example: Testing missing required configuration
it('should fail when required configuration is missing', () => new Promise(async (resolve) => {
it('should fail when required configuration is missing', () => new Promise(async (resolve, reject) => {
harness.objects.getObject('system.adapter.brightsky.0', async (err, obj) => {
if (err) {
console.error('Error getting adapter object:', err);
resolve();
reject(err);
return;
}

Expand All @@ -197,12 +208,17 @@ it('should fail when required configuration is missing', () => new Promise(async

setTimeout(() => {
harness.states.getState('brightsky.0.info.connection', (err, state) => {
if (err) {
reject(err);
return;
}
if (!state || state.val === false) {
console.log('✅ Adapter properly failed with missing required configuration');
resolve();
} else {
console.log('❌ Adapter should have failed but connection shows true');
reject(new Error('Adapter should have failed with missing configuration'));
}
resolve();
});
}, 10000);
} catch (error) {
Expand Down