Name customer selectors and validate customer fixtures during frontend builds
This commit is contained in:
@@ -52,8 +52,10 @@ test('creates and renames a customer, opens its inventory, and hides editing for
|
|||||||
return route.fulfill({ json: { ...listing(customers), can_manage_customers: canManage } });
|
return route.fulfill({ json: { ...listing(customers), can_manage_customers: canManage } });
|
||||||
}
|
}
|
||||||
if (method === 'GET' && path === `${collection}/${customerId}/devices`) {
|
if (method === 'GET' && path === `${collection}/${customerId}/devices`) {
|
||||||
|
const customer = customers.find(c => c.tenant_id === customerId);
|
||||||
|
if (!customer) throw new Error('Kunde fehlt im Testbestand');
|
||||||
return route.fulfill({ json: listing([{
|
return route.fulfill({ json: listing([{
|
||||||
tenant_id: customerId, customer_name: customers[1].name, asset_id: 'device-1', agent_id: 'agent-1',
|
tenant_id: customerId, customer_name: customer.name, asset_id: 'device-1', agent_id: 'agent-1',
|
||||||
lifecycle: 'current', status: 'online', hostname: 'NORD-PC', os: 'Linux'
|
lifecycle: 'current', status: 'online', hostname: 'NORD-PC', os: 'Linux'
|
||||||
}]) });
|
}]) });
|
||||||
}
|
}
|
||||||
@@ -69,8 +71,10 @@ test('creates and renames a customer, opens its inventory, and hides editing for
|
|||||||
}
|
}
|
||||||
if (method === 'PATCH' && path === `${collection}/${customerId}`) {
|
if (method === 'PATCH' && path === `${collection}/${customerId}`) {
|
||||||
expect(request.headers()['x-rmm-tenant']).toBe(customerId);
|
expect(request.headers()['x-rmm-tenant']).toBe(customerId);
|
||||||
customers[1].name = body.name;
|
const customer = customers.find(c => c.tenant_id === customerId);
|
||||||
return route.fulfill({ json: customers[1] });
|
if (!customer) throw new Error('Unbekannter Testkunde');
|
||||||
|
customer.name = body.name;
|
||||||
|
return route.fulfill({ json: customer });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return route.fulfill({ status: 404, json: { code: 'UNEXPECTED_FIXTURE_REQUEST', message: path } });
|
return route.fulfill({ status: 404, json: { code: 'UNEXPECTED_FIXTURE_REQUEST', message: path } });
|
||||||
|
|||||||
@@ -407,6 +407,7 @@ export function Devices({
|
|||||||
<label>
|
<label>
|
||||||
<span>Kunde</span>
|
<span>Kunde</span>
|
||||||
<select
|
<select
|
||||||
|
aria-label="Kunde"
|
||||||
value={filter}
|
value={filter}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setRoutes([]);
|
setRoutes([]);
|
||||||
@@ -425,6 +426,7 @@ export function Devices({
|
|||||||
<label>
|
<label>
|
||||||
<span>Status</span>
|
<span>Status</span>
|
||||||
<select
|
<select
|
||||||
|
aria-label="Status"
|
||||||
value={status}
|
value={status}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setRoutes([]);
|
setRoutes([]);
|
||||||
|
|||||||
+2
-2
@@ -367,7 +367,7 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
|
|||||||
<div className="account">
|
<div className="account">
|
||||||
<div>
|
<div>
|
||||||
<span className="account-dot" aria-hidden="true" />
|
<span className="account-dot" aria-hidden="true" />
|
||||||
<span title={auth.principal.id}>{auth.principal.display_name}</span>
|
<span title={auth.principal.id}>{auth.principal.display_name === auth.principal.id && auth.principal.id.startsWith('local:') ? 'Lokales Konto' : auth.principal.display_name}</span>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
@@ -394,7 +394,7 @@ function Workspace({ auth, logout }: { auth: Session; logout: () => void }) {
|
|||||||
{route.page !== 'geraete' && route.page !== 'kunden' && (
|
{route.page !== 'geraete' && route.page !== 'kunden' && (
|
||||||
<label className="context">
|
<label className="context">
|
||||||
<span>Kunde</span>
|
<span>Kunde</span>
|
||||||
<select value={customer} onChange={(e) => switchCustomer(e.target.value)}>
|
<select aria-label="Kunde" value={customer} onChange={(e) => switchCustomer(e.target.value)}>
|
||||||
{customers.map((c) => (
|
{customers.map((c) => (
|
||||||
<option value={c.tenant_id} key={c.tenant_id}>
|
<option value={c.tenant_id} key={c.tenant_id}>
|
||||||
{c.name}
|
{c.name}
|
||||||
|
|||||||
Reference in New Issue
Block a user