insomnia/packages/insomnia-smoke-test/tests/critical/backup.test.ts
Filipe Freire df77275576
chore: Add test to check for backups on new version to critical tests (#6403)
* chore: Add test to check for backups on new version to critical tests

* check for backups folder contents

* change env var on gh actions file

* fix
2023-08-28 14:06:47 +00:00

30 lines
1.1 KiB
TypeScript

import { expect } from '@playwright/test';
import fs from 'fs';
import path from 'path';
import { test } from '../../playwright/test';
test('can backup data on new version available', async ({ app, page }) => {
const dataPath = await app.evaluate(async ({ app }) => app.getPath('userData'));
let foundBackups = false;
// retry 5 times
for (let i = 0; i < 5; i++) {
console.log('Retry', i);
if (fs.existsSync(path.join(dataPath, 'backups'))) {
console.log('Backups exists!');
const rootBackupsFolder = fs.readdirSync(path.join(dataPath, 'backups'));
const backupDir = fs.readdirSync(path.join(dataPath, 'backups', rootBackupsFolder[0]));
const hasFilesInsideBackup = backupDir.length > 0;
const hasProjectDbFile = backupDir.includes('insomnia.Project.db');
foundBackups = hasFilesInsideBackup && hasProjectDbFile;
break;
} else {
console.log('backups not found. Waiting 5 seconds...');
await page.waitForTimeout(5000);
}
}
await expect(foundBackups).toBe(true);
});