mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
feat: add logging around fixture downloads
This commit is contained in:
@@ -13,6 +13,7 @@ import SSOFileModification from '@app/unraid-api/unraid-file-modifier/modificati
|
|||||||
interface ModificationTestCase {
|
interface ModificationTestCase {
|
||||||
ModificationClass: new (...args: ConstructorParameters<typeof FileModification>) => FileModification;
|
ModificationClass: new (...args: ConstructorParameters<typeof FileModification>) => FileModification;
|
||||||
fileUrl: string;
|
fileUrl: string;
|
||||||
|
fileName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const testCases: ModificationTestCase[] = [
|
const testCases: ModificationTestCase[] = [
|
||||||
@@ -20,16 +21,19 @@ const testCases: ModificationTestCase[] = [
|
|||||||
ModificationClass: DefaultPageLayoutModification,
|
ModificationClass: DefaultPageLayoutModification,
|
||||||
fileUrl:
|
fileUrl:
|
||||||
'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/include/DefaultPageLayout.php',
|
'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/include/DefaultPageLayout.php',
|
||||||
|
fileName: 'DefaultPageLayout.php',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ModificationClass: NotificationsPageModification,
|
ModificationClass: NotificationsPageModification,
|
||||||
fileUrl:
|
fileUrl:
|
||||||
'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/Notifications.page',
|
'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/Notifications.page',
|
||||||
|
fileName: 'Notifications.page',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fileUrl:
|
fileUrl:
|
||||||
'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/include/.login.php',
|
'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/plugins/dynamix/include/.login.php',
|
||||||
ModificationClass: SSOFileModification,
|
ModificationClass: SSOFileModification,
|
||||||
|
fileName: '.login.php',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -40,9 +44,16 @@ async function testModification(testCase: ModificationTestCase) {
|
|||||||
const path = resolve(__dirname, `../__fixtures__/downloaded/${fileName}`);
|
const path = resolve(__dirname, `../__fixtures__/downloaded/${fileName}`);
|
||||||
let originalContent = '';
|
let originalContent = '';
|
||||||
if (!existsSync(path)) {
|
if (!existsSync(path)) {
|
||||||
originalContent = await fetch(testCase.fileUrl).then((response) => response.text());
|
try {
|
||||||
await writeFile(path, originalContent);
|
console.log('Downloading file', testCase.fileUrl);
|
||||||
|
originalContent = await fetch(testCase.fileUrl).then((response) => response.text());
|
||||||
|
await writeFile(path, originalContent);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to download file', error);
|
||||||
|
throw new Error('Failed to download file for testing');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
console.log('Using existing fixture file', path);
|
||||||
originalContent = await readFile(path, 'utf-8');
|
originalContent = await readFile(path, 'utf-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +83,7 @@ async function testModification(testCase: ModificationTestCase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('File modifications', () => {
|
describe('File modifications', () => {
|
||||||
test.each(testCases)(`$fileUrl modifier correctly applies to fresh install`, async (testCase) => {
|
test.each(testCases)(`$fileName modifier correctly applies to fresh install`, async (testCase) => {
|
||||||
await testModification(testCase);
|
await testModification(testCase);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user