From 06cf4c7d0c947d02120f824d558f16174aa75992 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Fri, 27 Sep 2024 10:19:07 -0400 Subject: [PATCH 1/2] Remove ember-fetch dep --- ui/app/services/token.js | 1 - ui/app/utils/properties/watch.js | 1 - ui/package.json | 1 - .../components/streaming-file-test.js | 1 - ui/tests/unit/adapters/job-test.js | 1 - ui/tests/unit/adapters/volume-test.js | 1 - .../services/stats-trackers-registry-test.js | 1 - .../utils/allocation-stats-tracker-test.js | 1 - .../unit/utils/node-stats-tracker-test.js | 1 - ui/yarn.lock | 184 ++---------------- 10 files changed, 11 insertions(+), 182 deletions(-) diff --git a/ui/app/services/token.js b/ui/app/services/token.js index 102fcf61bcb..df9ae0ca6ab 100644 --- a/ui/app/services/token.js +++ b/ui/app/services/token.js @@ -10,7 +10,6 @@ import { getOwner } from '@ember/application'; import { assign } from '@ember/polyfills'; import { task, timeout } from 'ember-concurrency'; import queryString from 'query-string'; -import fetch from 'nomad-ui/utils/fetch'; import classic from 'ember-classic-decorator'; import moment from 'moment'; diff --git a/ui/app/utils/properties/watch.js b/ui/app/utils/properties/watch.js index 3935f83f5bf..a3222c02a0c 100644 --- a/ui/app/utils/properties/watch.js +++ b/ui/app/utils/properties/watch.js @@ -10,7 +10,6 @@ import { get } from '@ember/object'; import { assert } from '@ember/debug'; import RSVP from 'rsvp'; import { task } from 'ember-concurrency'; -import { AbortController } from 'fetch'; import wait from 'nomad-ui/utils/wait'; import Watchable from 'nomad-ui/adapters/watchable'; import config from 'nomad-ui/config/environment'; diff --git a/ui/package.json b/ui/package.json index 38ab49aff28..7d6fd7ca0e0 100644 --- a/ui/package.json +++ b/ui/package.json @@ -93,7 +93,6 @@ "ember-decorators": "^6.1.1", "ember-exam": "6.1.0", "ember-export-application-global": "^2.0.1", - "ember-fetch": "^8.1.1", "ember-inflector": "^4.0.2", "ember-inline-svg": "^1.0.1", "ember-load-initializers": "^2.1.2", diff --git a/ui/tests/integration/components/streaming-file-test.js b/ui/tests/integration/components/streaming-file-test.js index d48f5006853..9afd5f00be6 100644 --- a/ui/tests/integration/components/streaming-file-test.js +++ b/ui/tests/integration/components/streaming-file-test.js @@ -11,7 +11,6 @@ import hbs from 'htmlbars-inline-precompile'; import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit'; import Pretender from 'pretender'; import { logEncode } from '../../../mirage/data/logs'; -import fetch from 'nomad-ui/utils/fetch'; import Log from 'nomad-ui/utils/classes/log'; const { assign } = Object; diff --git a/ui/tests/unit/adapters/job-test.js b/ui/tests/unit/adapters/job-test.js index c7d57b51f31..e308770a454 100644 --- a/ui/tests/unit/adapters/job-test.js +++ b/ui/tests/unit/adapters/job-test.js @@ -9,7 +9,6 @@ import { settled } from '@ember/test-helpers'; import { setupTest } from 'ember-qunit'; import { module, test } from 'qunit'; import { startMirage } from 'nomad-ui/initializers/ember-cli-mirage'; -import { AbortController } from 'fetch'; import { TextEncoderLite } from 'text-encoder-lite'; import base64js from 'base64-js'; import addToPath from 'nomad-ui/utils/add-to-path'; diff --git a/ui/tests/unit/adapters/volume-test.js b/ui/tests/unit/adapters/volume-test.js index eaf2d32bb41..3edc3f9a439 100644 --- a/ui/tests/unit/adapters/volume-test.js +++ b/ui/tests/unit/adapters/volume-test.js @@ -8,7 +8,6 @@ import { settled } from '@ember/test-helpers'; import { setupTest } from 'ember-qunit'; import { module, test } from 'qunit'; import { startMirage } from 'nomad-ui/initializers/ember-cli-mirage'; -import { AbortController } from 'fetch'; module('Unit | Adapter | Volume', function (hooks) { setupTest(hooks); diff --git a/ui/tests/unit/services/stats-trackers-registry-test.js b/ui/tests/unit/services/stats-trackers-registry-test.js index 29124547428..7be9fffa9db 100644 --- a/ui/tests/unit/services/stats-trackers-registry-test.js +++ b/ui/tests/unit/services/stats-trackers-registry-test.js @@ -10,7 +10,6 @@ import { setupTest } from 'ember-qunit'; import { settled } from '@ember/test-helpers'; import Pretender from 'pretender'; import sinon from 'sinon'; -import fetch from 'nomad-ui/utils/fetch'; import NodeStatsTracker from 'nomad-ui/utils/classes/node-stats-tracker'; module('Unit | Service | Stats Trackers Registry', function (hooks) { diff --git a/ui/tests/unit/utils/allocation-stats-tracker-test.js b/ui/tests/unit/utils/allocation-stats-tracker-test.js index 7b4250edddb..e2054764593 100644 --- a/ui/tests/unit/utils/allocation-stats-tracker-test.js +++ b/ui/tests/unit/utils/allocation-stats-tracker-test.js @@ -11,7 +11,6 @@ import Pretender from 'pretender'; import AllocationStatsTracker, { stats, } from 'nomad-ui/utils/classes/allocation-stats-tracker'; -import fetch from 'nomad-ui/utils/fetch'; import statsTrackerFrameMissingBehavior from './behaviors/stats-tracker-frame-missing'; import { settled } from '@ember/test-helpers'; diff --git a/ui/tests/unit/utils/node-stats-tracker-test.js b/ui/tests/unit/utils/node-stats-tracker-test.js index a3575f95bad..a5934442c7b 100644 --- a/ui/tests/unit/utils/node-stats-tracker-test.js +++ b/ui/tests/unit/utils/node-stats-tracker-test.js @@ -11,7 +11,6 @@ import Pretender from 'pretender'; import NodeStatsTracker, { stats, } from 'nomad-ui/utils/classes/node-stats-tracker'; -import fetch from 'nomad-ui/utils/fetch'; import statsTrackerFrameMissingBehavior from './behaviors/stats-tracker-frame-missing'; import { settled } from '@ember/test-helpers'; diff --git a/ui/yarn.lock b/ui/yarn.lock index a8378d9d69c..6d8846cf9d3 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -2908,13 +2908,6 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== -"@types/acorn@^4.0.3": - version "4.0.6" - resolved "https://registry.yarnpkg.com/@types/acorn/-/acorn-4.0.6.tgz#d61ca5480300ac41a7d973dd5b84d0a591154a22" - integrity sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ== - dependencies: - "@types/estree" "*" - "@types/body-parser@*": version "1.19.5" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" @@ -3084,11 +3077,6 @@ dependencies: undici-types "~5.26.4" -"@types/node@^9.6.0": - version "9.6.61" - resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.61.tgz#29f124eddd41c4c74281bd0b455d689109fc2a2d" - integrity sha512-/aKAdg5c8n468cYLy2eQrcR5k6chlbNwZNGUj3TboyPa2hcO2QAJcfymlqPzMiRj8B6nYKXjzQz36minFE0RwQ== - "@types/parse-json@^4.0.0": version "4.0.2" resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239" @@ -3297,11 +3285,6 @@ abbrev@1: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== -abortcontroller-polyfill@^1.7.3: - version "1.7.5" - resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.5.tgz#6738495f4e901fbb57b6c0611d0c75f76c485bed" - integrity sha512-JMJ5soJWP18htbbxJjG7bG6yuI6pRhgJ0scHHTfkUjf6wjP912xZWvM+A4sJK3gqd9E8fcPbDnOefbA9Th/FIQ== - accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7, accepts@~1.3.8: version "1.3.8" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" @@ -3310,13 +3293,6 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" -acorn-dynamic-import@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz#901ceee4c7faaef7e07ad2a47e890675da50a278" - integrity sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg== - dependencies: - acorn "^5.0.0" - acorn-globals@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-6.0.0.tgz#46cdd39f0f8ff08a876619b55f5ac8a6dc770b45" @@ -3340,11 +3316,6 @@ acorn-walk@^7.1.1: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== -acorn@^5.0.0, acorn@^5.5.3: - version "5.7.4" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.4.tgz#3e8d8a9947d0599a1796d10225d7432f4a4acf5e" - integrity sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg== - acorn@^7.1.0, acorn@^7.1.1, acorn@^7.4.0: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" @@ -3416,7 +3387,7 @@ amd-name-resolver@1.2.0: dependencies: ensure-posix-path "^1.0.1" -amd-name-resolver@^1.2.0, amd-name-resolver@^1.3.1: +amd-name-resolver@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/amd-name-resolver/-/amd-name-resolver-1.3.1.tgz#ffe71c683c6e7191fc4ae1bb3aaed15abea135d9" integrity sha512-26qTEWqZQ+cxSYygZ4Cf8tsjDBLceJahhtewxtKZA3SRa4PluuqYCuheemDQD+7Mf5B7sr+zhTDWAHDh02a1Dw== @@ -5022,7 +4993,7 @@ broccoli-plugin@1.1.0: rimraf "^2.3.4" symlink-or-copy "^1.0.1" -broccoli-plugin@^1.0.0, broccoli-plugin@^1.1.0, broccoli-plugin@^1.2.0, broccoli-plugin@^1.2.1, broccoli-plugin@^1.3.0, broccoli-plugin@^1.3.1: +broccoli-plugin@^1.0.0, broccoli-plugin@^1.1.0, broccoli-plugin@^1.2.0, broccoli-plugin@^1.2.1, broccoli-plugin@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/broccoli-plugin/-/broccoli-plugin-1.3.1.tgz#a26315732fb99ed2d9fb58f12a1e14e986b4fabd" integrity sha512-DW8XASZkmorp+q7J4EeDEZz+LoyKLAd2XZULXyD9l4m9/hAKV3vjHmB1kiUshcWAYMgTP1m2i4NnqCE/23h6AQ== @@ -5068,23 +5039,6 @@ broccoli-plugin@^4.0.0, broccoli-plugin@^4.0.1, broccoli-plugin@^4.0.2, broccoli rimraf "^3.0.2" symlink-or-copy "^1.3.1" -broccoli-rollup@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/broccoli-rollup/-/broccoli-rollup-2.1.1.tgz#0b77dc4b7560a53e998ea85f3b56772612d4988d" - integrity sha512-aky/Ovg5DbsrsJEx2QCXxHLA6ZR+9u1TNVTf85soP4gL8CjGGKQ/JU8R3BZ2ntkWzo6/83RCKzX6O+nlNKR5MQ== - dependencies: - "@types/node" "^9.6.0" - amd-name-resolver "^1.2.0" - broccoli-plugin "^1.2.1" - fs-tree-diff "^0.5.2" - heimdalljs "^0.2.1" - heimdalljs-logger "^0.1.7" - magic-string "^0.24.0" - node-modules-path "^1.0.1" - rollup "^0.57.1" - symlink-or-copy "^1.1.8" - walk-sync "^0.3.1" - broccoli-rollup@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/broccoli-rollup/-/broccoli-rollup-4.1.1.tgz#7531a24d88ddab9f1bace1c6ee6e6ca74a38d36f" @@ -5184,17 +5138,6 @@ broccoli-stew@^3.0.0: symlink-or-copy "^1.2.0" walk-sync "^1.1.3" -broccoli-templater@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/broccoli-templater/-/broccoli-templater-2.0.2.tgz#285a892071c0b3ad5ebc275d9e8b3465e2d120d6" - integrity sha512-71KpNkc7WmbEokTQpGcbGzZjUIY1NSVa3GB++KFKAfx5SZPUozCOsBlSTwxcv8TLoCAqbBnsX5AQPgg6vJ2l9g== - dependencies: - broccoli-plugin "^1.3.1" - fs-tree-diff "^0.5.9" - lodash.template "^4.4.0" - rimraf "^2.6.2" - walk-sync "^0.3.3" - broccoli-terser-sourcemap@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/broccoli-terser-sourcemap/-/broccoli-terser-sourcemap-4.1.1.tgz#4c26696e07a822e1fc91fb48c5b6d6c70d5ca9b2" @@ -5254,7 +5197,7 @@ browserslist@^3.2.6: caniuse-lite "^1.0.30000844" electron-to-chromium "^1.3.47" -browserslist@^4.0.0, browserslist@^4.21.10, browserslist@^4.22.2, browserslist@^4.23.0: +browserslist@^4.21.10, browserslist@^4.22.2, browserslist@^4.23.0: version "4.23.0" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.0.tgz#8f3acc2bbe73af7213399430890f86c63a5674ab" integrity sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ== @@ -5376,17 +5319,7 @@ can-symlink@^1.0.0: dependencies: tmp "0.0.28" -caniuse-api@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0" - integrity sha512-bsTwuIg/BZZK/vreVTYYbSWoe2F+71P7K5QGEX+pT250DZbfU1MQ5prOKpPR+LL6uWKK3KMwMCAS74QB3Um1uw== - dependencies: - browserslist "^4.0.0" - caniuse-lite "^1.0.0" - lodash.memoize "^4.1.2" - lodash.uniq "^4.5.0" - -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30001587: +caniuse-lite@^1.0.30000844, caniuse-lite@^1.0.30001587: version "1.0.30001625" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001625.tgz#ead1b155ea691d6a87938754d3cb119c24465b03" integrity sha512-4KE9N2gcRH+HQhpeiRZXd+1niLB/XNLAhSy4z7fI8EzcbcPoAqjNInxVHTiTwWfTIV4w096XG8OtCOCQQKPv3w== @@ -6347,13 +6280,6 @@ date-fns@^2.28.0: dependencies: "@babel/runtime" "^7.21.0" -date-time@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/date-time/-/date-time-2.1.0.tgz#0286d1b4c769633b3ca13e1e62558d2dbdc2eba2" - integrity sha512-/9+C44X7lot0IeiyfgJmETtRMhBidBYM2QFFIkGa0U1k+hSyY87Nw7PY3eDqpvCBm7I3WCSfPeZskW/YYq6m4g== - dependencies: - time-zone "^1.0.0" - debug@2.6.9, debug@^2.1.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -6775,7 +6701,7 @@ ember-cli-babel@^6.6.0: ember-cli-version-checker "^2.1.2" semver "^5.5.0" -ember-cli-babel@^7.0.0, ember-cli-babel@^7.1.2, ember-cli-babel@^7.1.3, ember-cli-babel@^7.10.0, ember-cli-babel@^7.11.1, ember-cli-babel@^7.13.0, ember-cli-babel@^7.17.2, ember-cli-babel@^7.18.0, ember-cli-babel@^7.19.0, ember-cli-babel@^7.21.0, ember-cli-babel@^7.22.1, ember-cli-babel@^7.23.0, ember-cli-babel@^7.23.1, ember-cli-babel@^7.26.0, ember-cli-babel@^7.26.10, ember-cli-babel@^7.26.11, ember-cli-babel@^7.26.3, ember-cli-babel@^7.26.4, ember-cli-babel@^7.26.5, ember-cli-babel@^7.26.6, ember-cli-babel@^7.4.0, ember-cli-babel@^7.5.0, ember-cli-babel@^7.7.3: +ember-cli-babel@^7.0.0, ember-cli-babel@^7.1.2, ember-cli-babel@^7.1.3, ember-cli-babel@^7.10.0, ember-cli-babel@^7.11.1, ember-cli-babel@^7.13.0, ember-cli-babel@^7.17.2, ember-cli-babel@^7.18.0, ember-cli-babel@^7.19.0, ember-cli-babel@^7.21.0, ember-cli-babel@^7.22.1, ember-cli-babel@^7.23.0, ember-cli-babel@^7.26.0, ember-cli-babel@^7.26.10, ember-cli-babel@^7.26.11, ember-cli-babel@^7.26.3, ember-cli-babel@^7.26.4, ember-cli-babel@^7.26.5, ember-cli-babel@^7.26.6, ember-cli-babel@^7.4.0, ember-cli-babel@^7.5.0, ember-cli-babel@^7.7.3: version "7.26.11" resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-7.26.11.tgz#50da0fe4dcd99aada499843940fec75076249a9f" integrity sha512-JJYeYjiz/JTn34q7F5DSOjkkZqy8qwFOOxXfE6pe9yEJqWGu4qErKxlz8I22JoVEQ/aBUO+OcKTpmctvykM9YA== @@ -7482,26 +7408,6 @@ ember-export-application-global@^2.0.1: resolved "https://registry.yarnpkg.com/ember-export-application-global/-/ember-export-application-global-2.0.1.tgz#b120a70e322ab208defc9e2daebe8d0dfc2dcd46" integrity sha512-B7wiurPgsxsSGzJuPFkpBWnaeuCu2PGpG2BjyrfA1VcL7//o+5RSnZqiCEY326y7qmxb2GoCgo0ft03KBU0rRw== -ember-fetch@^8.1.1: - version "8.1.2" - resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-8.1.2.tgz#651839780519319309127054786bf35cd4b84543" - integrity sha512-TVx24/jrvDIuPL296DV0hBwp7BWLcSMf0I8464KGz01sPytAB+ZAePbc9ooBTJDkKZEGFgatJa4nj3yF1S9Bpw== - dependencies: - abortcontroller-polyfill "^1.7.3" - broccoli-concat "^4.2.5" - broccoli-debug "^0.6.5" - broccoli-merge-trees "^4.2.0" - broccoli-rollup "^2.1.1" - broccoli-stew "^3.0.0" - broccoli-templater "^2.0.1" - calculate-cache-key-for-tree "^2.0.0" - caniuse-api "^3.0.0" - ember-cli-babel "^7.23.1" - ember-cli-typescript "^4.1.0" - ember-cli-version-checker "^5.1.2" - node-fetch "^2.6.1" - whatwg-fetch "^3.6.2" - ember-focus-trap@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/ember-focus-trap/-/ember-focus-trap-1.1.0.tgz#e3c47c6e916e838af3884b43e2794e87088d2bac" @@ -9062,7 +8968,7 @@ fs-merger@^3.0.1, fs-merger@^3.2.1: fs-tree-diff "^2.0.1" walk-sync "^2.2.0" -fs-tree-diff@^0.5.2, fs-tree-diff@^0.5.3, fs-tree-diff@^0.5.4, fs-tree-diff@^0.5.6, fs-tree-diff@^0.5.9: +fs-tree-diff@^0.5.2, fs-tree-diff@^0.5.3, fs-tree-diff@^0.5.4, fs-tree-diff@^0.5.6: version "0.5.9" resolved "https://registry.yarnpkg.com/fs-tree-diff/-/fs-tree-diff-0.5.9.tgz#a4ec6182c2f5bd80b9b83c8e23e4522e6f5fd946" integrity sha512-872G8ax0kHh01m9n/2KDzgYwouKza0Ad9iFltBpNykvROvf2AGtoOzPJgGx125aolGPER3JuC7uZFrQ7bG1AZw== @@ -10083,13 +9989,6 @@ is-potential-custom-element-name@^1.0.1: resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" integrity sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ== -is-reference@^1.1.0: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - is-regex@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" @@ -10557,11 +10456,6 @@ loader.js@^4.7.0: resolved "https://registry.yarnpkg.com/loader.js/-/loader.js-4.7.0.tgz#a1a52902001c83631efde9688b8ab3799325ef1f" integrity sha512-9M2KvGT6duzGMgkOcTkWb+PR/Q2Oe54df/tLgHGVmFpAmtqJ553xJh6N63iFYI2yjo2PeJXbS5skHi/QpJq4vA== -locate-character@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/locate-character/-/locate-character-2.0.5.tgz#f2d2614d49820ecb3c92d80d193b8db755f74c0f" - integrity sha512-n2GmejDXtOPBAZdIiEFy5dJ5N38xBCXLNOtw2WpB9kGh6pnrEuKlwYI+Tkpofc4wDtVXHtoAOJaMRlYG/oYaxg== - locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -10750,11 +10644,6 @@ lodash.keys@^3.0.0: lodash.isarguments "^3.0.0" lodash.isarray "^3.0.0" -lodash.memoize@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" - integrity sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag== - lodash.merge@^4.6.0, lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" @@ -10770,7 +10659,7 @@ lodash.restparam@^3.0.0: resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" integrity sha512-L4/arjjuq4noiUJpt3yS6KIKDtJwNe2fIYgMqyYYKoeIfV1iEqvPwhCx23o+R9dzouGihDAPN1dTIRWa7zk8tw== -lodash.template@^4.4.0, lodash.template@^4.5.0: +lodash.template@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== @@ -10790,7 +10679,7 @@ lodash.truncate@^4.4.2: resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" integrity sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw== -lodash.uniq@^4.2.0, lodash.uniq@^4.5.0: +lodash.uniq@^4.2.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ== @@ -10868,13 +10757,6 @@ lru_map@^0.4.1: resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.4.1.tgz#f7b4046283c79fb7370c36f8fca6aee4324b0a98" integrity sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg== -magic-string@^0.24.0: - version "0.24.1" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.24.1.tgz#7e38e5f126cae9f15e71f0cf8e450818ca7d5a8f" - integrity sha512-YBfNxbJiixMzxW40XqJEIldzHyh5f7CZKalo1uZffevyrPEX8Qgo9s0dmcORLHdV47UyvJg8/zD+6hQG3qvJrA== - dependencies: - sourcemap-codec "^1.4.1" - magic-string@^0.25.7: version "0.25.9" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" @@ -11301,7 +11183,7 @@ no-case@^3.0.4: lower-case "^2.0.2" tslib "^2.0.3" -node-fetch@^2.6.0, node-fetch@^2.6.1: +node-fetch@^2.6.0: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== @@ -11749,11 +11631,6 @@ parse-json@^5.0.0, parse-json@^5.2.0: json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" -parse-ms@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-1.0.1.tgz#56346d4749d78f23430ca0c713850aef91aa361d" - integrity sha512-LpH1Cf5EYuVjkBvCDBYvkUPh+iv2bk3FHflxHkpCYT0/FZ1d3N3uJaLiHr4yGuMcFUhv6eAivitTvWZI4B/chg== - parse-passwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" @@ -12029,13 +11906,6 @@ prettier@^2.5.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== -pretty-ms@^3.1.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-3.2.0.tgz#87a8feaf27fc18414d75441467d411d6e6098a25" - integrity sha512-ZypexbfVUGTFxb0v+m1bUyy92DHe5SyYlnyY0msyms5zd3RwyvNgyxZZsXXgoyzlxjx5MiqtXUdhUfvQbe0A2Q== - dependencies: - parse-ms "^1.0.0" - printf@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/printf/-/printf-0.6.1.tgz#b9afa3d3b55b7f2e8b1715272479fc756ed88650" @@ -12449,11 +12319,6 @@ require-from-string@^2.0.2: resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== -require-relative@^0.8.7: - version "0.8.7" - resolved "https://registry.yarnpkg.com/require-relative/-/require-relative-0.8.7.tgz#7999539fc9e047a37928fa196f8e1563dabd36de" - integrity sha512-AKGr4qvHiryxRb19m3PsLRGuKVAbJLUD7E6eOaHkfKhwc+vSgVOCY5xNvm9EkolBKTOf0GrQAZKLimOCz81Khg== - requireindex@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef" @@ -12602,30 +12467,13 @@ robust-predicates@^3.0.2: resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.2.tgz#d5b28528c4824d20fc48df1928d41d9efa1ad771" integrity sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg== -rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.8.1: +rollup-pluginutils@^2.8.1: version "2.8.2" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== dependencies: estree-walker "^0.6.1" -rollup@^0.57.1: - version "0.57.1" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.57.1.tgz#0bb28be6151d253f67cf4a00fea48fb823c74027" - integrity sha512-I18GBqP0qJoJC1K1osYjreqA8VAKovxuI3I81RSk0Dmr4TgloI0tAULjZaox8OsJ+n7XRrhH6i0G2By/pj1LCA== - dependencies: - "@types/acorn" "^4.0.3" - acorn "^5.5.3" - acorn-dynamic-import "^3.0.0" - date-time "^2.1.0" - is-reference "^1.1.0" - locate-character "^2.0.5" - pretty-ms "^3.1.0" - require-relative "^0.8.7" - rollup-pluginutils "^2.0.1" - signal-exit "^3.0.2" - sourcemap-codec "^1.4.1" - rollup@^1.12.0: version "1.32.1" resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.32.1.tgz#4480e52d9d9e2ae4b46ba0d9ddeaf3163940f9c4" @@ -13159,7 +13007,7 @@ source-map@~0.1.x: dependencies: amdefine ">=0.0.4" -sourcemap-codec@^1.4.1, sourcemap-codec@^1.4.8: +sourcemap-codec@^1.4.8: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== @@ -13706,11 +13554,6 @@ through@^2.3.6, through@^2.3.8: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== -time-zone@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/time-zone/-/time-zone-1.0.0.tgz#99c5bf55958966af6d06d83bdf3800dc82faec5d" - integrity sha512-TIsDdtKo6+XrPtiTm1ssmMngN1sAhyKnTO2kunQWqNPWIVvCm15Wmw4SWInwTVgJ5u/Tr04+8Ei9TNcw4x4ONA== - tiny-emitter@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423" @@ -14380,11 +14223,6 @@ whatwg-encoding@^1.0.5: dependencies: iconv-lite "0.4.24" -whatwg-fetch@^3.6.2: - version "3.6.20" - resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70" - integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg== - whatwg-mimetype@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf" From 0f5594cebe815a5ef76486a12d7a827e0f006322 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Thu, 3 Oct 2024 16:36:38 -0400 Subject: [PATCH 2/2] Starting to handle test failures resulting from upgrades and ember-fetch removal --- ui/app/utils/fetch.js | 18 ----- ui/tests/acceptance/access-control-test.js | 10 +-- ui/tests/acceptance/actions-test.js | 12 +-- ui/tests/acceptance/allocation-detail-test.js | 72 +++++++++++++---- ui/tests/acceptance/behaviors/fs.js | 15 +++- ui/tests/acceptance/token-test.js | 77 +++++++++++-------- ui/tests/acceptance/topology-test.js | 9 ++- ui/tests/helpers/wait-for-token.js | 11 +++ ui/tests/pages/settings/tokens.js | 12 ++- 9 files changed, 159 insertions(+), 77 deletions(-) delete mode 100644 ui/app/utils/fetch.js create mode 100644 ui/tests/helpers/wait-for-token.js diff --git a/ui/app/utils/fetch.js b/ui/app/utils/fetch.js deleted file mode 100644 index bade0d8e0cf..00000000000 --- a/ui/app/utils/fetch.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) HashiCorp, Inc. - * SPDX-License-Identifier: BUSL-1.1 - */ - -import fetch from 'fetch'; -import config from '../config/environment'; - -// The ember-fetch polyfill does not provide streaming -// Additionally, Mirage/Pretender does not support fetch -const mirageEnabled = - config.environment !== 'production' && - config['ember-cli-mirage'] && - config['ember-cli-mirage'].enabled !== false; - -const fetchToUse = mirageEnabled ? fetch : window.fetch || fetch; - -export default fetchToUse; diff --git a/ui/tests/acceptance/access-control-test.js b/ui/tests/acceptance/access-control-test.js index 44399626b1a..c49473c0950 100644 --- a/ui/tests/acceptance/access-control-test.js +++ b/ui/tests/acceptance/access-control-test.js @@ -51,7 +51,7 @@ module('Acceptance | access control', function (hooks) { (t) => t.type === 'management' ); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); assert.dom('[data-test-gutter-link="administration"]').exists(); @@ -79,7 +79,7 @@ module('Acceptance | access control', function (hooks) { (t) => t.type === 'management' ); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Administration.visit(); assert.dom('[data-test-sentinel-policies-card]').doesNotExist(); }); @@ -92,7 +92,7 @@ module('Acceptance | access control', function (hooks) { (t) => t.type === 'management' ); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Administration.visit(); assert.dom('[data-test-sentinel-policies-card]').exists(); @@ -107,7 +107,7 @@ module('Acceptance | access control', function (hooks) { (t) => t.type === 'management' ); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Administration.visit(); assert.dom('[data-test-tokens-card]').exists(); @@ -140,7 +140,7 @@ module('Acceptance | access control', function (hooks) { (t) => t.type === 'management' ); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Administration.visit(); diff --git a/ui/tests/acceptance/actions-test.js b/ui/tests/acceptance/actions-test.js index 212ebb6bf84..e7517aa3292 100644 --- a/ui/tests/acceptance/actions-test.js +++ b/ui/tests/acceptance/actions-test.js @@ -105,7 +105,7 @@ module('Acceptance | actions', function (hooks) { assert.notOk(Actions.hasTitleActions, 'No actions dropdown by default'); await Tokens.visit(); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Actions.visitIndex({ id: 'actionable-job' }); assert.ok( Actions.hasTitleActions, @@ -118,7 +118,7 @@ module('Acceptance | actions', function (hooks) { // Sign out and sign back in as a token without alloc exec await Tokens.visit(); await Tokens.clear(); - await Tokens.secret(clientReaderToken.secretId).submit(); + await Tokens.secret(clientReaderToken.secretId).submit(this.owner); await Actions.visitIndex({ id: 'actionable-job' }); assert.notOk( Actions.hasTitleActions, @@ -132,7 +132,7 @@ module('Acceptance | actions', function (hooks) { // Sign out and sign back in as a token with alloc exec await Tokens.visit(); await Tokens.clear(); - await Tokens.secret(allocExecToken.secretId).submit(); + await Tokens.secret(allocExecToken.secretId).submit(this.owner); await Actions.visitIndex({ id: 'actionable-job' }); assert.ok( Actions.hasTitleActions, @@ -154,7 +154,7 @@ module('Acceptance | actions', function (hooks) { await Tokens.visit(); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Actions.visitIndex({ id: 'actionable-job' }); assert.ok( Actions.hasTitleActions, @@ -286,7 +286,7 @@ module('Acceptance | actions', function (hooks) { await Tokens.visit(); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Actions.visitAllocs({ id: 'actionable-job' }); // Get the number of rows; each of them should have an actions dropdown @@ -331,7 +331,7 @@ module('Acceptance | actions', function (hooks) { }); await Tokens.visit(); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Actions.visitIndex({ id: 'actionable-job' }); // Run an action to open the flyout; observe the dropdown there await Actions.titleActions.click(); diff --git a/ui/tests/acceptance/allocation-detail-test.js b/ui/tests/acceptance/allocation-detail-test.js index 5f69f44a3a0..fe805417de2 100644 --- a/ui/tests/acceptance/allocation-detail-test.js +++ b/ui/tests/acceptance/allocation-detail-test.js @@ -6,8 +6,13 @@ /* eslint-disable qunit/require-expect */ /* Mirage fixtures are random so we can't expect a set number of assertions */ import AdapterError from '@ember-data/adapter/error'; -import { run } from '@ember/runloop'; -import { currentURL, click, triggerEvent, waitFor } from '@ember/test-helpers'; +import { + currentURL, + click, + triggerEvent, + waitFor, + waitUntil, +} from '@ember/test-helpers'; import { assign } from '@ember/polyfills'; import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; @@ -17,7 +22,6 @@ import Allocation from 'nomad-ui/tests/pages/allocations/detail'; import moment from 'moment'; import formatHost from 'nomad-ui/utils/format-host'; import faker from 'nomad-ui/mirage/faker'; - let job; let node; let allocation; @@ -377,6 +381,12 @@ module('Acceptance | allocation detail', function (hooks) { await Allocation.restart.idle(); await Allocation.restart.confirm(); + await waitUntil(() => { + return server.pretender.handledRequests.find((request) => { + return request.method === 'PUT' && request.url.includes(allocation.id); + }); + }); + assert.equal( server.pretender.handledRequests.findBy('method', 'PUT').url, `/v1/client/allocation/${allocation.id}/restart`, @@ -397,26 +407,62 @@ module('Acceptance | allocation detail', function (hooks) { }); test('while an allocation is being restarted, the stop button is disabled', async function (assert) { - server.pretender.post('/v1/allocation/:id/stop', () => [204, {}, ''], true); + let resolveRestart; + const restartRequestPromise = new Promise((resolve) => { + resolveRestart = resolve; + }); + server.pretender.put('/v1/client/allocation/:id/restart', () => { + return restartRequestPromise.then(() => { + return [204, {}, '']; + }); + }); - await Allocation.stop.idle(); + await Allocation.restart.idle(); + await Allocation.restart.confirm(); - run.later(() => { - assert.ok(Allocation.stop.isDisabled, 'Stop is disabled'); - assert.ok(Allocation.restart.isDisabled, 'Restart is disabled'); - assert.ok(Allocation.restartAll.isDisabled, 'Restart All is disabled'); - server.pretender.resolve(server.pretender.requestReferences[0].request); - }, 500); + assert.ok(Allocation.stop.isDisabled, 'Stop is disabled'); + assert.ok(Allocation.restart.isDisabled, 'Restart is disabled'); + assert.ok(Allocation.restartAll.isDisabled, 'Restart All is disabled'); - await Allocation.stop.confirm(); + resolveRestart(); + await waitUntil(() => !Allocation.stop.isDisabled); + + assert.notOk( + Allocation.stop.isDisabled, + 'Stop is enabled after request completes' + ); + assert.notOk( + Allocation.restart.isDisabled, + 'Restart is enabled after request completes' + ); + assert.notOk( + Allocation.restartAll.isDisabled, + 'Restart All is enabled after request completes' + ); }); test('if stopping or restarting fails, an error message is shown', async function (assert) { - server.pretender.post('/v1/allocation/:id/stop', () => [403, {}, '']); + let resolveStop; + const stopRequestPromise = new Promise((resolve) => { + resolveStop = resolve; + }); + server.pretender.post('/v1/allocation/:id/stop', () => { + return stopRequestPromise.then(() => { + return [403, {}, '']; + }); + }); await Allocation.stop.idle(); await Allocation.stop.confirm(); + assert.notOk( + Allocation.inlineError.isShown, + 'No error is shown while request is pending' + ); + + resolveStop(); + await waitUntil(() => Allocation.inlineError.isShown); + assert.ok(Allocation.inlineError.isShown, 'Inline error is shown'); assert.ok( Allocation.inlineError.title.includes('Could Not Stop Allocation'), diff --git a/ui/tests/acceptance/behaviors/fs.js b/ui/tests/acceptance/behaviors/fs.js index f3c81a2a595..73d04f65cd1 100644 --- a/ui/tests/acceptance/behaviors/fs.js +++ b/ui/tests/acceptance/behaviors/fs.js @@ -5,7 +5,7 @@ /* eslint-disable qunit/require-expect */ import { test } from 'qunit'; -import { currentURL, visit } from '@ember/test-helpers'; +import { currentURL, visit, waitUntil } from '@ember/test-helpers'; import { filesForPath } from 'nomad-ui/mirage/config'; import { formatBytes } from 'nomad-ui/utils/units'; @@ -363,6 +363,19 @@ export default function browseFilesystem({ assert.ok(FS.fileViewer.isPresent); const requests = this.server.pretender.handledRequests; + await waitUntil(() => { + return ( + requests.some((req) => + req.url.includes(`${node.httpAddr}/v1/client/fs/readat`) + ) && + requests.some( + (req) => + req.url.includes('/v1/client/fs/readat') && + !req.url.includes(node.httpAddr) + ) + ); + }); + const secondAttempt = requests.pop(); const firstAttempt = requests.pop(); diff --git a/ui/tests/acceptance/token-test.js b/ui/tests/acceptance/token-test.js index c29dd44b200..b4c690f627d 100644 --- a/ui/tests/acceptance/token-test.js +++ b/ui/tests/acceptance/token-test.js @@ -11,6 +11,7 @@ import { visit, click, fillIn, + waitUntil, } from '@ember/test-helpers'; import { module, skip, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; @@ -37,6 +38,17 @@ let node; let managementToken; let clientToken; +async function saveAndWait(handledRequests, selector) { + if (!selector) { + selector = '[data-test-token-save]'; + } + console.log('selector', selector); + const initialRequestCount = handledRequests.length; + console.log('initialRequestCount', initialRequestCount); + await click(selector); + await waitUntil(() => handledRequests.length > initialRequestCount); +} + module('Acceptance | tokens', function (hooks) { setupApplicationTest(hooks); setupMirage(hooks); @@ -73,7 +85,7 @@ module('Acceptance | tokens', function (hooks) { ); assert.ok(document.title.includes('Sign In')); - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); assert.equal( window.localStorage.nomadTokenSecret, secretId, @@ -100,7 +112,7 @@ module('Acceptance | tokens', function (hooks) { const requestPosition = server.pretender.handledRequests.length; await Tokens.visit(); - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await JobDetail.visit({ id: job.id }); await ClientDetail.visit({ id: node.id }); @@ -128,7 +140,7 @@ module('Acceptance | tokens', function (hooks) { ); await Tokens.visit(); - await Tokens.secret(bogusSecret).submit(); + await Tokens.secret(bogusSecret).submit(this.owner); assert.equal( window.localStorage.nomadTokenSecret, @@ -144,7 +156,7 @@ module('Acceptance | tokens', function (hooks) { const { secretId } = managementToken; await Tokens.visit(); - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await percySnapshot(assert); @@ -160,7 +172,7 @@ module('Acceptance | tokens', function (hooks) { policy.update('description', 'Make sure there is a description'); await Tokens.visit(); - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); assert.ok(Tokens.successMessage, 'Token success message is shown'); assert.notOk(Tokens.errorMessage, 'Token error message is not shown'); @@ -192,7 +204,7 @@ module('Acceptance | tokens', function (hooks) { assert.ok(find('.job-row'), 'Jobs found'); await Tokens.visit(); - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); server.pretender.get('/v1/jobs/statuses', function () { return [200, {}, '[]']; @@ -213,7 +225,7 @@ module('Acceptance | tokens', function (hooks) { await Tokens.visit(); // Token with no TTL - await Tokens.secret(clientToken.secretId).submit(); + await Tokens.secret(clientToken.secretId).submit(this.owner); assert .dom('[data-test-token-expiry]') .doesNotExist('No expiry shown for regular token'); @@ -224,7 +236,7 @@ module('Acceptance | tokens', function (hooks) { setTimeout(() => run.cancelTimers(), 500); // Token with TTL - await Tokens.secret(expiringToken.secretId).submit(); + await Tokens.secret(expiringToken.secretId).submit(this.owner); assert .dom('[data-test-token-expiry]') .exists('Expiry shown for TTL-having token'); @@ -347,7 +359,7 @@ module('Acceptance | tokens', function (hooks) { run.cancelTimers(); }, 5000); }, 500); - await Tokens.secret(nearlyExpiringToken.secretId).submit(); + await Tokens.secret(nearlyExpiringToken.secretId).submit(this.owner); }); test('when the ott query parameter is present upon application load it’s exchanged for a token', async function (assert) { @@ -466,7 +478,7 @@ module('Acceptance | tokens', function (hooks) { // Expect to be signed in as a manager await Tokens.secret( 'aaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.management' - ).submit(); + ).submit(this.owner); assert.ok(currentURL().startsWith('/settings/tokens')); assert.dom('[data-test-token-name]').includesText('Token: Manager'); await Tokens.clear(); @@ -474,7 +486,7 @@ module('Acceptance | tokens', function (hooks) { // Expect to be signed in as a client await Tokens.secret( 'aaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.whateverlol' - ).submit(); + ).submit(this.owner); assert.ok(currentURL().startsWith('/settings/tokens')); assert.dom('[data-test-token-name]').includesText( `Token: ${ @@ -488,7 +500,7 @@ module('Acceptance | tokens', function (hooks) { // Expect to an error on bad JWT await Tokens.secret( 'aaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.bad' - ).submit(); + ).submit(this.owner); assert.ok(currentURL().startsWith('/settings/tokens')); assert.dom('[data-test-token-error]').exists(); }); @@ -786,7 +798,7 @@ module('Acceptance | tokens', function (hooks) { token = server.db.tokens.findBy( (t) => t.name === 'High Level Role Token' ); - await Tokens.secret(token.secretId).submit(); + await Tokens.secret(token.secretId).submit(this.owner); assert.dom('[data-test-token-role]').exists({ count: 1 }); assert.dom('[data-test-role-name]').hasText('high-level'); @@ -802,7 +814,7 @@ module('Acceptance | tokens', function (hooks) { token = server.db.tokens.findBy( (t) => t.name === 'Policy And Role Token' ); - await Tokens.secret(token.secretId).submit(); + await Tokens.secret(token.secretId).submit(this.owner); assert.dom('[data-test-token-role]').exists({ count: 1 }); assert.dom('[data-test-role-name]').hasText('reader'); @@ -825,7 +837,7 @@ module('Acceptance | tokens', function (hooks) { token = server.db.tokens.findBy( (t) => t.name === 'Multi Role And Policy Token' ); - await Tokens.secret(token.secretId).submit(); + await Tokens.secret(token.secretId).submit(this.owner); assert.equal(token.roleIds.length, 2); assert.equal(token.policyIds.length, 1); @@ -846,7 +858,7 @@ module('Acceptance | tokens', function (hooks) { let token = server.db.tokens.findBy( (t) => t.name === 'Clientless Role Token' ); - await Tokens.secret(token.secretId).submit(); + await Tokens.secret(token.secretId).submit(this.owner); await visit('/clients'); // Expect no rows, and a denied message @@ -863,7 +875,7 @@ module('Acceptance | tokens', function (hooks) { token = server.db.tokens.findBy( (t) => t.name === 'High Level Role Token' ); - await Tokens.secret(token.secretId).submit(); + await Tokens.secret(token.secretId).submit(this.owner); await visit('/jobs'); // Expect the Run button/link to work now @@ -884,7 +896,7 @@ module('Acceptance | tokens', function (hooks) { (t) => t.type === 'management' ); const { secretId } = managementToken; - await Tokens.secret(secretId).submit(); + await Tokens.secret(secretId).submit(this.owner); await Administration.visitTokens(); }); @@ -977,7 +989,8 @@ module('Acceptance | tokens', function (hooks) { const tokenRowToDelete = [...findAll('[data-test-token-row]')].find( (row) => row.textContent.includes(tokenToDelete.name) ); - await click( + await saveAndWait( + server.pretender.handledRequests, tokenRowToDelete.querySelector('[data-test-delete-token] button') ); assert.dom('.flash-message.alert-success').exists(); @@ -1139,7 +1152,7 @@ module('Acceptance | tokens', function (hooks) { await visit(`/administration/tokens/${token.id}`); assert.dom('[data-test-token-name-input]').hasValue(token.name); await fillIn('[data-test-token-name-input]', 'Mud-Token'); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); await Administration.visitTokens(); assert.dom('[data-test-token-name="Mud-Token"]').exists({ count: 1 }); @@ -1189,12 +1202,12 @@ module('Acceptance | tokens', function (hooks) { checkedRoles.forEach((role) => { role.click(); }); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-critical').exists(); // Try selecting a single role await click('[data-test-token-roles] tbody tr input'); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); await percySnapshot(assert); @@ -1228,7 +1241,10 @@ module('Acceptance | tokens', function (hooks) { assert .dom('[data-test-confirmation-message]') .exists('confirmation message is present'); - await click(find('[data-test-confirm-button]')); + await saveAndWait( + server.pretender.handledRequests, + '[data-test-confirm-button]' + ); assert.dom('.flash-message.alert-success').exists(); await Administration.visitTokens(); @@ -1238,7 +1254,7 @@ module('Acceptance | tokens', function (hooks) { await click('[data-test-create-token]'); assert.equal(currentURL(), '/administration/tokens/new'); await fillIn('[data-test-token-name-input]', 'Timeless Token'); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); await Administration.visitTokens(); assert @@ -1258,7 +1274,7 @@ module('Acceptance | tokens', function (hooks) { await fillIn('[data-test-token-name-input]', 'TTL Token'); // Select the "8 hours" radio within the .expiration-time div await click('.expiration-time input[value="8h"]'); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); await Administration.visitTokens(); assert.dom('[data-test-token-name="TTL Token"]').exists({ count: 1 }); @@ -1286,7 +1302,7 @@ module('Acceptance | tokens', function (hooks) { var tzoffset = new Date().getTimezoneOffset() * 60000; //offset in milliseconds var soonString = new Date(soon - tzoffset).toISOString().slice(0, -1); await fillIn('[data-test-token-expiration-time-input]', soonString); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); await Administration.visitTokens(); assert @@ -1308,7 +1324,7 @@ module('Acceptance | tokens', function (hooks) { assert.dom('[data-test-global-token-group]').doesNotExist(); await fillIn('[data-test-token-name-input]', 'Capt. Steven Hiller'); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); const token = server.db.tokens.findBy( (t) => t.name === 'Capt. Steven Hiller' @@ -1378,7 +1394,7 @@ module('Tokens and Regions', function (hooks) { assert.dom('[data-test-locality="global"]').isChecked(); await click('[data-test-token-type="management"]'); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); let globalToken = server.db.tokens.findBy( (t) => t.name === 'Thomas J. Whitmore' @@ -1418,7 +1434,7 @@ module('Tokens and Regions', function (hooks) { await fillIn('[data-test-token-name-input]', 'David Levinson'); await click('[data-test-token-type="management"]'); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); let token = server.db.tokens.findBy((t) => t.name === 'David Levinson'); @@ -1450,9 +1466,8 @@ module('Tokens and Regions', function (hooks) { await fillIn('[data-test-token-name-input]', 'Russell Casse'); await click('[data-test-token-type="management"]'); - // await this.pauseTest(); - await click('[data-test-token-save]'); + await saveAndWait(server.pretender.handledRequests); assert.dom('.flash-message.alert-success').exists(); let token = server.db.tokens.findBy((t) => t.name === 'Russell Casse'); assert.notOk(token.global, 'Token is not global'); diff --git a/ui/tests/acceptance/topology-test.js b/ui/tests/acceptance/topology-test.js index 253a76ff1b6..0286ffef587 100644 --- a/ui/tests/acceptance/topology-test.js +++ b/ui/tests/acceptance/topology-test.js @@ -5,7 +5,7 @@ /* eslint-disable qunit/require-expect */ import { get } from '@ember/object'; -import { currentURL, typeIn, click } from '@ember/test-helpers'; +import { currentURL, typeIn, click, waitUntil } from '@ember/test-helpers'; import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; @@ -175,6 +175,7 @@ module('Acceptance | topology', function (hooks) { await Topology.viz.datacenters[dcIndex].nodes[ nodeIndex ].memoryRects[0].select(); + await waitUntil(() => Topology.infoPanelTitle === 'Allocation Details'); }; await reset(); @@ -233,13 +234,17 @@ module('Acceptance | topology', function (hooks) { jobId: job2.id, taskGroup2, }); - await Topology.visit(); await Topology.viz.datacenters[0].nodes[0].memoryRects[0].select(); const firstAllocationTaskNames = Topology.allocInfoPanel.charts[0].areas.mapBy('taskName'); await Topology.viz.datacenters[0].nodes[0].memoryRects[1].select(); + + await new Promise((resolve) => setTimeout(resolve, 100)); + // TODO: This is hackier than hacky but proves that awaiting methods dont seem to be waiting for things being settled. + // noting that await settled() here does nothing. + const secondAllocationTaskNames = Topology.allocInfoPanel.charts[0].areas.mapBy('taskName'); diff --git a/ui/tests/helpers/wait-for-token.js b/ui/tests/helpers/wait-for-token.js new file mode 100644 index 00000000000..cd0b9af84ed --- /dev/null +++ b/ui/tests/helpers/wait-for-token.js @@ -0,0 +1,11 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: BUSL-1.1 + */ + +import { waitUntil } from '@ember/test-helpers'; + +export default async function waitForToken(owner) { + const tokenService = owner.lookup('service:token'); + await waitUntil(() => tokenService.selfToken, { timeout: 2000 }); +} diff --git a/ui/tests/pages/settings/tokens.js b/ui/tests/pages/settings/tokens.js index 6164d16d9a3..d513d0cb734 100644 --- a/ui/tests/pages/settings/tokens.js +++ b/ui/tests/pages/settings/tokens.js @@ -12,12 +12,22 @@ import { isVisible, visitable, } from 'ember-cli-page-object'; +import waitForToken from 'nomad-ui/tests/helpers/wait-for-token'; export default create({ visit: visitable('/settings/tokens'), secret: fillable('[data-test-token-secret]'), - submit: clickable('[data-test-token-submit]'), + _submit: clickable('[data-test-token-submit]'), + async submit(owner) { + await this._submit(); + if (owner) { + await waitForToken(owner); + } else { + console.debug('No owner provided to wait for token'); + } + }, + clear: clickable('[data-test-token-clear]'), errorMessage: isVisible('[data-test-token-error]'),