зеркало из 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.
|
||||
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 serviceContainer = require("devtools/client/webconsole/new-console-output/test/fixtures/serviceContainer");
|
||||
|
||||
describe("ConsoleAPICall component:", () => {
|
||||
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", () => {
|
||||
let message = prepareMessage(logMessageStubPacket, {getNextId: () => "1"});
|
||||
message = new ConsoleMessage(message);
|
||||
|
||||
const wrapper = render(ConsoleApiCall({ message, serviceContainer }));
|
||||
|
||||
expect(wrapper.find(".message-body").text()).toBe("foobar test");
|
||||
|
@ -33,9 +40,16 @@ describe("ConsoleAPICall component:", () => {
|
|||
});
|
||||
|
||||
// Stub packet
|
||||
const logMessageStubPacket = {
|
||||
const cachedLogMessageStubPacket = {
|
||||
"from": "server1.conn1.consoleActor2",
|
||||
"message": "foobar test",
|
||||
"timeStamp": "1493370184067",
|
||||
"_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) {
|
||||
let { message } = packet;
|
||||
let {
|
||||
message,
|
||||
timeStamp,
|
||||
} = packet;
|
||||
|
||||
return new ConsoleMessage({
|
||||
source: MESSAGE_SOURCE.CONSOLE_API,
|
||||
type: MESSAGE_TYPE.LOG,
|
||||
level: MESSAGE_LEVEL.LOG,
|
||||
messageText: message.message,
|
||||
timeStamp: message.timeStamp
|
||||
messageText: message,
|
||||
timeStamp,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -318,8 +322,10 @@ function convertCachedPacket(packet) {
|
|||
convertPacket.networkEvent = packet;
|
||||
convertPacket.type = "networkEvent";
|
||||
} else if (packet._type === "LogMessage") {
|
||||
convertPacket.message = packet;
|
||||
convertPacket.type = "logMessage";
|
||||
convertPacket = {
|
||||
...packet,
|
||||
type: "logMessage"
|
||||
};
|
||||
} else {
|
||||
throw new Error("Unexpected packet type: " + packet._type);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче