Skip to content

Commit

Permalink
clean up telemetry db after each telemetry tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m5r committed Oct 30, 2024
1 parent 857203f commit e795d34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 5 additions & 2 deletions tests/e2e/default/telemetry/telemetry.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ describe('Telemetry', () => {
const todayDBName = `${TELEMETRY_PREFIX}-${moment().format(DATE_FORMAT)}-${user.username}`;

before(async () => {
await utils.deleteDb(todayDBName);

const selectContactTelemetryForm = utils.deepFreeze({
_id: 'form:select_contact_telemetry',
internalId: 'select_contact_telemetry',
Expand Down Expand Up @@ -123,6 +121,11 @@ describe('Telemetry', () => {
});

describe('search matches telemetry', () => {
afterEach(async () => {
// eslint-disable-next-line no-undef
await browser.execute((dbName) => window.PouchDB(dbName).destroy(), todayDBName);
});

const getTelemetryEntryByKey = async (key) => {
const todayTelemetryDocs = await browser.execute(async (dbName) => {
// eslint-disable-next-line no-undef
Expand Down
5 changes: 1 addition & 4 deletions tests/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,11 @@ const setUserContactDoc = (attempt = 0) => {
});
};

const deleteDb = async (dbName) => await request({ method: 'DELETE', path: `/${dbName}` });

const deleteMetaDbs = async () => {
const allDbs = await request({ path: '/_all_dbs' });
const metaDbs = allDbs.filter(db => db.endsWith('-meta') && !db.endsWith('-users-meta'));
for (const metaDb of metaDbs) {
await deleteDb(metaDb);
await request({ method: 'DELETE', path: `/${metaDb}` });
}
};

Expand Down Expand Up @@ -1596,7 +1594,6 @@ module.exports = {
revertSettings,
seedTestData,
revertDb,
deleteDb,
getOrigin,
getBaseUrl,
getAdminBaseUrl,
Expand Down

0 comments on commit e795d34

Please sign in to comment.