Fix Discourse integration success result and add regression test
This commit is contained in:
1 parent
f83b3e4fd0
commit
d9186a2afc
2 files changed
+49
-4
No files matched your search
@@ -3,11 +3,15 @@ import { on } from '@ember/modifier';
|
||||
|
||||
export default class IntegrationResult extends Component {
|
||||
get isSuccess() {
|
||||
return this.args.result?.success;
|
||||
return this.args.props?.result?.success;
|
||||
}
|
||||
|
||||
get isError() {
|
||||
return this.args.result?.error;
|
||||
return this.args.props?.result?.error;
|
||||
}
|
||||
|
||||
get error() {
|
||||
return this.args.props?.result?.error;
|
||||
}
|
||||
|
||||
<template>
|
||||
@@ -60,7 +64,7 @@ export default class IntegrationResult extends Component {
|
||||
Your Discourse forum has been connected successfully. You can now
|
||||
receive notifications from your forum.
|
||||
{{else}}
|
||||
{{@result.error}}
|
||||
{{this.error}}
|
||||
{{/if}}
|
||||
</p>
|
||||
</div>
|
||||
@@ -71,7 +75,7 @@ export default class IntegrationResult extends Component {
|
||||
{{on "click" @close}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-xs hover:bg-indigo-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
|
||||
>
|
||||
Go back to dashboard
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'dashtab/tests/helpers';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import Result from 'dashtab/components/settings/integrations/result';
|
||||
|
||||
module(
|
||||
'Integration | Component | settings/integrations/result',
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders a success result', async function (assert) {
|
||||
const noop = () => {};
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<Result @props={{hash result=(hash success=true)}} @close={{noop}} />
|
||||
</template>
|
||||
);
|
||||
|
||||
assert.dom().containsText('Integration Successful!');
|
||||
assert.dom('button').hasText('Close');
|
||||
});
|
||||
|
||||
test('it renders an error result', async function (assert) {
|
||||
const noop = () => {};
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<Result
|
||||
@props={{hash result=(hash error="Something went wrong")}}
|
||||
@close={{noop}}
|
||||
/>
|
||||
</template>
|
||||
);
|
||||
|
||||
assert.dom().containsText('Integration Failed');
|
||||
assert.dom().containsText('Something went wrong');
|
||||
assert.dom('button').hasText('Close');
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in new issue
Block a user