diff options
| author | Hiral Bhavsar <hbh@odoo.com> | 2020-10-07 11:11:25 +0000 |
|---|---|---|
| committer | Hiral Bhavsar <hbh@odoo.com> | 2020-10-15 11:01:19 +0000 |
| commit | becf051f38fcf08d4a0aea758cb2758ad0f25bc3 (patch) | |
| tree | f64decac8b5a90d49fd8a3ba4a2b781d5637335c /addons/website_slides/static/src/components/activity | |
| parent | 43db576b7f0efed563ee597ab087e4d7ef5c74d9 (diff) | |
[FIX] mail, website_slides: fix while accept the request from the new attendee
Before this commit:
We have a new feature that if the course is private, and attendee make the
request to access the course it will create an activity for 'course responsible'.
Currently, after accepting the invitation request from the new user, it is still
not considered the user as an attendee and not displaying like 'You're enrolled'
to the respective users
After this commit:
The features of access invitation on courses will be workable.
Task-2328389
closes odoo/odoo#59504
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/website_slides/static/src/components/activity')
| -rw-r--r-- | addons/website_slides/static/src/components/activity/activity_tests.js | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/addons/website_slides/static/src/components/activity/activity_tests.js b/addons/website_slides/static/src/components/activity/activity_tests.js new file mode 100644 index 00000000000..d8e465a4237 --- /dev/null +++ b/addons/website_slides/static/src/components/activity/activity_tests.js @@ -0,0 +1,124 @@ +odoo.define('website_slides/static/src/tests/activity_tests.js', function (require) { +'use strict'; + +const components = { + Activity: require('mail/static/src/components/activity/activity.js'), +}; + +const { + afterEach, + beforeEach, + createRootComponent, + start, +} = require('mail/static/src/utils/test_utils.js'); + +QUnit.module('website_slides', {}, function () { +QUnit.module('components', {}, function () { +QUnit.module('activity', {}, function () { +QUnit.module('activity_tests.js', { + beforeEach() { + beforeEach(this); + + this.createActivityComponent = async activity => { + await createRootComponent(this, components.Activity, { + props: { activityLocalId: activity.localId }, + target: this.widget.el, + }); + }; + + this.start = async params => { + const { env, widget } = await start(Object.assign({}, params, { + data: this.data, + })); + this.env = env; + this.widget = widget; + }; + }, + afterEach() { + afterEach(this); + }, +}); + +QUnit.test('grant course access', async function (assert) { + assert.expect(8); + + await this.start({ + async mockRPC(route, args) { + if (args.method === 'action_grant_access') { + assert.strictEqual(args.args.length, 1); + assert.strictEqual(args.args[0].length, 1); + assert.strictEqual(args.args[0][0], 100); + assert.strictEqual(args.kwargs.partner_id, 5); + assert.step('access_grant'); + } + return this._super(...arguments); + }, + }); + const activity = this.env.models['mail.activity'].create({ + canWrite: true, + thread: [['insert', { + id: 100, + model: 'slide.channel', + }]], + requestingPartner: [['insert', { + id: 5, + displayName: "Pauvre pomme", + }]], + type: [['insert', { + id: 1, + displayName: "Access Request", + }]], + }); + await this.createActivityComponent(activity); + + assert.containsOnce(document.body, '.o_Activity', "should have activity component"); + assert.containsOnce(document.body, '.o_Activity_grantAccessButton', "should have grant access button"); + + document.querySelector('.o_Activity_grantAccessButton').click(); + assert.verifySteps(['access_grant'], "Grant button should trigger the right rpc call"); +}); + +QUnit.test('refuse course access', async function (assert) { + assert.expect(8); + + await this.start({ + async mockRPC(route, args) { + if (args.method === 'action_refuse_access') { + assert.strictEqual(args.args.length, 1); + assert.strictEqual(args.args[0].length, 1); + assert.strictEqual(args.args[0][0], 100); + assert.strictEqual(args.kwargs.partner_id, 5); + assert.step('access_refuse'); + } + return this._super(...arguments); + }, + }); + const activity = this.env.models['mail.activity'].create({ + canWrite: true, + thread: [['insert', { + id: 100, + model: 'slide.channel', + }]], + requestingPartner: [['insert', { + id: 5, + displayName: "Pauvre pomme", + }]], + type: [['insert', { + id: 1, + displayName: "Access Request", + }]], + }); + await this.createActivityComponent(activity); + + assert.containsOnce(document.body, '.o_Activity', "should have activity component"); + assert.containsOnce(document.body, '.o_Activity_refuseAccessButton', "should have refuse access button"); + + document.querySelector('.o_Activity_refuseAccessButton').click(); + assert.verifySteps(['access_refuse'], "refuse button should trigger the right rpc call"); +}); + +}); +}); +}); + +}); |
