Skip to content

Commit

Permalink
Stabilize token scopes (#6573)
Browse files Browse the repository at this point in the history
This enables the new "Create API Token" page for everyone, including the new support for API token scopes.
  • Loading branch information
Turbo87 authored Jun 5, 2023
1 parent af2b59a commit 46ea2c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
8 changes: 2 additions & 6 deletions app/components/settings/api-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ export default class ApiTokens extends Component {
return new Intl.ListFormat('en-US').formatToParts(list);
}

@action startNewToken(event) {
if (event.altKey) {
this.router.transitionTo('settings.tokens.new');
} else {
this.newToken = this.store.createRecord('api-token');
}
@action startNewToken() {
this.router.transitionTo('settings.tokens.new');
}

saveTokenTask = task(async () => {
Expand Down
20 changes: 7 additions & 13 deletions tests/acceptance/api-token-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,19 @@ module('Acceptance | api-tokens', function (hooks) {
await visit('/settings/tokens');
assert.strictEqual(currentURL(), '/settings/tokens');
assert.dom('[data-test-api-token]').exists({ count: 2 });
assert.dom('[data-test-focused-input]').doesNotExist();
assert.dom('[data-test-save-token-button]').doesNotExist();

await click('[data-test-new-token-button]');
assert.dom('[data-test-new-token-button]').isDisabled();
assert.dom('[data-test-focused-input]').isFocused();
assert.dom('[data-test-save-token-button]').exists();
assert.strictEqual(currentURL(), '/settings/tokens/new');

await fillIn('[data-test-focused-input]', 'the new token');
await fillIn('[data-test-name]', 'the new token');
await click('[data-test-scope="publish-update"]');
await percySnapshot(assert);

await click('[data-test-save-token-button]');
await click('[data-test-generate]');

let token = this.server.schema.apiTokens.findBy({ name: 'the new token' });
assert.ok(Boolean(token), 'API token has been created in the backend database');

assert.dom('[data-test-focused-input]').doesNotExist();
assert.dom('[data-test-save-token-button]').doesNotExist();

assert.dom('[data-test-api-token="3"] [data-test-name]').hasText('the new token');
assert.dom('[data-test-api-token="3"] [data-test-save-token-button]').doesNotExist();
assert.dom('[data-test-api-token="3"] [data-test-revoke-token-button]').exists();
Expand All @@ -138,8 +132,9 @@ module('Acceptance | api-tokens', function (hooks) {

await visit('/settings/tokens');
await click('[data-test-new-token-button]');
await fillIn('[data-test-focused-input]', 'the new token');
await click('[data-test-save-token-button]');
await fillIn('[data-test-name]', 'the new token');
await click('[data-test-scope="publish-update"]');
await click('[data-test-generate]');

let token = this.server.schema.apiTokens.findBy({ name: 'the new token' });
assert.dom('[data-test-token]').hasText(token.token);
Expand All @@ -159,7 +154,6 @@ module('Acceptance | api-tokens', function (hooks) {
assert.dom('[data-test-api-token]').exists({ count: 2 });

await click('[data-test-new-token-button]');
await fillIn('[data-test-focused-input]', 'the new token');

await visit('/settings/profile');

Expand Down

0 comments on commit 46ea2c8

Please sign in to comment.