-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(e2e): Harden e2e tests, add cleanup routine after all-tests run (…
…#1314) ## Description This hopefully fixes an intermittent issue in e2e tests where leftovers from previously running tests sometimes were not cleaned up properly, and interfered with subsequent tests. * Now using UpdatedAfter instead of ChangedAfter in default filter to avoid clashing with other dialogs * Using a new default synthetic person/organization * Added missing cleanups for some tests * Added a sentinel mechanism that detects if some tests aren't cleaning up after themselves. The remaining dialogs will be attempted removed, but the run will be failed as a whole * Updated README * Cleanups ## Verification - [x] **Your** code builds clean without any errors or warnings - [x] Manual testing done (required) - [x] Relevant automated test added <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **Documentation** - Enhanced clarity in the testing framework documentation, emphasizing self-contained test files and cleanup requirements. - **New Features** - Introduced a `sentinelValue` for tracking unpurged dialogs. - Added a new test suite to check for unpurged dialogs and ensure proper cleanup. - **Improvements** - Updated dialog search filters to focus on updated timestamps. - Streamlined test output by removing unnecessary logging. - Ensured cleanup operations after successful dialog creation tests. - **Bug Fixes** - Corrected validation checks in dialog detail tests to ensure proper authorization and API response handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
12 changed files
with
86 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { expect, expectStatusFor, describe, getSO, purgeSO } from './testimports.js' | ||
import { sentinelValue } from './config.js'; | ||
|
||
export default function () { | ||
|
||
let dialogId = null; | ||
const tokenOptions = { | ||
scopes: "digdir:dialogporten.serviceprovider digdir:dialogporten.serviceprovider.search digdir:dialogporten.serviceprovider.admin digdir:dialogporten.correspondence" | ||
} | ||
describe('Post run: checking for unpurged dialogs', () => { | ||
let r = getSO('dialogs/?Search=' + sentinelValue, null, tokenOptions); | ||
expectStatusFor(r).to.equal(200); | ||
expect(r, 'response').to.have.validJsonBody(); | ||
var response = r.json(); | ||
if (response.items && response.items.length > 0) { | ||
console.error("Found " + response.items.length + " unpurged dialogs, make sure that all tests clean up after themselves. Purging ..."); | ||
response.items.forEach((item) => { | ||
console.warn("Sentinel purging dialog with id: " + item.id) | ||
let r = purgeSO('dialogs/' + item.id, null, tokenOptions); | ||
if (r.status != 204) { | ||
console.error("Failed to purge dialog with id: " + item.id); | ||
console.log(r); | ||
} | ||
}); | ||
|
||
// Fail the test after purging for visibility | ||
expect(response.items.length, 'unpurged dialogs').to.equal(0); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { default as serviceOwnerTests } from './serviceowner/all-tests.js'; | ||
import { default as enduserTests } from './enduser/all-tests.js'; | ||
import { default as sentinelCheck } from '../common/sentinel.js'; | ||
|
||
export function runAllTests() { | ||
serviceOwnerTests(); | ||
enduserTests(); | ||
|
||
// Run sentinel check last, which will warn about and purge any leftover dialogs | ||
sentinelCheck(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters