[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:
Oliver authored and GitHub committed 2026-10-25 12:36:13 +11:00
1 parent cdb3b1ecf7
commit c475e9bfcf
91 files changed
+7753 -102

No files matched your search

+12
View File
@@ -141,6 +141,18 @@ export const activateCalendarView = async (page: Page) => {
await page.waitForLoadState('networkidle');
};
export const tableSearch = async (page: Page, query: string) => {
await page.getByLabel('table-search-input').fill(query);
await page.waitForTimeout(300);
await page.waitForLoadState('networkidle');
};
export const clearTableSearch = async (page: Page) => {
await page.getByLabel('table-search-input').clear();
await page.waitForTimeout(300);
await page.waitForLoadState('networkidle');
};
/**
* Perform a 'global search' on the provided page, for the provided query text
*/
+5 -3
View File
@@ -3,6 +3,7 @@ import { test } from '../baseFixtures.ts';
import {
activateCalendarView,
clearTableFilters,
clearTableSearch,
clickOnRowMenu,
getRowFromCell,
loadTab,
@@ -12,6 +13,7 @@ import {
showCalendarView,
showParametricView,
showTableView,
tableSearch,
waitForDataOutput
} from '../helpers.ts';
import { doCachedLogin } from '../login.ts';
@@ -275,7 +277,7 @@ test('Build Order - Build Outputs', async ({ browser }) => {
await clearTableFilters(page);
// We have now loaded the "Build Order" table. Check for some expected texts
await page.getByRole('textbox', { name: 'table-search-input' }).fill('1');
await tableSearch(page, '1');
await page.getByText('On Hold').first().waitFor();
await page.getByText('Pending').first().waitFor();
@@ -757,11 +759,11 @@ test('Build Order - Filters', async ({ browser }) => {
// Toggle 'Outstanding' filter
await setTableChoiceFilter(page, 'Outstanding', 'Yes');
await page.getByRole('textbox', { name: 'table-search-input' }).fill('1');
await tableSearch(page, '1');
await page.getByRole('cell', { name: 'BO0017' }).waitFor();
await clearTableFilters(page);
await page.getByRole('textbox', { name: 'table-search-input' }).fill('');
await clearTableSearch(page);
await setTableChoiceFilter(page, 'Outstanding', 'No');
await page.getByText(/1 - \d+ \/ \d+/).waitFor();
+3 -2
View File
@@ -13,7 +13,8 @@ import {
openDetailAction,
setTableChoiceFilter,
showParametricView,
showTableView
showTableView,
tableSearch
} from '../helpers';
import { adminuser } from '../defaults';
@@ -406,7 +407,7 @@ test('Parts - BOM Nesting', async ({ browser }) => {
await expect(page.getByText('MAX232IDR')).toHaveCount(0);
// Searching reloads the table, which discards sub-assembly rows
await page.getByLabel('table-search-input').fill('Doohickey');
await tableSearch(page, 'Doohickey');
await expect(page.getByText('M3x10 Torx')).toHaveCount(0);
await expect(
page.getByRole('button', { name: 'nested-row-collapse' })
@@ -16,6 +16,7 @@ import {
showCalendarView,
showParametricView,
showTableView,
tableSearch,
waitForDataOutput
} from '../helpers.ts';
import { doCachedLogin } from '../login.ts';
@@ -53,9 +54,7 @@ test('Purchasing - Index', async ({ browser }) => {
// Check for expected values
await clearTableFilters(page);
await page
.getByRole('textbox', { name: 'table-search-input' })
.fill('R_100K_0402');
await tableSearch(page, 'R_100K_0402');
await page.getByText('R_100K_0402_1%').first().waitFor();
await page.getByRole('cell', { name: 'RR05P100KDTR-ND' }).first().waitFor();
@@ -155,9 +154,7 @@ test('Purchasing - Manufacturer Parts', async ({ browser }) => {
url: 'purchasing/index/manufacturer-parts'
});
await page
.getByRole('textbox', { name: 'table-search-input' })
.fill('CPF0402B100KE1');
await tableSearch(page, 'CPF0402B100KE1');
await page.getByText('R_100K_0402_1%').first().waitFor();
await page.getByRole('cell', { name: 'CPF0402B100KE1' }).waitFor();
@@ -609,9 +606,7 @@ test('Purchase Orders - Receive Items', async ({ browser }) => {
await loadTab(page, 'Received Stock');
await clearTableFilters(page);
await page
.getByRole('textbox', { name: 'table-search-input' })
.fill('my-batch-code');
await tableSearch(page, 'my-batch-code');
await page.getByRole('cell', { name: 'my-batch-code' }).first().waitFor();
});
@@ -669,9 +664,7 @@ test('Purchase Orders - Custom Location', async ({ browser }) => {
await loadTab(page, 'Received Stock');
await clearTableFilters(page);
await page
.getByRole('textbox', { name: 'table-search-input' })
.fill('po-custom-location-test');
await tableSearch(page, 'po-custom-location-test');
const receivedRow = page
.getByRole('row')
+100
View File
@@ -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);
});
@@ -6,12 +6,18 @@ import { test } from './baseFixtures';
import { adminuser, readeruser } from './defaults';
import { clickOnRowMenu, loadTab } from './helpers';
import { doCachedLogin } from './login';
import { setSettingState } from './settings';
/**
* Test the "admin" account
* - This is a superuser account, so should have *all* permissions available
*/
test('Permissions - Admin', async ({ browser }) => {
await setSettingState({
setting: 'INVENTREE_SHOW_SUPERUSER_BANNER',
value: true
});
// Login, and start on the "admin" page
const page = await doCachedLogin(browser, {
user: adminuser,
+4 -3
View File
@@ -6,7 +6,8 @@ import {
clickOnRowMenu,
loadTab,
navigate,
setTableChoiceFilter
setTableChoiceFilter,
tableSearch
} from './helpers.js';
import { doCachedLogin } from './login.js';
import { setPluginState, setSettingState } from './settings.js';
@@ -26,7 +27,7 @@ test('Plugins - Settings', async ({ browser }) => {
// Navigate and select the plugin
await navigate(page, 'settings/admin/plugin/');
await clearTableFilters(page);
await page.getByLabel('table-search-input').fill('integration');
await tableSearch(page, 'integration');
await page.waitForTimeout(250);
await page.waitForLoadState('networkidle');
@@ -305,7 +306,7 @@ test('Plugins - Creator', async ({ browser }) => {
// View a custom table
await page.getByRole('button', { name: 'Custom Table Example' }).click();
await page.getByRole('textbox', { name: 'table-search-input' }).fill('red');
await tableSearch(page, 'red');
await page.waitForLoadState('networkidle');
await page.getByRole('cell', { name: 'Red Square Table' }).first().waitFor();
});
+2 -3
View File
@@ -5,6 +5,7 @@ import {
activateTableView,
loadTab,
navigate,
tableSearch,
waitForDataOutput
} from './helpers.js';
import { doCachedLogin } from './login.js';
@@ -243,9 +244,7 @@ test('Printing - Broken Template', async ({ browser }) => {
// Next, check error message from the template editor preview
await navigate(page, 'settings/admin/reports');
await page
.getByRole('textbox', { name: 'table-search-input' })
.fill('broken');
await tableSearch(page, 'broken');
await page.getByRole('cell', { name: 'Broken Sales Order Report' }).click();
await page.getByLabel('split-button-preview-options-action').click();
+11 -9
View File
@@ -2,7 +2,13 @@ import type { Page } from '@playwright/test';
import { createApi } from './api.js';
import { expect, test } from './baseFixtures.js';
import { adminuser, allaccessuser, stevenuser } from './defaults.js';
import { getRowFromCell, loadTab, navigate } from './helpers.js';
import {
clearTableSearch,
getRowFromCell,
loadTab,
navigate,
tableSearch
} from './helpers.js';
import { doCachedLogin } from './login.js';
import { setPluginState, setSettingState } from './settings.js';
@@ -417,10 +423,8 @@ test('Settings - Admin - Barcode History', async ({ browser }) => {
await page.waitForTimeout(500);
const checkBarcode = async (barcode: string) => {
await page.getByRole('textbox', { name: 'table-search-input' }).clear();
await page
.getByRole('textbox', { name: 'table-search-input' })
.fill(barcode);
await clearTableSearch(page);
await tableSearch(page, barcode);
await page.waitForLoadState('networkidle');
await page.getByText(barcode).first().waitFor();
};
@@ -441,16 +445,14 @@ test('Settings - Admin - Parameter', async ({ browser }) => {
await loadTab(page, 'Selection Lists');
// Check for expected entry
await page
.getByRole('textbox', { name: 'table-search-input' })
.fill('Animals');
await tableSearch(page, 'Animals');
await page.getByRole('cell', { name: 'Animals', exact: true }).waitFor();
await page.getByText('Various animals and descriptions thereof').waitFor();
await page.waitForLoadState('networkidle');
await page.waitForTimeout(250);
await page.getByRole('textbox', { name: 'table-search-input' }).fill('some');
await tableSearch(page, 'some');
await page.waitForTimeout(500);
await page.waitForLoadState('networkidle');