Skip to content
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

Stabilize token scopes #6573

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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