-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #2659 - Make console logs in browser configuration details easier to read #3103
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3f78ca3
Issue #2659 - Save console logs to the server and append the link to …
ksy36 2b77c9f
Issue #2659 - Added console logs view page and ui
ksy36 abc5f26
Issue #2659 - Functional tests for console log ui
ksy36 c939c7b
Issue #2659 - Add console logs saving to the new form
ksy36 e12e205
Issue #2659 - Move console logs saving to upload endpoint
ksy36 24a7f75
Issue #2659 - Trying htmlsafe_dumps for console logs upload
ksy36 6055e31
Issue #2659 - Move parsing console logs to the backend
ksy36 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/fixtures/uploads/2019/12/77d565bd-f1b4-4e76-a480-357f72df80b2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
{ | ||
"level": "log", | ||
"log": [ | ||
"test log" | ||
], | ||
"uri": "http://example.com/vendor.js", | ||
"pos": "95:13" | ||
}, | ||
{ | ||
"level": "warn", | ||
"log": [ | ||
"test warn" | ||
], | ||
"uri": "http://example.com/", | ||
"pos": "1:28535" | ||
}, | ||
{ | ||
"level": "error", | ||
"log": [ | ||
"test error" | ||
], | ||
"uri": "http://example.com/test.js?param=1¶m22=13", | ||
"pos": "1:1" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"use strict"; | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
const intern = require("intern").default; | ||
const { assert } = intern.getPlugin("chai"); | ||
const { registerSuite } = intern.getInterface("object"); | ||
const FunctionalHelpers = require("./lib/helpers.js"); | ||
|
||
var url = function(path) { | ||
return intern.config.siteRoot + path; | ||
}; | ||
|
||
registerSuite("Console logs page", { | ||
tests: { | ||
"console log page loads with right data"() { | ||
return FunctionalHelpers.openPage( | ||
this, | ||
url("/console_logs/2019/12/77d565bd-f1b4-4e76-a480-357f72df80b2"), | ||
"#console_logs_data" | ||
) | ||
.findByCssSelector("#console_logs_data") | ||
.getAttribute("data-file-id") | ||
.then(function(text) { | ||
assert.include(text, "7d565bd-f1b4-4e76-a480-357f72df80b2"); | ||
}) | ||
.getAttribute("data-subpath") | ||
.then(function(text) { | ||
assert.include(text, "2019/12"); | ||
}) | ||
.end() | ||
.findByCssSelector(".level-log > .log-message") | ||
.getVisibleText() | ||
.then(function(text) { | ||
assert.include(text, "test log"); | ||
}) | ||
.end() | ||
.findByCssSelector(".level-log > .log-file") | ||
.getVisibleText() | ||
.then(function(text) { | ||
assert.include(text, "vendor.js:95:13"); | ||
}) | ||
.end() | ||
.findByCssSelector(".level-warn > .log-file") | ||
.getVisibleText() | ||
.then(function(text) { | ||
assert.include(text, "http://example.com/:1:28535"); | ||
}) | ||
.end() | ||
.findByCssSelector(".level-error > .log-file") | ||
.getVisibleText() | ||
.then(function(text) { | ||
assert.include(text, "test.js:1:1"); | ||
}) | ||
.end(); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
'''Tests for console logs upload.''' | ||
|
||
import json | ||
import os.path | ||
import sys | ||
import unittest | ||
from werkzeug.datastructures import MultiDict | ||
|
||
# Add webcompat module to import path | ||
sys.path.append(os.path.realpath(os.pardir)) | ||
|
||
from webcompat import app # noqa | ||
|
||
LOG = [ | ||
{ | ||
'level': 'log', | ||
'log': [ | ||
'test log' | ||
], | ||
'uri': 'http://example.com/vendor.js', | ||
'pos': '95:13' | ||
}, | ||
{ | ||
'level': 'warn', | ||
'log': [ | ||
'test warn' | ||
], | ||
'uri': 'http://example.com/test.js', | ||
'pos': '1:28535' | ||
} | ||
] | ||
|
||
|
||
def get_json_contents(filepath): | ||
with open(filepath, 'r') as f: | ||
json_contents = json.load(f) | ||
return json_contents | ||
|
||
|
||
def get_path(self, url): | ||
return self.app.config['UPLOADS_DEFAULT_DEST'] + url + '.json' | ||
|
||
|
||
def cleanup(filepath): | ||
os.remove(filepath) | ||
|
||
|
||
def form_request(data): | ||
d = MultiDict() | ||
d['console_logs'] = data | ||
return d | ||
|
||
|
||
class TestConsoleUploads(unittest.TestCase): | ||
def setUp(self): | ||
app.config['TESTING'] = True | ||
self.app = app | ||
self.test_client = self.app.test_client() | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_get(self): | ||
'''Test that /upload/ doesn't let you GET.''' | ||
rv = self.test_client.get('/upload/') | ||
self.assertEqual(rv.status_code, 404) | ||
|
||
def test_console_log_upload(self): | ||
rv = self.test_client.post( | ||
'/upload/', data=form_request(json.dumps(LOG))) | ||
self.assertEqual(rv.status_code, 201) | ||
|
||
response = json.loads(rv.data) | ||
self.assertTrue('url' in response) | ||
cleanup(get_path(self, response.get('url'))) | ||
|
||
def test_console_log_bad_format(self): | ||
rv = self.test_client.post( | ||
'/upload/', data=form_request('{test}')) | ||
self.assertEqual(rv.status_code, 400) | ||
|
||
rv = self.test_client.post( | ||
'/upload/', data=form_request('')) | ||
self.assertEqual(rv.status_code, 501) | ||
|
||
rv = self.test_client.post( | ||
'/upload/', data=json.dumps(LOG)) | ||
self.assertEqual(rv.status_code, 501) | ||
|
||
def test_console_log_file_contents(self): | ||
rv = self.test_client.post( | ||
'/upload/', data=form_request(json.dumps(LOG))) | ||
response = json.loads(rv.data) | ||
filepath = get_path(self, response.get('url')) | ||
actual = get_json_contents(filepath) | ||
self.assertEqual(actual, LOG) | ||
cleanup(filepath) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self, we probably needs to create a console_logs directory