зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1438542 - Fix rendering of non-cached message issued from logStringMessage; r=miker.
We weren't doing the right transform for cached messages, and thus we weren't creating the ConsoleMessage with the correct properties. This is now fixed and a mocha test is added to make sure we don't regress on this. MozReview-Commit-ID: ACOCPF06GK2 --HG-- extra : rebase_source : 029fe31b7343f4032ea48a8629bae8d8c0a87e62
This commit is contained in:
Родитель
e63e670281
Коммит
32b0754ade
|
@ -12,16 +12,23 @@ const { createFactory } = require("devtools/client/shared/vendor/react");
|
||||||
// Components under test.
|
// Components under test.
|
||||||
const ConsoleApiCall = createFactory(require("devtools/client/webconsole/new-console-output/components/message-types/ConsoleApiCall"));
|
const ConsoleApiCall = createFactory(require("devtools/client/webconsole/new-console-output/components/message-types/ConsoleApiCall"));
|
||||||
|
|
||||||
const { ConsoleMessage } = require("devtools/client/webconsole/new-console-output/types");
|
|
||||||
const { prepareMessage } = require("devtools/client/webconsole/new-console-output/utils/messages");
|
const { prepareMessage } = require("devtools/client/webconsole/new-console-output/utils/messages");
|
||||||
const serviceContainer = require("devtools/client/webconsole/new-console-output/test/fixtures/serviceContainer");
|
const serviceContainer = require("devtools/client/webconsole/new-console-output/test/fixtures/serviceContainer");
|
||||||
|
|
||||||
describe("ConsoleAPICall component:", () => {
|
describe("ConsoleAPICall component:", () => {
|
||||||
describe("Services.console.logStringMessage", () => {
|
describe("Services.console.logStringMessage", () => {
|
||||||
|
it("renders cached logMessage grips", () => {
|
||||||
|
let message = prepareMessage(cachedLogMessageStubPacket, {getNextId: () => "1"});
|
||||||
|
const wrapper = render(ConsoleApiCall({ message, serviceContainer }));
|
||||||
|
|
||||||
|
expect(wrapper.find(".message-body").text()).toBe("foobar test");
|
||||||
|
|
||||||
|
// There should not be the location
|
||||||
|
expect(wrapper.find(".message-location").text()).toBe("");
|
||||||
|
});
|
||||||
|
|
||||||
it("renders logMessage grips", () => {
|
it("renders logMessage grips", () => {
|
||||||
let message = prepareMessage(logMessageStubPacket, {getNextId: () => "1"});
|
let message = prepareMessage(logMessageStubPacket, {getNextId: () => "1"});
|
||||||
message = new ConsoleMessage(message);
|
|
||||||
|
|
||||||
const wrapper = render(ConsoleApiCall({ message, serviceContainer }));
|
const wrapper = render(ConsoleApiCall({ message, serviceContainer }));
|
||||||
|
|
||||||
expect(wrapper.find(".message-body").text()).toBe("foobar test");
|
expect(wrapper.find(".message-body").text()).toBe("foobar test");
|
||||||
|
@ -33,9 +40,16 @@ describe("ConsoleAPICall component:", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Stub packet
|
// Stub packet
|
||||||
const logMessageStubPacket = {
|
const cachedLogMessageStubPacket = {
|
||||||
"from": "server1.conn1.consoleActor2",
|
"from": "server1.conn1.consoleActor2",
|
||||||
"message": "foobar test",
|
"message": "foobar test",
|
||||||
"timeStamp": "1493370184067",
|
"timeStamp": "1493370184067",
|
||||||
"_type": "LogMessage",
|
"_type": "LogMessage",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const logMessageStubPacket = {
|
||||||
|
"from": "server1.conn0.consoleActor2",
|
||||||
|
"type": "logMessage",
|
||||||
|
"message": "foobar test",
|
||||||
|
"timeStamp": 1519052480060
|
||||||
|
};
|
||||||
|
|
|
@ -182,13 +182,17 @@ function transformNavigationMessagePacket(packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function transformLogMessagePacket(packet) {
|
function transformLogMessagePacket(packet) {
|
||||||
let { message } = packet;
|
let {
|
||||||
|
message,
|
||||||
|
timeStamp,
|
||||||
|
} = packet;
|
||||||
|
|
||||||
return new ConsoleMessage({
|
return new ConsoleMessage({
|
||||||
source: MESSAGE_SOURCE.CONSOLE_API,
|
source: MESSAGE_SOURCE.CONSOLE_API,
|
||||||
type: MESSAGE_TYPE.LOG,
|
type: MESSAGE_TYPE.LOG,
|
||||||
level: MESSAGE_LEVEL.LOG,
|
level: MESSAGE_LEVEL.LOG,
|
||||||
messageText: message.message,
|
messageText: message,
|
||||||
timeStamp: message.timeStamp
|
timeStamp,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,8 +322,10 @@ function convertCachedPacket(packet) {
|
||||||
convertPacket.networkEvent = packet;
|
convertPacket.networkEvent = packet;
|
||||||
convertPacket.type = "networkEvent";
|
convertPacket.type = "networkEvent";
|
||||||
} else if (packet._type === "LogMessage") {
|
} else if (packet._type === "LogMessage") {
|
||||||
convertPacket.message = packet;
|
convertPacket = {
|
||||||
convertPacket.type = "logMessage";
|
...packet,
|
||||||
|
type: "logMessage"
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Unexpected packet type: " + packet._type);
|
throw new Error("Unexpected packet type: " + packet._type);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче