mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-29 19:14:35 +00:00
[Feature] Changelog / Edit History (#13069)
* Initial app scaffolding * Skeleton for AuditLogTable * Add UI table * Add audit history panel to admin center * Add auditing for models in the 'company' app * Gate API access of user staff status * Display item history in UI * Track 'attachment' history * Track 'parameter' changes * Audit support for "common" models * Track changed for "build" models * Track history for "order" models: - PurchaseOrder - SalesOrder - SalesOrderShipment - ReturnOrder Also track changes against LineItem and ExtraLineItem objects * Register custom admin class * Support Part history * BomItem changes * Fix for BulkCreateMixin * Tweak unit tests * Use Viewset * Adjust error code behavior * Setting to keep summary entries * Refactor helper for middlewares * Tweak unit tests * Fixes for ModelInformationDict * Track pricing changes * Add model type filter for auditlog table * Specify filter field type * Hide HistoryPanel if auding is disabled * add docs * Add "--summary" option to export_records task * Playwright tests * Track task responsible for data changes * Updated unit tests * record changes to global settings * Update docs * Ensure values are stringified * Fix for globalsetting * Patch unit test * Tweak playwright tests * playwright test fix * use main branch for demo data * Update CHANGELOG
This commit is contained in:
1 parent
cdb3b1ecf7
commit
c475e9bfcf
91 files changed
+7753
-102
No files matched your search
@@ -0,0 +1,100 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect, test } from './baseFixtures.js';
|
||||
import { adminuser, allaccessuser, stevenuser } from './defaults.js';
|
||||
import {
|
||||
clearTableSearch,
|
||||
loadTab,
|
||||
navigate,
|
||||
setTableChoiceFilter,
|
||||
tableSearch
|
||||
} from './helpers.js';
|
||||
import { doCachedLogin } from './login.js';
|
||||
|
||||
/**
|
||||
* Tests for the audit log (change history) functionality.
|
||||
*
|
||||
* Note: These tests rely on the audit log entries provided in the demo dataset
|
||||
*/
|
||||
|
||||
// Return the "History" tab on a detail page (if present)
|
||||
const historyTab = (page: Page) =>
|
||||
page
|
||||
.getByLabel(/panel-tabs-/)
|
||||
.getByRole('tab', { name: 'History', exact: true });
|
||||
|
||||
test('Audit - Admin Center', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
user: adminuser,
|
||||
url: 'settings/admin/audit-log'
|
||||
});
|
||||
|
||||
await page.getByRole('button', { name: 'Audit Log', exact: true }).waitFor();
|
||||
|
||||
// Historical records are displayed
|
||||
await tableSearch(page, 'red round table');
|
||||
await page.getByRole('cell', { name: 'BOM Item' }).first().waitFor();
|
||||
|
||||
await tableSearch(page, 'PO0020');
|
||||
await page.getByRole('cell', { name: 'Purchase Order' }).first().waitFor();
|
||||
await page.getByText('UPDATED').first().waitFor();
|
||||
|
||||
// Filter by model type
|
||||
await clearTableSearch(page);
|
||||
await setTableChoiceFilter(page, 'Model Type', 'Build Order');
|
||||
await page.getByRole('cell', { name: 'Build Order' }).first().waitFor();
|
||||
await expect(page.getByRole('cell', { name: 'BOM Item' })).toHaveCount(0);
|
||||
|
||||
// Audit log settings
|
||||
await page.getByRole('button', { name: 'Audit Log Settings' }).click();
|
||||
await page.getByText('Enable Audit Log').waitFor();
|
||||
await page.getByText('Delete Old Audit Log Entries').waitFor();
|
||||
await page.getByText('Audit Log Deletion Interval').waitFor();
|
||||
await page.getByText('Retain Audit Log Summary').waitFor();
|
||||
});
|
||||
|
||||
test('Audit - Detail Pages', async ({ browser }) => {
|
||||
// Part (includes BOM item changes)
|
||||
const page = await doCachedLogin(browser, {
|
||||
user: adminuser,
|
||||
url: 'part/111/details'
|
||||
});
|
||||
|
||||
await loadTab(page, 'History', true);
|
||||
await page
|
||||
.getByRole('cell', { name: /to make TB2 \| Test Board 2/ })
|
||||
.first()
|
||||
.waitFor();
|
||||
await page.getByText('Setup Quantity:').first().waitFor();
|
||||
|
||||
// Purchase order (includes line item changes)
|
||||
await navigate(page, 'purchasing/purchase-order/9/detail');
|
||||
await loadTab(page, 'History', true);
|
||||
|
||||
await page.getByRole('cell', { name: 'PO0009 - PCBWOY' }).first().waitFor();
|
||||
await page.getByText('Purchase Order Extra Line').first().waitFor();
|
||||
await page.getByText('Supplier Reference:').first().waitFor();
|
||||
});
|
||||
|
||||
test('Audit - Hidden', async ({ browser }) => {
|
||||
// Staff user, but the 'DISPLAY_HISTORY_TAB' setting is not enabled
|
||||
const page = await doCachedLogin(browser, {
|
||||
user: stevenuser,
|
||||
url: 'part/111/details'
|
||||
});
|
||||
|
||||
await page.getByRole('tab', { name: 'Part Details' }).waitFor();
|
||||
await expect(historyTab(page)).toHaveCount(0);
|
||||
|
||||
// Non-staff user
|
||||
const page2 = await doCachedLogin(browser, {
|
||||
user: allaccessuser,
|
||||
url: 'part/111/details'
|
||||
});
|
||||
|
||||
await page2.getByRole('tab', { name: 'Part Details' }).waitFor();
|
||||
await expect(historyTab(page2)).toHaveCount(0);
|
||||
|
||||
await navigate(page2, 'purchasing/purchase-order/9/detail');
|
||||
await page2.getByRole('tab', { name: 'Order Details' }).waitFor();
|
||||
await expect(historyTab(page2)).toHaveCount(0);
|
||||
});
|
||||
Reference in new issue
Block a user