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

UI - auth form prefer pathed methods #5281

Merged
merged 1 commit into from
Sep 5, 2018
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
5 changes: 4 additions & 1 deletion ui/app/components/auth-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export default Ember.Component.extend(DEFAULTS, {
}
// this is here because we're changing the `with` attr and there's no way to short-circuit rendering,
// so we'll just nav -> get new attrs -> re-render
if (!this.get('selectedAuth') || (this.get('selectedAuth') && !this.get('selectedAuthBackend'))) {
if (
(this.get('fetchMethods.isIdle') && !this.get('selectedAuth')) ||
(this.get('selectedAuth') && !this.get('selectedAuthBackend'))
) {
this.set('selectedAuth', this.firstMethod());
this.get('router').replaceWith({
queryParams: {
Expand Down
14 changes: 13 additions & 1 deletion ui/tests/integration/components/auth-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,21 @@ test('it renders AdapterError style errors', function(assert) {
});

test('it renders all the supported tabs when no methods are passed', function(assert) {
let replaceSpy = sinon.spy(this.get('router'), 'replaceWith');
this.render(hbs`{{auth-form cluster=cluster}}`);
assert.equal(component.tabs.length, BACKENDS.length, 'renders a tab for every backend');

return wait().then(() => {
assert.equal(component.tabs.length, BACKENDS.length, 'renders a tab for every backend');
assert.equal(
replaceSpy.getCall(0).args[0].queryParams.with,
'token',
'calls router replaceWith properly'
);
});
});

test('it renders all the supported methods and Other tab when methods are present', function(assert) {
let replaceSpy = sinon.spy(this.get('router'), 'replaceWith');
let methods = {
'foo/': {
type: 'userpass',
Expand All @@ -128,7 +138,9 @@ test('it renders all the supported methods and Other tab when methods are presen
assert.equal(component.tabs.length, 2, 'renders a tab for userpass and Other');
assert.equal(component.tabs.objectAt(0).name, 'foo', 'uses the path in the label');
assert.equal(component.tabs.objectAt(1).name, 'Other', 'second tab is the Other tab');
assert.equal(replaceSpy.getCall(0).args[0].queryParams.with, 'foo/', 'calls router replaceWith properly');
server.shutdown();
replaceSpy.restore();
});
});

Expand Down