mirror of
https://github.com/discourse/discourse.git
synced 2025-04-25 04:24:30 +08:00
DEV: Centralise user preferences security test into a single file (#19121)
* Makes it easier to find all the related tests for the particular route * Remove some tests that don't really provide much value against regressions
This commit is contained in:
parent
bb42016a72
commit
d3366a9092
@ -1,24 +1,33 @@
|
||||
{{#if @model.userApiKeys}}
|
||||
<div class="control-group apps">
|
||||
<label class="control-label">{{i18n "user.apps"}}</label>
|
||||
<div class="control-group pref-user-api-keys">
|
||||
<label class="control-label pref-user-api-keys__label">{{i18n "user.apps"}}</label>
|
||||
|
||||
<div class="controls">
|
||||
{{#each @model.userApiKeys as |key|}}
|
||||
<div>
|
||||
<span>{{key.application_name}}</span>
|
||||
<span class="pref-user-api-keys__application-name">{{key.application_name}}</span>
|
||||
|
||||
{{#if key.revoked}}
|
||||
<DButton @action={{route-action "undoRevokeApiKey"}} @actionParam={{key}} @class="btn" @label="user.undo_revoke_access" />
|
||||
{{else}}
|
||||
<DButton @action={{route-action "revokeApiKey"}} @actionParam={{key}} @class="btn" @label="user.revoke_access" />
|
||||
{{/if}}
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<ul class="pref-user-api-keys__scopes-list">
|
||||
{{#each key.scopes as |scope|}}
|
||||
<li>{{scope}}</li>
|
||||
<li class="pref-user-api-keys__scopes-list-item">{{scope}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</p>
|
||||
<p><span>{{i18n "user.api_approved"}}</span> {{bound-date key.created_at}}</p>
|
||||
<p><span>{{i18n "user.api_last_used_at"}}</span> {{bound-date key.last_used_at}}</p>
|
||||
|
||||
<p class="pref-user-api-keys__created-at">
|
||||
<span>{{i18n "user.api_approved"}}</span> {{bound-date key.created_at}}
|
||||
</p>
|
||||
|
||||
<p class="pref-user-api-keys__last-used-at">
|
||||
<span>{{i18n "user.api_last_used_at"}}</span> {{bound-date key.last_used_at}}
|
||||
</p>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
@ -1,41 +0,0 @@
|
||||
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance(
|
||||
"New User Menu - Horizontal nav and preferences relocation",
|
||||
function (needs) {
|
||||
needs.user({
|
||||
redesigned_user_page_nav_enabled: true,
|
||||
user_api_keys: [
|
||||
{
|
||||
id: 1,
|
||||
application_name: "Discourse Hub",
|
||||
scopes: ["Read and clear notifications"],
|
||||
created_at: "2020-11-14T00:57:09.093Z",
|
||||
last_used_at: "2022-09-22T18:55:41.672Z",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
test("Horizontal user nav exists", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences");
|
||||
assert.ok(exists(".horizontal-overflow-nav"), "horizontal nav exists");
|
||||
});
|
||||
|
||||
test("User Tracking page exists", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences");
|
||||
assert.ok(exists(".nav-tracking"), "the new tracking page link exists");
|
||||
});
|
||||
|
||||
test("User Categories page no longer exists", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences");
|
||||
assert.ok(!exists(".nav-categories"), "Categories tab no longer exists");
|
||||
});
|
||||
|
||||
test("Can view user api keys on security page", async function (assert) {
|
||||
await visit("/u/eviltrout/preferences/security");
|
||||
assert.ok(exists(".control-group.apps"), "User can see apps section");
|
||||
});
|
||||
}
|
||||
);
|
@ -4,7 +4,9 @@ import { click, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
exists,
|
||||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
|
||||
@ -61,4 +63,43 @@ acceptance("User Preferences - Security", function (needs) {
|
||||
"it should highlight password preferences"
|
||||
);
|
||||
});
|
||||
|
||||
test("Viewing user api keys when user has redesign user page navigation enabled", async function (assert) {
|
||||
updateCurrentUser({
|
||||
redesigned_user_page_nav_enabled: true,
|
||||
user_api_keys: [
|
||||
{
|
||||
id: 1,
|
||||
application_name: "Discourse Hub",
|
||||
scopes: ["Read and clear notifications"],
|
||||
created_at: "2020-11-14T00:57:09.093Z",
|
||||
last_used_at: "2022-09-15T18:55:41.672Z",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await visit("/u/eviltrout/preferences/security");
|
||||
|
||||
assert.strictEqual(
|
||||
query(".pref-user-api-keys__application-name").innerText.trim(),
|
||||
"Discourse Hub",
|
||||
"displays the application name for the API key"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
query(".pref-user-api-keys__scopes-list-item").innerText.trim(),
|
||||
"Read and clear notifications",
|
||||
"displays the scope for the API key"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
exists(".pref-user-api-keys__created-at"),
|
||||
"displays the created at date for the API key"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
exists(".pref-user-api-keys__last-used-at"),
|
||||
"displays the last used at date for the API key"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user