-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ mon-pix: call companion-alert endpoint when companion is not detected
Co-authored-by: Andreia Pena Ferreira <andreia.pena@pix.fr>
- Loading branch information
1 parent
81d1358
commit bd63f5b
Showing
4 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
|
||
import CompanionBlocker from '../companion/blocker'; | ||
|
||
<template> | ||
{{#if @assessment.isCertification}} | ||
<CompanionBlocker> | ||
export default class Assessments extends Component { | ||
@service store; | ||
|
||
@action | ||
async createLiveAlert() { | ||
const adapter = this.store.adapterFor('assessment'); | ||
await adapter.createCompanionLiveAlert({ assessmentId: this.args.assessment.id }); | ||
} | ||
|
||
<template> | ||
{{#if @assessment.isCertification}} | ||
<CompanionBlocker @onBlock={{this.createLiveAlert}}> | ||
{{yield}} | ||
</CompanionBlocker> | ||
{{else}} | ||
{{yield}} | ||
</CompanionBlocker> | ||
{{else}} | ||
{{yield}} | ||
{{/if}} | ||
</template> | ||
{{/if}} | ||
</template> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
mon-pix/tests/unit/components/assessments/assessments-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { setupTest } from 'ember-qunit'; | ||
import createGlimmerComponent from 'mon-pix/tests/helpers/create-glimmer-component'; | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
module('Unit | Component | Assessments | Assessments', function (hooks) { | ||
setupTest(hooks); | ||
|
||
module('#createLiveAlert', function () { | ||
test('should create a companion live alert', async function (assert) { | ||
// given | ||
const component = createGlimmerComponent('assessments/assessments', { | ||
assessment: { | ||
id: 123, | ||
isCertification: true, | ||
}, | ||
}); | ||
const store = this.owner.lookup('service:store'); | ||
const adapter = store.adapterFor('assessment'); | ||
const createCompanionLiveAlertStub = sinon.stub(adapter, 'createCompanionLiveAlert'); | ||
|
||
// when | ||
await component.createLiveAlert(); | ||
|
||
// then | ||
sinon.assert.calledWithExactly(createCompanionLiveAlertStub, { assessmentId: 123 }); | ||
assert.ok(true); | ||
}); | ||
}); | ||
}); |