-
Notifications
You must be signed in to change notification settings - Fork 98
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
Implement mobile Intercom using vuex store #3424
Changes from 6 commits
a3dbf8c
8564f57
3ceadf7
c1e429e
a2e46c8
0597cfb
a9f41cd
69c81cc
7dcae71
32be543
8a3d66e
51b3488
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Added] [#3423](https://github.com/cosmos/lunie/issues/3423) Implement mobile Intercom using vuex store @mariopino |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import config from "src/../config" | ||
import { Intercom } from "capacitor-intercom" | ||
|
||
let intercom = null | ||
/* istanbul ignore next */ | ||
if (config.mobileApp) { | ||
intercom = new Intercom() | ||
const userId = "lunie-app-" + Math.floor(Math.random() * 10000 + 1).toString() | ||
intercom.registerIdentifiedUser({ userId }) | ||
} | ||
|
||
export default () => { | ||
return { | ||
state: { | ||
intercom | ||
}, | ||
mutations: { | ||
displayMessenger(state) { | ||
state.intercom.displayMessenger() | ||
}, | ||
displayHelpCenter(state) { | ||
state.intercom.displayHelpCenter() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It opens the help center (I guess is the same thing you talked about the last demo day conf). What do you think about? We can remove it if it's not going to be useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as long as it is not used, we should not have it in code. But nice to know this is possible. |
||
} | ||
}, | ||
actions: { | ||
displayMessenger({ commit }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we only need mutations or actions for this ^^ I guess only actions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It put the mutations there cause I think not having it was causing problems with I needed to modify transformIgnorePatterns in jest config to whitelist
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you considered mocking the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, good point! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is done and great! testing back to normal speed ;-) |
||
commit(`displayMessenger`) | ||
}, | ||
displayHelpCenter({ commit }) { | ||
commit(`displayHelpCenter`) | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import recoverModule from "src/vuex/modules/intercom.js" | ||
|
||
describe(`Module: Intercom`, () => { | ||
let module, state, actions, mutations, node | ||
|
||
const intercom = { | ||
displayMessenger: jest.fn(), | ||
displayHelpCenter: jest.fn() | ||
} | ||
|
||
const spydisplayMessenger = jest.spyOn(intercom, "displayMessenger") | ||
const spydisplayHelpCenter = jest.spyOn(intercom, "displayHelpCenter") | ||
|
||
beforeEach(() => { | ||
node = {} | ||
module = recoverModule({ node }) | ||
state = { intercom } | ||
actions = module.actions | ||
mutations = module.mutations | ||
}) | ||
|
||
describe(`mutations`, () => { | ||
it(`should display Intercom Messenger`, () => { | ||
mutations.displayMessenger(state) | ||
expect(spydisplayMessenger).toHaveBeenCalled() | ||
}) | ||
it(`should display Help Center`, () => { | ||
mutations.displayHelpCenter(state) | ||
expect(spydisplayHelpCenter).toHaveBeenCalled() | ||
}) | ||
}) | ||
|
||
describe(`actions`, () => { | ||
it(`should display Intercom Messenger`, async () => { | ||
const commit = jest.fn() | ||
await actions.displayMessenger({ commit }) | ||
expect(commit).toHaveBeenCalledWith(`displayMessenger`) | ||
}) | ||
it(`should display Help Center`, async () => { | ||
const commit = jest.fn() | ||
await actions.displayHelpCenter({ commit }) | ||
expect(commit).toHaveBeenCalledWith(`displayHelpCenter`) | ||
}) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably don't need to add the ios stuff (or anything) here if it gets overridden by the top level capacitor.config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the reason why that file has this content (the top-level config file has it).