Host Details Page, Manage Host Table: Fix CPU rendering bug (#1912)

* Fix host_cpu to cpu_type

* Same bug in host table, helpers, and unit tests

* Update target's unit test

* Changelog

* Remove duplicate property
This commit is contained in:
RachelElysia 2021-09-09 18:42:35 +02:00 committed by GitHub
parent befb65d191
commit d807c0b227
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 14 deletions

1
changes/1912-fix-cpu-bug Normal file
View file

@ -0,0 +1 @@
Fixes frontend CPU type bug from API change that was not reflected in frontend UI or tests

View file

@ -651,7 +651,7 @@ export class HostDetailsPage extends Component {
pick(host, [
"status",
"memory",
"host_cpu",
"cpu_type",
"os_version",
"enroll_secret_name",
"detail_updated_at",
@ -765,7 +765,7 @@ export class HostDetailsPage extends Component {
</div>
<div className="info__item info__item--title">
<span className="info__header">CPU</span>
<span className="info__data">{titleData.host_cpu}</span>
<span className="info__data">{titleData.cpu_type}</span>
</div>
<div className="info__item info__item--title">
<span className="info__header">OS</span>

View file

@ -216,7 +216,7 @@ const allHostTableHeaders: IHostDataColumn[] = [
title: "CPU",
Header: "CPU",
disableSortBy: true,
accessor: "host_cpu",
accessor: "cpu_type",
Cell: (cellProps) => <TextCell value={cellProps.cell.value} />,
},
{
@ -269,7 +269,7 @@ const allHostTableHeaders: IHostDataColumn[] = [
const defaultHiddenColumns = [
"primary_mac",
"host_cpu",
"cpu_type",
"memory",
"uptime",
"uuid",

View file

@ -22,7 +22,7 @@ export const parseEntityFunc = (host) => {
}
const additionalAttrs = {
host_cpu: hostCpuOutput,
cpu_type: hostCpuOutput,
target_type: "hosts",
};

View file

@ -7,7 +7,7 @@ describe("reduxConfig - hosts helpers", () => {
cpu_brand: "Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz",
cpu_physical_cores: 2,
};
expect(parseEntityFunc(host).host_cpu).toEqual("2 x 1.9 GHz");
expect(parseEntityFunc(host).cpu_type).toEqual("2 x 1.9 GHz");
});
it("parses a host missing clock speed", () => {
@ -15,26 +15,26 @@ describe("reduxConfig - hosts helpers", () => {
cpu_brand: "Intel(R) Xeon(R) CPU E5-242",
cpu_physical_cores: 2,
};
expect(parseEntityFunc(host).host_cpu).toEqual("2 x Unknown GHz");
expect(parseEntityFunc(host).cpu_type).toEqual("2 x Unknown GHz");
});
it("parses a host missing CPU brand", () => {
const host = {
cpu_physical_cores: 2,
};
expect(parseEntityFunc(host).host_cpu).toEqual("2 x Unknown GHz");
expect(parseEntityFunc(host).cpu_type).toEqual("2 x Unknown GHz");
});
it("parses a host missing CPU cores", () => {
const host = {
cpu_brand: "Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz",
};
expect(parseEntityFunc(host).host_cpu).toEqual("Unknown x 1.9 GHz");
expect(parseEntityFunc(host).cpu_type).toEqual("Unknown x 1.9 GHz");
});
it("parses a host missing CPU info entirely", () => {
const host = {};
expect(parseEntityFunc(host).host_cpu).toEqual(null);
expect(parseEntityFunc(host).cpu_type).toEqual(null);
});
});
});

View file

@ -39,7 +39,7 @@ describe("targets - helpers", () => {
id: 3,
cpu_brand: "Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz",
cpu_physical_cores: 2,
host_cpu: "2 x 2.9 GHz",
cpu_type: "2 x 2.9 GHz",
label: "OS X El Capitan 10.11",
name: "osx-10.11",
platform: "darwin",
@ -49,7 +49,7 @@ describe("targets - helpers", () => {
id: 4,
cpu_brand: "Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz",
cpu_physical_cores: 2,
host_cpu: "2 x 2.9 GHz",
cpu_type: "2 x 2.9 GHz",
label: "Jason Meller's Macbook Pro",
name: "jmeller.local",
platform: "darwin",

View file

@ -79,7 +79,7 @@ export const hostStub = {
code_name: "",
uptime: 45469000000000,
memory: 2094940160,
cpu_type: "6",
cpu_type: "1 x 2.4Ghz",
cpu_subtype: "78",
cpu_brand: "Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz",
cpu_physical_cores: 2,
@ -94,7 +94,6 @@ export const hostStub = {
status: "online",
display_text: "52883a0ba916",
target_type: "hosts",
host_cpu: "1 x 2.4Ghz",
};
export const labelStub = {