logster 2.20.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -92
  3. data/README.md +29 -14
  4. data/assets/javascript/main-B82IoCiW.js +1 -0
  5. data/assets/javascript/modules-4-12-BHA4lR2U.js +1 -0
  6. data/assets/javascript/vendor.js +11 -5260
  7. data/assets/logster-config.json +18 -0
  8. data/assets/manifest.json +23 -0
  9. data/assets/stylesheets/main-CgAFFyi8.css +1 -0
  10. data/lib/logster/configuration.rb +1 -0
  11. data/lib/logster/group.rb +2 -2
  12. data/lib/logster/message.rb +4 -4
  13. data/lib/logster/middleware/reporter.rb +34 -3
  14. data/lib/logster/middleware/viewer.rb +205 -33
  15. data/lib/logster/rails/railtie.rb +4 -20
  16. data/lib/logster/redis_store.rb +0 -2
  17. data/lib/logster/version.rb +1 -1
  18. data/lib/logster.rb +1 -1
  19. metadata +17 -186
  20. data/.github/workflows/ci.yml +0 -140
  21. data/.gitignore +0 -3
  22. data/.rubocop.yml +0 -8
  23. data/.streerc +0 -2
  24. data/Gemfile +0 -10
  25. data/Guardfile +0 -10
  26. data/Rakefile +0 -27
  27. data/assets/javascript/.gitkeep +0 -0
  28. data/assets/javascript/chunk.524.c3042190e39d148beaf9.js +0 -22
  29. data/assets/javascript/chunk.582.695dcbfb11a784b110cd.js +0 -22
  30. data/assets/javascript/chunk.747.a730c497582bb6742a6e.js +0 -579
  31. data/assets/javascript/chunk.761.64949d89942c829e5c1b.js +0 -1213
  32. data/assets/javascript/client-app.js +0 -1390
  33. data/assets/stylesheets/.gitkeep +0 -0
  34. data/assets/stylesheets/client-app.css +0 -1
  35. data/assets/stylesheets/vendor.css +0 -1
  36. data/build_client_app.sh +0 -10
  37. data/client-app/.editorconfig +0 -19
  38. data/client-app/.ember-cli +0 -9
  39. data/client-app/.eslintignore +0 -20
  40. data/client-app/.eslintrc +0 -10
  41. data/client-app/.gitignore +0 -23
  42. data/client-app/.prettierignore +0 -21
  43. data/client-app/.prettierrc +0 -1
  44. data/client-app/.template-lintrc.js +0 -10
  45. data/client-app/.watchmanconfig +0 -3
  46. data/client-app/README.md +0 -56
  47. data/client-app/app/app.js +0 -12
  48. data/client-app/app/components/actions-menu.js +0 -50
  49. data/client-app/app/components/back-to-site-link.js +0 -9
  50. data/client-app/app/components/back-trace.js +0 -153
  51. data/client-app/app/components/env-tab.js +0 -68
  52. data/client-app/app/components/message-info.js +0 -151
  53. data/client-app/app/components/message-row.js +0 -46
  54. data/client-app/app/components/page-nav.js +0 -42
  55. data/client-app/app/components/panel-resizer.js +0 -108
  56. data/client-app/app/components/patterns-list.js +0 -142
  57. data/client-app/app/components/tab-contents.js +0 -23
  58. data/client-app/app/components/tabbed-section.js +0 -45
  59. data/client-app/app/components/time-formatter.js +0 -36
  60. data/client-app/app/controllers/index.js +0 -269
  61. data/client-app/app/controllers/show.js +0 -39
  62. data/client-app/app/helpers/logster-url.js +0 -12
  63. data/client-app/app/helpers/or.js +0 -7
  64. data/client-app/app/index.html +0 -31
  65. data/client-app/app/initializers/app-init.js +0 -71
  66. data/client-app/app/lib/decorators.js +0 -13
  67. data/client-app/app/lib/preload.js +0 -43
  68. data/client-app/app/lib/utilities.js +0 -230
  69. data/client-app/app/models/group.js +0 -34
  70. data/client-app/app/models/message-collection.js +0 -303
  71. data/client-app/app/models/message.js +0 -128
  72. data/client-app/app/models/pattern-item.js +0 -32
  73. data/client-app/app/resolver.js +0 -3
  74. data/client-app/app/router.js +0 -13
  75. data/client-app/app/routes/index.js +0 -64
  76. data/client-app/app/routes/settings.js +0 -32
  77. data/client-app/app/routes/show.js +0 -16
  78. data/client-app/app/services/events.js +0 -4
  79. data/client-app/app/styles/app.css +0 -829
  80. data/client-app/app/templates/application.hbs +0 -1
  81. data/client-app/app/templates/components/actions-menu.hbs +0 -31
  82. data/client-app/app/templates/components/back-to-site-link.hbs +0 -8
  83. data/client-app/app/templates/components/back-trace.hbs +0 -15
  84. data/client-app/app/templates/components/env-tab.hbs +0 -10
  85. data/client-app/app/templates/components/message-info.hbs +0 -86
  86. data/client-app/app/templates/components/message-row.hbs +0 -32
  87. data/client-app/app/templates/components/page-nav.hbs +0 -37
  88. data/client-app/app/templates/components/panel-resizer.hbs +0 -3
  89. data/client-app/app/templates/components/patterns-list.hbs +0 -78
  90. data/client-app/app/templates/components/tabbed-section.hbs +0 -18
  91. data/client-app/app/templates/components/time-formatter.hbs +0 -1
  92. data/client-app/app/templates/index.hbs +0 -165
  93. data/client-app/app/templates/settings.hbs +0 -47
  94. data/client-app/app/templates/show.hbs +0 -13
  95. data/client-app/config/ember-cli-update.json +0 -18
  96. data/client-app/config/environment.js +0 -51
  97. data/client-app/config/icons.js +0 -28
  98. data/client-app/config/optional-features.json +0 -6
  99. data/client-app/config/targets.js +0 -26
  100. data/client-app/ember-cli-build.js +0 -28
  101. data/client-app/package.json +0 -76
  102. data/client-app/preload-json-manager.rb +0 -35
  103. data/client-app/public/assets/images/icon_144x144.png +0 -0
  104. data/client-app/public/assets/images/icon_64x64.png +0 -0
  105. data/client-app/testem.js +0 -23
  106. data/client-app/tests/index.html +0 -41
  107. data/client-app/tests/integration/components/back-to-site-link-test.js +0 -20
  108. data/client-app/tests/integration/components/back-trace-test.js +0 -138
  109. data/client-app/tests/integration/components/env-tab-test.js +0 -220
  110. data/client-app/tests/integration/components/message-info-test.js +0 -122
  111. data/client-app/tests/integration/components/patterns-list-test.js +0 -76
  112. data/client-app/tests/test-helper.js +0 -12
  113. data/client-app/tests/unit/controllers/index-test.js +0 -77
  114. data/client-app/tests/unit/controllers/show-test.js +0 -12
  115. data/client-app/tests/unit/routes/index-test.js +0 -11
  116. data/client-app/tests/unit/routes/show-test.js +0 -11
  117. data/client-app/yarn.lock +0 -9905
  118. data/gemfiles/rails_6.1.gemfile +0 -12
  119. data/gemfiles/rails_7.0.gemfile +0 -12
  120. data/gemfiles/rails_7.1.gemfile +0 -9
  121. data/gemfiles/rails_7.2.gemfile +0 -9
  122. data/logster.gemspec +0 -43
  123. data/test/dummy/config/application.rb +0 -31
  124. data/test/dummy/config/boot.rb +0 -6
  125. data/test/dummy/config/environment.rb +0 -6
  126. data/test/examples/test_sidekiq_reporter_example.rb +0 -47
  127. data/test/fake_data/Gemfile +0 -6
  128. data/test/fake_data/generate.rb +0 -23
  129. data/test/logster/middleware/test_reporter.rb +0 -84
  130. data/test/logster/middleware/test_viewer.rb +0 -495
  131. data/test/logster/test_base_store.rb +0 -224
  132. data/test/logster/test_cache.rb +0 -39
  133. data/test/logster/test_defer_logger.rb +0 -36
  134. data/test/logster/test_group.rb +0 -92
  135. data/test/logster/test_ignore_pattern.rb +0 -42
  136. data/test/logster/test_logger.rb +0 -177
  137. data/test/logster/test_message.rb +0 -269
  138. data/test/logster/test_pattern.rb +0 -144
  139. data/test/logster/test_railtie.rb +0 -21
  140. data/test/logster/test_redis_rate_limiter.rb +0 -246
  141. data/test/logster/test_redis_store.rb +0 -1165
  142. data/test/test_helper.rb +0 -44
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- const browsers = [
4
- "last 1 Chrome versions",
5
- "last 1 Firefox versions",
6
- "last 1 Safari versions",
7
- ];
8
-
9
- // Ember's browser support policy is changing, and IE11 support will end in
10
- // v4.0 onwards.
11
- //
12
- // See https://deprecations.emberjs.com/v3.x#toc_3-0-browser-support-policy
13
- //
14
- // If you need IE11 support on a version of Ember that still offers support
15
- // for it, uncomment the code block below.
16
-
17
- const isCI = Boolean(process.env.CI);
18
- const isProduction = process.env.EMBER_ENV === "production";
19
-
20
- if (isCI || isProduction) {
21
- browsers.push("ie 11");
22
- }
23
-
24
- module.exports = {
25
- browsers,
26
- };
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- const EmberApp = require("ember-cli/lib/broccoli/ember-app");
4
-
5
- module.exports = function (defaults) {
6
- let app = new EmberApp(defaults, {
7
- // Add options here
8
- fingerprint: {
9
- enabled: false,
10
- },
11
- });
12
-
13
- // Use `app.import` to add additional libraries to the generated
14
- // output files.
15
- //
16
- // If you need to use different assets in different
17
- // environments, specify an object as the first parameter. That
18
- // object's keys should be the environment name and the values
19
- // should be the asset to use in that environment.
20
- //
21
- // If the library that you are including contains AMD or ES6
22
- // modules that you would like to import into your application
23
- // please specify an object with the list of modules as keys
24
- // along with the exports of each module as its value.
25
-
26
- app.import("node_modules/moment/min/moment.min.js");
27
- return app.toTree();
28
- };
@@ -1,76 +0,0 @@
1
- {
2
- "name": "client-app",
3
- "version": "0.0.0",
4
- "private": true,
5
- "description": "Logging framework and viewer",
6
- "repository": "https://github.com/discourse/logster/",
7
- "license": "MIT",
8
- "author": "Sam Saffron",
9
- "directories": {
10
- "doc": "doc",
11
- "test": "tests"
12
- },
13
- "scripts": {
14
- "build": "ember build --environment=production",
15
- "lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
16
- "lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
17
- "lint:hbs": "ember-template-lint .",
18
- "lint:hbs:fix": "ember-template-lint . --fix",
19
- "lint:js": "eslint . --cache",
20
- "lint:js:fix": "eslint . --fix",
21
- "start": "ember serve",
22
- "test": "npm-run-all lint test:*",
23
- "test:ember": "ember test"
24
- },
25
- "devDependencies": {
26
- "@ember/optional-features": "^2.0.0",
27
- "@ember/test-helpers": "^2.6.0",
28
- "@fortawesome/ember-fontawesome": "^0.4.1",
29
- "@fortawesome/free-brands-svg-icons": "^6.3.0",
30
- "@fortawesome/free-regular-svg-icons": "^6.3.0",
31
- "@fortawesome/free-solid-svg-icons": "^6.3.0",
32
- "@glimmer/component": "^1.0.4",
33
- "@glimmer/tracking": "^1.0.4",
34
- "babel-eslint": "^10.1.0",
35
- "broccoli-asset-rev": "^3.0.0",
36
- "ember-auto-import": "^2.6.1",
37
- "ember-classic-decorator": "^3.0.1",
38
- "ember-cli": "^3.28.6",
39
- "ember-cli-app-version": "^6.0.0",
40
- "ember-cli-babel": "^7.26.10",
41
- "ember-cli-dependency-checker": "^3.2.0",
42
- "ember-cli-htmlbars": "^6.2.0",
43
- "ember-cli-inject-live-reload": "^2.1.0",
44
- "ember-cli-sri": "^2.1.1",
45
- "ember-cli-terser": "^4.0.2",
46
- "ember-decorators": "^6.1.1",
47
- "ember-export-application-global": "^2.0.1",
48
- "ember-load-initializers": "^2.1.2",
49
- "ember-maybe-import-regenerator": "^1.0.0",
50
- "ember-page-title": "^7.0.0",
51
- "ember-qunit": "^6.2.0",
52
- "ember-resolver": "^10.0.0",
53
- "ember-sinon-qunit": "^7.0.0",
54
- "ember-source": "^3.28.11",
55
- "eslint-config-discourse": "^3.4.0",
56
- "loader.js": "^4.7.0",
57
- "npm-run-all": "^4.1.5",
58
- "qunit": "^2.17.2",
59
- "qunit-dom": "^2.0.0",
60
- "sinon": "^15.0.1",
61
- "webpack": "^5.94.0"
62
- },
63
- "engines": {
64
- "node": "12.* || 14.* || >= 16"
65
- },
66
- "ember": {
67
- "edition": "octane"
68
- },
69
- "dependencies": {
70
- "moment": "~2.29.4"
71
- },
72
- "overrides": {
73
- "testem": "^3.9.0",
74
- "workerpool": "^6.3.1"
75
- }
76
- }
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This script takes care of updating the content of the preloaded json in tests/index.html
4
- # All you need to do is update the `tests_index_html` hash and run the script
5
-
6
- require "bundler/inline"
7
- require "json"
8
- require "cgi"
9
-
10
- gemfile do
11
- source "https://rubygems.org"
12
- gem "nokogiri"
13
- end
14
-
15
- tests_index_html = {
16
- env_expandable_keys: [],
17
- gems_dir: "/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/",
18
- backtrace_links_enabled: true,
19
- gems_data: [
20
- { name: "activerecord", url: "https://github.com/rails/rails/tree/v6.0.1/activerecord" },
21
- ],
22
- directories: [
23
- { path: "/var/www/discourse", url: "https://github.com/discourse/discourse", main_app: true },
24
- {
25
- path: "/var/www/discourse/plugins/discourse-prometheus",
26
- url: "https://github.com/discourse/discourse-prometheus",
27
- },
28
- ],
29
- application_version: "ce512452b512b909c38e9c63f2a0e1f8c17a2399",
30
- }
31
-
32
- content = File.read("tests/index.html")
33
- json = CGI.escapeHTML(JSON.generate(tests_index_html))
34
- content.sub!(/data-preloaded=".*">$/, "data-preloaded=\"#{json}\">")
35
- File.write("tests/index.html", content)
data/client-app/testem.js DELETED
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- test_page: "tests/index.html?hidepassed",
5
- disable_watching: true,
6
- launch_in_ci: ["Chrome"],
7
- launch_in_dev: ["Chrome"],
8
- browser_start_timeout: 120,
9
- browser_args: {
10
- Chrome: {
11
- ci: [
12
- // --no-sandbox is needed when running Chrome inside a container
13
- process.env.CI ? "--no-sandbox" : null,
14
- "--headless",
15
- "--disable-dev-shm-usage",
16
- "--disable-software-rasterizer",
17
- "--mute-audio",
18
- "--remote-debugging-port=0",
19
- "--window-size=1440,900",
20
- ].filter(Boolean),
21
- },
22
- },
23
- };
@@ -1,41 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
- <title>ClientApp Tests</title>
7
- <meta name="description" content="">
8
- <meta name="viewport" content="width=device-width, initial-scale=1">
9
- <meta id="preloaded-data" data-root-path="/logs" data-preloaded="{&quot;env_expandable_keys&quot;:[],&quot;gems_dir&quot;:&quot;/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/&quot;,&quot;backtrace_links_enabled&quot;:true,&quot;gems_data&quot;:[{&quot;name&quot;:&quot;activerecord&quot;,&quot;url&quot;:&quot;https://github.com/rails/rails/tree/v6.0.1/activerecord&quot;}],&quot;directories&quot;:[{&quot;path&quot;:&quot;/var/www/discourse&quot;,&quot;url&quot;:&quot;https://github.com/discourse/discourse&quot;,&quot;main_app&quot;:true},{&quot;path&quot;:&quot;/var/www/discourse/plugins/discourse-prometheus&quot;,&quot;url&quot;:&quot;https://github.com/discourse/discourse-prometheus&quot;}],&quot;application_version&quot;:&quot;ce512452b512b909c38e9c63f2a0e1f8c17a2399&quot;}">
10
-
11
- {{content-for "head"}}
12
- {{content-for "test-head"}}
13
-
14
- <link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
15
- <link rel="stylesheet" href="{{rootURL}}assets/client-app.css">
16
- <link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
17
-
18
- {{content-for "head-footer"}}
19
- {{content-for "test-head-footer"}}
20
- </head>
21
- <body>
22
- {{content-for "body"}}
23
- {{content-for "test-body"}}
24
-
25
- <div id="qunit"></div>
26
- <div id="qunit-fixture">
27
- <div id="ember-testing-container">
28
- <div id="ember-testing"></div>
29
- </div>
30
- </div>
31
-
32
- <script src="/testem.js" integrity="" data-embroider-ignore></script>
33
- <script src="{{rootURL}}assets/vendor.js"></script>
34
- <script src="{{rootURL}}assets/test-support.js"></script>
35
- <script src="{{rootURL}}assets/client-app.js"></script>
36
- <script src="{{rootURL}}assets/tests.js"></script>
37
-
38
- {{content-for "body-footer"}}
39
- {{content-for "test-body-footer"}}
40
- </body>
41
- </html>
@@ -1,20 +0,0 @@
1
- import { module, test } from "qunit";
2
- import { setupRenderingTest } from "ember-qunit";
3
- import { render } from "@ember/test-helpers";
4
- import hbs from "htmlbars-inline-precompile";
5
-
6
- module("Integration | Component | back-to-site-link", function (hooks) {
7
- setupRenderingTest(hooks);
8
-
9
- test("With path and text paremeter", async function (assert) {
10
- await render(hbs`<BackToSiteLink @path="/admin" @text="back to site"/>`);
11
- assert.dom("#back-to-site-panel a").exists("It shows back to site link");
12
- });
13
-
14
- test("Without required paremeters", async function (assert) {
15
- await render(hbs`<BackToSiteLink />`);
16
- assert
17
- .dom("#back-to-site-panel a")
18
- .doesNotExist("It does not show back link to site");
19
- });
20
- });
@@ -1,138 +0,0 @@
1
- import { module, test } from "qunit";
2
- import { setupRenderingTest } from "ember-qunit";
3
- import { find, findAll, render } from "@ember/test-helpers";
4
- import hbs from "htmlbars-inline-precompile";
5
- import { mutatePreload, uninitialize } from "client-app/lib/preload";
6
-
7
- module("Integration | Component | back-trace", function (hooks) {
8
- setupRenderingTest(hooks);
9
-
10
- hooks.beforeEach(function () {
11
- uninitialize();
12
- });
13
-
14
- hooks.afterEach(function () {
15
- uninitialize();
16
- });
17
-
18
- test("backtrace lines display and work correctly", async function (assert) {
19
- const backtrace = `/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/finder_methods.rb:317:in \`exists?'
20
- /var/www/discourse/lib/permalink_constraint.rb:6:in \`matches?'
21
- /var/www/discourse/plugins/discourse-prometheus/lib/middleware/metrics.rb:17:in \`call'
22
- activerecord-6.0.1/lib/active_record/relation/finder_methods.rb:317:in \`exists?'`;
23
- this.set("backtrace", backtrace);
24
- await render(hbs`<BackTrace @backtrace={{this.backtrace}} />`);
25
-
26
- const [gem, app, plugin, gem2] = findAll("a");
27
- assert.strictEqual(
28
- gem.href,
29
- "https://github.com/rails/rails/tree/v6.0.1/activerecord/lib/active_record/relation/finder_methods.rb#L317"
30
- );
31
-
32
- assert.strictEqual(
33
- app.href,
34
- "https://github.com/discourse/discourse/blob/ce512452b512b909c38e9c63f2a0e1f8c17a2399/lib/permalink_constraint.rb#L6"
35
- );
36
-
37
- assert.strictEqual(
38
- plugin.href,
39
- "https://github.com/discourse/discourse-prometheus/blob/master/lib/middleware/metrics.rb#L17"
40
- );
41
-
42
- assert.strictEqual(
43
- gem2.href,
44
- "https://github.com/rails/rails/tree/v6.0.1/activerecord/lib/active_record/relation/finder_methods.rb#L317"
45
- );
46
-
47
- let gemLine = find("div.backtrace-line");
48
- assert.strictEqual(
49
- gemLine.textContent.trim(),
50
- "activerecord-6.0.1/lib/active_record/relation/finder_methods.rb:317:in `exists?'",
51
- "gem lines are truncated"
52
- );
53
- });
54
-
55
- test("non-ruby backtraces don't break things", async function (assert) {
56
- this.set(
57
- "backtrace",
58
- `m/<@https://discourse-cdn.com/assets/application-f59d2.br.js:1:27448
59
- m@https://discourse-cdn.com/assets/application-f59d2.br.js:1:27560
60
- string@https://discourse-cdn.com/assets/application-f59d2.br.js:1:27869`
61
- );
62
- await render(hbs`<BackTrace @backtrace={{this.backtrace}} />`);
63
- const lines = this.backtrace.split("\n");
64
- findAll("div.backtrace-line").forEach((node, index) => {
65
- assert.strictEqual(node.textContent.trim(), lines[index]);
66
- });
67
- });
68
-
69
- test("non-gem backtraces don't break things", async function (assert) {
70
- this.set(
71
- "backtrace",
72
- `/ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/behaviors.rb:33:in \`block in <class:Deprecation>'
73
- /ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:26:in \`block (2 levels) in warn'
74
- /ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:26:in \`each'
75
- /ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:26:in \`block in warn'
76
- <internal:kernel>:90:in \`tap'
77
- /ruby/gems/activesupport-7.0.4.1/lib/active_support/deprecation/reporting.rb:22:in \`warn'`
78
- );
79
- await render(hbs`<BackTrace @backtrace={{this.backtrace}} />`);
80
- const lines = this.backtrace.split("\n");
81
- findAll("div.backtrace-line").forEach((node, index) => {
82
- assert.strictEqual(node.textContent.trim(), lines[index]);
83
- });
84
- });
85
-
86
- test("Github links use commit sha", async function (assert) {
87
- const backtrace = `/var/www/discourse/lib/permalink_constraint.rb:6:in \`matches?'`;
88
- let env = [
89
- { application_version: "123abc" },
90
- { application_version: "abc123" },
91
- ];
92
- this.setProperties({
93
- backtrace,
94
- env,
95
- });
96
- await render(
97
- hbs`<BackTrace @backtrace={{this.backtrace}} @env={{this.env}} />`
98
- );
99
- let href = find("a").href;
100
- assert.strictEqual(
101
- href,
102
- "https://github.com/discourse/discourse/blob/123abc/lib/permalink_constraint.rb#L6",
103
- "uses the first application_version if there are multiple versions"
104
- );
105
-
106
- env = { application_version: "567def" };
107
- this.set("env", env);
108
- await render(
109
- hbs`<BackTrace @backtrace={{this.backtrace}} @env={{this.env}} />`
110
- );
111
- href = find("a").href;
112
- assert.strictEqual(
113
- href,
114
- "https://github.com/discourse/discourse/blob/567def/lib/permalink_constraint.rb#L6",
115
- "uses application_version when env is only a hash"
116
- );
117
-
118
- this.set("env", null);
119
- await render(
120
- hbs`<BackTrace @backtrace={{this.backtrace}} @env={{this.env}} />`
121
- );
122
- href = find("a").href;
123
- assert.strictEqual(
124
- href,
125
- "https://github.com/discourse/discourse/blob/ce512452b512b909c38e9c63f2a0e1f8c17a2399/lib/permalink_constraint.rb#L6",
126
- "falls back to preload if env doesn't contain application_version"
127
- );
128
-
129
- mutatePreload("application_version", null);
130
- await render(hbs`<BackTrace @backtrace={{this.backtrace}} />`);
131
- href = find("a").href;
132
- assert.strictEqual(
133
- href,
134
- "https://github.com/discourse/discourse/blob/master/lib/permalink_constraint.rb#L6",
135
- "falls back to master branch when neither preload nor application_version in env are available"
136
- );
137
- });
138
- });
@@ -1,220 +0,0 @@
1
- import { module, test } from "qunit";
2
- import { setupRenderingTest } from "ember-qunit";
3
- import { click, find, findAll, render } from "@ember/test-helpers";
4
- import hbs from "htmlbars-inline-precompile";
5
- import Message from "client-app/models/message";
6
- import { init } from "client-app/lib/preload";
7
-
8
- const time1 = new Date("2010-01-01T01:00:00").getTime();
9
- const time2 = new Date("2015-01-01T01:00:00").getTime();
10
-
11
- const message = Message.create({
12
- env: [
13
- { a: "aa", b: "bb", time: time1 },
14
- { c: "cc", d: "dd", time: time2 },
15
- ],
16
- });
17
-
18
- const message2 = Message.create({
19
- env: { e: "ee", f: "ff" },
20
- });
21
-
22
- const message3 = Message.create({
23
- env: [
24
- { env_key_2: "value1", default_expanded: "vvv1", notExpanded: "dsdcz" },
25
- { env_key_2: "value2", default_expanded: "vvv2", notExpanded: "uerue" },
26
- { env_key_2: "value3", notExpanded: "weeww" },
27
- { env_key_2: "value4", notExpanded: "cxc" },
28
- ],
29
- });
30
-
31
- const message4 = Message.create({
32
- env: { env_key_2: "value", default_expanded: "vvv", notExpanded: "wwww" },
33
- });
34
-
35
- function reduceToContent(node) {
36
- return Array.from(node.childNodes).reduce(
37
- (ac, cr) => `${ac.textContent}: ${cr.textContent}`
38
- );
39
- }
40
-
41
- module("Integration | Component | env-tab", function (hooks) {
42
- setupRenderingTest(hooks);
43
-
44
- test("it renders", async function (assert) {
45
- const callback = (newPosition) => this.set("envPosition", newPosition);
46
- this.setProperties({
47
- message,
48
- callback,
49
- envPosition: 0,
50
- });
51
- await render(
52
- hbs`<EnvTab @message={{this.message}} @envChangedAction={{this.callback}} @currentEnvPosition={{this.envPosition}} />`
53
- );
54
-
55
- assert.strictEqual(
56
- find(".current-number").textContent,
57
- "1/2",
58
- "shows the current over the total number of env objects"
59
- );
60
- let trs = findAll("tr");
61
- assert.strictEqual(trs.length, 3);
62
- assert.strictEqual(
63
- reduceToContent(trs[0]),
64
- "a: aa",
65
- "has the right content"
66
- );
67
- assert.strictEqual(
68
- reduceToContent(trs[1]),
69
- "b: bb",
70
- "has the right content"
71
- );
72
- assert.strictEqual(
73
- reduceToContent(trs[2]),
74
- "time: 1 Jan 10",
75
- "has the right content"
76
- );
77
-
78
- const buttons = findAll("button.nav-btn");
79
- // at first page, you can't go back
80
- assert.ok(buttons[0].disabled, "back buttons are disabled");
81
- assert.ok(buttons[1].disabled, "back buttons are disabled");
82
-
83
- assert.notOk(buttons[2].disabled, "forward buttons are not disabled");
84
- assert.notOk(buttons[3].disabled, "forward buttons are not disabled");
85
-
86
- this.set("message", message2);
87
- assert.dom("button").doesNotExist("doesn't show buttons for non-array env");
88
-
89
- trs = findAll("tr");
90
- assert.strictEqual(trs.length, 2);
91
- assert.strictEqual(
92
- reduceToContent(trs[0]),
93
- "e: ee",
94
- "has the right content"
95
- );
96
- assert.strictEqual(
97
- reduceToContent(trs[1]),
98
- "f: ff",
99
- "has the right content"
100
- );
101
- });
102
-
103
- test("it works correctly", async function (assert) {
104
- const callback = (newPosition) => this.set("envPosition", newPosition);
105
- this.setProperties({
106
- message,
107
- callback,
108
- envPosition: 0,
109
- });
110
- await render(
111
- hbs`<EnvTab @message={{this.message}} @envChangedAction={{this.callback}} @currentEnvPosition={{this.envPosition}} />`
112
- );
113
-
114
- const buttons = findAll("button.nav-btn");
115
- await click(buttons[2]);
116
-
117
- assert.strictEqual(
118
- find(".current-number").textContent,
119
- "2/2",
120
- "shows the current over the total number of env objects"
121
- );
122
-
123
- const trs = findAll("tr");
124
- assert.strictEqual(trs.length, 3);
125
- assert.strictEqual(
126
- reduceToContent(trs[0]),
127
- "c: cc",
128
- "has the right content"
129
- );
130
- assert.strictEqual(
131
- reduceToContent(trs[1]),
132
- "d: dd",
133
- "has the right content"
134
- );
135
- assert.strictEqual(
136
- reduceToContent(trs[2]),
137
- "time: 1 Jan 15",
138
- "has the right content"
139
- );
140
-
141
- // at last page, you can't go forward but you can go back
142
- assert.notOk(buttons[0].disabled, "back buttons are not disabled");
143
- assert.notOk(buttons[1].disabled, "back buttons are not disabled");
144
-
145
- assert.ok(buttons[2].disabled, "forward buttons are disabled");
146
- assert.ok(buttons[3].disabled, "forward buttons are disabled");
147
- });
148
-
149
- test("expandable env keys", async function (assert) {
150
- document.getElementById("preloaded-data").dataset.preloaded =
151
- JSON.stringify({
152
- env_expandable_keys: ["env_key_2", "default_expanded"],
153
- });
154
- init();
155
- const callback = (newPosition) => this.set("envPosition", newPosition);
156
- this.setProperties({
157
- message: message3,
158
- callback,
159
- envPosition: 0,
160
- });
161
- await render(
162
- hbs`<EnvTab @message={{this.message}} @envChangedAction={{this.callback}} @currentEnvPosition={{this.envPosition}} />`
163
- );
164
-
165
- const trs = findAll(".env-table tr");
166
- const expandable = trs[0];
167
- const defaultExpanded = trs[1];
168
-
169
- assert.strictEqual(
170
- expandable.children[1].textContent.trim(),
171
- "value1, 3 more",
172
- "expandable env keys shown correctly"
173
- );
174
-
175
- assert.strictEqual(
176
- defaultExpanded.children[1].textContent.trim(),
177
- "vvv1, [vvv2]",
178
- "list is expanded by default when its length is 3 or less"
179
- );
180
-
181
- assert.strictEqual(
182
- findAll("a.expand-list").length,
183
- 1,
184
- "only whitelisted env keys are expandable"
185
- );
186
-
187
- const expandBtn = find("a.expand-list");
188
- assert.strictEqual(expandBtn.textContent.trim(), "3 more");
189
- await click(expandBtn);
190
-
191
- const expanded = find(".env-table tr");
192
- assert.strictEqual(
193
- expanded.children[1].textContent.trim(),
194
- "value1, [value2, value3, value4]",
195
- "expanded env keys shown correctly"
196
- );
197
-
198
- this.setProperties({
199
- message: message4,
200
- callback,
201
- envPosition: 0,
202
- });
203
- await render(
204
- hbs`<EnvTab @message={{this.message}} @envChangedAction={{this.callback}} @currentEnvPosition={{this.envPosition}} />`
205
- );
206
- const recreatedEnv = {};
207
- findAll(".env-table tr").forEach((node) => {
208
- recreatedEnv[node.children[0].innerText.trim()] =
209
- node.children[1].innerText.trim();
210
- });
211
-
212
- for (const [k, v] of Object.entries(recreatedEnv)) {
213
- assert.strictEqual(
214
- v,
215
- this.message.env[k],
216
- `${k}: ${v} === ${this.message.env[k]}`
217
- );
218
- }
219
- });
220
- });