mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into 2380-Community-tab-change-must-close-conversation-window
This commit is contained in:
commit
5d87fd4922
@ -1,7 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<span v-for="({ type, text }, index) in linkifiedMessage" :key="index">
|
<span v-for="({ type, text }, index) in parsedMessage" :key="index">
|
||||||
<b-link v-if="type === 'link'" :href="text" target="_blank">{{ text }}</b-link>
|
<b-link v-if="type === 'link'" :href="text" target="_blank">{{ text }}</b-link>
|
||||||
|
<span v-else-if="type === 'date'">
|
||||||
|
{{ $d(new Date(text), 'short') }}
|
||||||
|
<br />
|
||||||
|
</span>
|
||||||
|
<span v-else-if="type === 'amount'">
|
||||||
|
<br />
|
||||||
|
{{ `${$n(Number(text), 'decimal')} GDD` }}
|
||||||
|
</span>
|
||||||
<span v-else>{{ text }}</span>
|
<span v-else>{{ text }}</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -12,17 +20,28 @@ const LINK_REGEX_PATTERN =
|
|||||||
/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*))/i
|
/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*))/i
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LinkifyMessage',
|
name: 'ParseMessage',
|
||||||
props: {
|
props: {
|
||||||
message: {
|
message: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
reuired: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
linkifiedMessage() {
|
parsedMessage() {
|
||||||
const linkified = []
|
|
||||||
let string = this.message
|
let string = this.message
|
||||||
|
const linkified = []
|
||||||
|
let amount
|
||||||
|
if (this.type === 'HISTORY') {
|
||||||
|
const split = string.split(/\n\s*---\n\s*/)
|
||||||
|
string = split[1]
|
||||||
|
linkified.push({ type: 'date', text: split[0].trim() })
|
||||||
|
amount = split[2].trim()
|
||||||
|
}
|
||||||
let match
|
let match
|
||||||
while ((match = string.match(LINK_REGEX_PATTERN))) {
|
while ((match = string.match(LINK_REGEX_PATTERN))) {
|
||||||
if (match.index > 0)
|
if (match.index > 0)
|
||||||
@ -31,6 +50,7 @@ export default {
|
|||||||
string = string.substring(match.index + match[0].length)
|
string = string.substring(match.index + match[0].length)
|
||||||
}
|
}
|
||||||
if (string.length > 0) linkified.push({ type: 'text', text: string })
|
if (string.length > 0) linkified.push({ type: 'text', text: string })
|
||||||
|
if (amount) linkified.push({ type: 'amount', text: amount })
|
||||||
return linkified
|
return linkified
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3,12 +3,16 @@ import ContributionMessagesListItem from './ContributionMessagesListItem.vue'
|
|||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
|
const dateMock = jest.fn((d) => d)
|
||||||
|
const numberMock = jest.fn((n) => n)
|
||||||
|
|
||||||
describe('ContributionMessagesListItem', () => {
|
describe('ContributionMessagesListItem', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const mocks = {
|
const mocks = {
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
$d: jest.fn((d) => d),
|
$d: dateMock,
|
||||||
|
$n: numberMock,
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('if message author has moderator role', () => {
|
describe('if message author has moderator role', () => {
|
||||||
@ -189,4 +193,64 @@ and here is the link to the repository: https://github.com/gradido/gradido`)
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('contribution message type HISTORY', () => {
|
||||||
|
const propsData = {
|
||||||
|
message: {
|
||||||
|
id: 111,
|
||||||
|
message: `Sun Nov 13 2022 13:05:48 GMT+0100 (Central European Standard Time)
|
||||||
|
---
|
||||||
|
This message also contains a link: https://gradido.net/de/
|
||||||
|
---
|
||||||
|
350.00`,
|
||||||
|
createdAt: '2022-08-29T12:23:27.000Z',
|
||||||
|
updatedAt: null,
|
||||||
|
type: 'HISTORY',
|
||||||
|
userFirstName: 'Peter',
|
||||||
|
userLastName: 'Lustig',
|
||||||
|
userId: 107,
|
||||||
|
__typename: 'ContributionMessage',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemWrapper = () => {
|
||||||
|
return mount(ContributionMessagesListItem, {
|
||||||
|
localVue,
|
||||||
|
mocks,
|
||||||
|
propsData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let messageField
|
||||||
|
|
||||||
|
describe('render HISTORY message', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
wrapper = itemWrapper()
|
||||||
|
messageField = wrapper.find('div.is-not-moderator.text-left > div:nth-child(4)')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders the date', () => {
|
||||||
|
expect(dateMock).toBeCalledWith(
|
||||||
|
new Date('Sun Nov 13 2022 13:05:48 GMT+0100 (Central European Standard Time'),
|
||||||
|
'short',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders the amount', () => {
|
||||||
|
expect(numberMock).toBeCalledWith(350, 'decimal')
|
||||||
|
expect(messageField.text()).toContain('350 GDD')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('contains the link as text', () => {
|
||||||
|
expect(messageField.text()).toContain(
|
||||||
|
'This message also contains a link: https://gradido.net/de/',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('contains a link to the given address', () => {
|
||||||
|
expect(messageField.find('a').attributes('href')).toBe('https://gradido.net/de/')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -5,23 +5,23 @@
|
|||||||
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
||||||
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
||||||
<small class="ml-4 text-success">{{ $t('moderator') }}</small>
|
<small class="ml-4 text-success">{{ $t('moderator') }}</small>
|
||||||
<linkify-message :message="message.message"></linkify-message>
|
<parse-message v-bind="message"></parse-message>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="text-left is-not-moderator">
|
<div v-else class="text-left is-not-moderator">
|
||||||
<b-avatar variant="info"></b-avatar>
|
<b-avatar variant="info"></b-avatar>
|
||||||
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
||||||
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
||||||
<linkify-message :message="message.message"></linkify-message>
|
<parse-message v-bind="message"></parse-message>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import LinkifyMessage from '@/components/ContributionMessages/LinkifyMessage.vue'
|
import ParseMessage from '@/components/ContributionMessages/ParseMessage.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ContributionMessagesListItem',
|
name: 'ContributionMessagesListItem',
|
||||||
components: {
|
components: {
|
||||||
LinkifyMessage,
|
ParseMessage,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
message: {
|
message: {
|
||||||
|
|||||||
@ -26,12 +26,12 @@ describe('sendAddedContributionMessageEmail', () => {
|
|||||||
it('calls sendEMail', () => {
|
it('calls sendEMail', () => {
|
||||||
expect(sendEMail).toBeCalledWith({
|
expect(sendEMail).toBeCalledWith({
|
||||||
to: `Bibi Bloxberg <bibi@bloxberg.de>`,
|
to: `Bibi Bloxberg <bibi@bloxberg.de>`,
|
||||||
subject: 'Rückfrage zu Deinem Gemeinwohl-Beitrag',
|
subject: 'Nachricht zu deinem Gemeinwohl-Beitrag',
|
||||||
text:
|
text:
|
||||||
expect.stringContaining('Hallo Bibi Bloxberg') &&
|
expect.stringContaining('Hallo Bibi Bloxberg') &&
|
||||||
expect.stringContaining('Peter Lustig') &&
|
expect.stringContaining('Peter Lustig') &&
|
||||||
expect.stringContaining(
|
expect.stringContaining(
|
||||||
'Du hast soeben zu deinem eingereichten Gradido Schöpfungsantrag "Vielen herzlichen Dank für den neuen Hexenbesen!" eine Rückfrage von Peter Lustig erhalten.',
|
'du hast zu deinem Gemeinwohl-Beitrag "Vielen herzlichen Dank für den neuen Hexenbesen!" eine Nachricht von Peter Lustig erhalten.',
|
||||||
) &&
|
) &&
|
||||||
expect.stringContaining('Was für ein Besen ist es geworden?') &&
|
expect.stringContaining('Was für ein Besen ist es geworden?') &&
|
||||||
expect.stringContaining('http://localhost/overview'),
|
expect.stringContaining('http://localhost/overview'),
|
||||||
|
|||||||
@ -26,11 +26,11 @@ describe('sendContributionConfirmedEmail', () => {
|
|||||||
it('calls sendEMail', () => {
|
it('calls sendEMail', () => {
|
||||||
expect(sendEMail).toBeCalledWith({
|
expect(sendEMail).toBeCalledWith({
|
||||||
to: 'Bibi Bloxberg <bibi@bloxberg.de>',
|
to: 'Bibi Bloxberg <bibi@bloxberg.de>',
|
||||||
subject: 'Schöpfung wurde bestätigt',
|
subject: 'Dein Gemeinwohl-Beitrag wurde bestätigt',
|
||||||
text:
|
text:
|
||||||
expect.stringContaining('Hallo Bibi Bloxberg') &&
|
expect.stringContaining('Hallo Bibi Bloxberg') &&
|
||||||
expect.stringContaining(
|
expect.stringContaining(
|
||||||
'Dein Gradido Schöpfungsantrag "Vielen herzlichen Dank für den neuen Hexenbesen!" wurde soeben bestätigt.',
|
'dein Gemeinwohl-Beitrag "Vielen herzlichen Dank für den neuen Hexenbesen!" wurde soeben von Peter Lustig bestätigt und in deinem Gradido-Konto gutgeschrieben.',
|
||||||
) &&
|
) &&
|
||||||
expect.stringContaining('Betrag: 200,00 GDD') &&
|
expect.stringContaining('Betrag: 200,00 GDD') &&
|
||||||
expect.stringContaining('Link zu deinem Konto: http://localhost/overview'),
|
expect.stringContaining('Link zu deinem Konto: http://localhost/overview'),
|
||||||
|
|||||||
@ -26,11 +26,11 @@ describe('sendContributionConfirmedEmail', () => {
|
|||||||
it('calls sendEMail', () => {
|
it('calls sendEMail', () => {
|
||||||
expect(sendEMail).toBeCalledWith({
|
expect(sendEMail).toBeCalledWith({
|
||||||
to: 'Bibi Bloxberg <bibi@bloxberg.de>',
|
to: 'Bibi Bloxberg <bibi@bloxberg.de>',
|
||||||
subject: 'Schöpfung wurde abgelehnt',
|
subject: 'Dein Gemeinwohl-Beitrag wurde abgelehnt',
|
||||||
text:
|
text:
|
||||||
expect.stringContaining('Hallo Bibi Bloxberg') &&
|
expect.stringContaining('Hallo Bibi Bloxberg') &&
|
||||||
expect.stringContaining(
|
expect.stringContaining(
|
||||||
'Dein Gradido Schöpfungsantrag "Vielen herzlichen Dank für den neuen Hexenbesen!" wurde soeben von Peter Lustig abgelehnt.',
|
'dein Gemeinwohl-Beitrag "Vielen herzlichen Dank für den neuen Hexenbesen!" wurde von Peter Lustig abgelehnt.',
|
||||||
) &&
|
) &&
|
||||||
expect.stringContaining('Link zu deinem Konto: http://localhost/overview'),
|
expect.stringContaining('Link zu deinem Konto: http://localhost/overview'),
|
||||||
})
|
})
|
||||||
|
|||||||
@ -26,7 +26,7 @@ describe('sendTransactionReceivedEmail', () => {
|
|||||||
it('calls sendEMail', () => {
|
it('calls sendEMail', () => {
|
||||||
expect(sendEMail).toBeCalledWith({
|
expect(sendEMail).toBeCalledWith({
|
||||||
to: `Peter Lustig <peter@lustig.de>`,
|
to: `Peter Lustig <peter@lustig.de>`,
|
||||||
subject: 'Gradido Überweisung',
|
subject: 'Du hast Gradidos erhalten',
|
||||||
text:
|
text:
|
||||||
expect.stringContaining('Hallo Peter Lustig') &&
|
expect.stringContaining('Hallo Peter Lustig') &&
|
||||||
expect.stringContaining('42,00 GDD') &&
|
expect.stringContaining('42,00 GDD') &&
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import Decimal from 'decimal.js-light'
|
|||||||
|
|
||||||
export const contributionConfirmed = {
|
export const contributionConfirmed = {
|
||||||
de: {
|
de: {
|
||||||
subject: 'Schöpfung wurde bestätigt',
|
subject: 'Dein Gemeinwohl-Beitrag wurde bestätigt',
|
||||||
text: (data: {
|
text: (data: {
|
||||||
senderFirstName: string
|
senderFirstName: string
|
||||||
senderLastName: string
|
senderLastName: string
|
||||||
@ -14,18 +14,17 @@ export const contributionConfirmed = {
|
|||||||
}): string =>
|
}): string =>
|
||||||
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
||||||
|
|
||||||
Dein eingereichter Gemeinwohl-Beitrag "${data.contributionMemo}" wurde soeben von ${
|
dein Gemeinwohl-Beitrag "${data.contributionMemo}" wurde soeben von ${data.senderFirstName} ${
|
||||||
data.senderFirstName
|
data.senderLastName
|
||||||
} ${data.senderLastName} bestätigt.
|
} bestätigt und in deinem Gradido-Konto gutgeschrieben.
|
||||||
|
|
||||||
Betrag: ${data.contributionAmount.toFixed(2).replace('.', ',')} GDD
|
Betrag: ${data.contributionAmount.toFixed(2).replace('.', ',')} GDD
|
||||||
|
|
||||||
|
Link zu deinem Konto: ${data.overviewURL}
|
||||||
|
|
||||||
Bitte antworte nicht auf diese E-Mail!
|
Bitte antworte nicht auf diese E-Mail!
|
||||||
|
|
||||||
Mit freundlichen Grüßen,
|
Liebe Grüße
|
||||||
dein Gradido-Team
|
dein Gradido-Team`,
|
||||||
|
|
||||||
|
|
||||||
Link zu deinem Konto: ${data.overviewURL}`,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export const contributionMessageReceived = {
|
export const contributionMessageReceived = {
|
||||||
de: {
|
de: {
|
||||||
subject: 'Rückfrage zu Deinem Gemeinwohl-Beitrag',
|
subject: 'Nachricht zu deinem Gemeinwohl-Beitrag',
|
||||||
text: (data: {
|
text: (data: {
|
||||||
senderFirstName: string
|
senderFirstName: string
|
||||||
senderLastName: string
|
senderLastName: string
|
||||||
@ -14,15 +14,15 @@ export const contributionMessageReceived = {
|
|||||||
}): string =>
|
}): string =>
|
||||||
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
||||||
|
|
||||||
du hast soeben zu deinem eingereichten Gemeinwohl-Beitrag "${data.contributionMemo}" eine Rückfrage von ${data.senderFirstName} ${data.senderLastName} erhalten.
|
du hast zu deinem Gemeinwohl-Beitrag "${data.contributionMemo}" eine Nachricht von ${data.senderFirstName} ${data.senderLastName} erhalten.
|
||||||
|
|
||||||
Bitte beantworte die Rückfrage in deinem Gradido-Konto im Menü "Gemeinschaft" im Tab "Meine Beiträge zum Gemeinwohl"!
|
Um die Nachricht zu sehen und darauf zu antworten, gehe in deinem Gradido-Konto ins Menü "Gemeinschaft" auf den Tab "Meine Beiträge zum Gemeinwohl"!
|
||||||
|
|
||||||
Link zu deinem Konto: ${data.overviewURL}
|
Link zu deinem Konto: ${data.overviewURL}
|
||||||
|
|
||||||
Bitte antworte nicht auf diese E-Mail!
|
Bitte antworte nicht auf diese E-Mail!
|
||||||
|
|
||||||
Mit freundlichen Grüßen,
|
Liebe Grüße
|
||||||
dein Gradido-Team`,
|
dein Gradido-Team`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import Decimal from 'decimal.js-light'
|
|||||||
|
|
||||||
export const contributionRejected = {
|
export const contributionRejected = {
|
||||||
de: {
|
de: {
|
||||||
subject: 'Schöpfung wurde abgelehnt',
|
subject: 'Dein Gemeinwohl-Beitrag wurde abgelehnt',
|
||||||
text: (data: {
|
text: (data: {
|
||||||
senderFirstName: string
|
senderFirstName: string
|
||||||
senderLastName: string
|
senderLastName: string
|
||||||
@ -14,14 +14,15 @@ export const contributionRejected = {
|
|||||||
}): string =>
|
}): string =>
|
||||||
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
||||||
|
|
||||||
Dein eingereichter Gemeinwohl-Beitrag "${data.contributionMemo}" wurde soeben von ${data.senderFirstName} ${data.senderLastName} abgelehnt.
|
dein Gemeinwohl-Beitrag "${data.contributionMemo}" wurde von ${data.senderFirstName} ${data.senderLastName} abgelehnt.
|
||||||
|
|
||||||
|
Um deine Gemeinwohl-Beiträge und dazugehörige Nachrichten zu sehen, gehe in deinem Gradido-Konto ins Menü "Gemeinschaft" auf den Tab "Meine Beiträge zum Gemeinwohl"!
|
||||||
|
|
||||||
|
Link zu deinem Konto: ${data.overviewURL}
|
||||||
|
|
||||||
Bitte antworte nicht auf diese E-Mail!
|
Bitte antworte nicht auf diese E-Mail!
|
||||||
|
|
||||||
Mit freundlichen Grüßen,
|
Liebe Grüße
|
||||||
dein Gradido-Team
|
dein Gradido-Team`,
|
||||||
|
|
||||||
|
|
||||||
Link zu deinem Konto: ${data.overviewURL}`,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,20 +14,20 @@ export const transactionLinkRedeemed = {
|
|||||||
memo: string
|
memo: string
|
||||||
overviewURL: string
|
overviewURL: string
|
||||||
}): string =>
|
}): string =>
|
||||||
`Hallo ${data.recipientFirstName} ${data.recipientLastName}
|
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
||||||
|
|
||||||
${data.senderFirstName} ${data.senderLastName} (${
|
${data.senderFirstName} ${data.senderLastName} (${
|
||||||
data.senderEmail
|
data.senderEmail
|
||||||
}) hat soeben deinen Link eingelöst.
|
}) hat soeben deinen Link eingelöst.
|
||||||
|
|
||||||
Betrag: ${data.amount.toFixed(2).replace('.', ',')} GDD,
|
Betrag: ${data.amount.toFixed(2).replace('.', ',')} GDD,
|
||||||
Memo: ${data.memo}
|
Memo: ${data.memo}
|
||||||
|
|
||||||
Details zur Transaktion findest du in deinem Gradido-Konto: ${data.overviewURL}
|
Details zur Transaktion findest du in deinem Gradido-Konto: ${data.overviewURL}
|
||||||
|
|
||||||
Bitte antworte nicht auf diese E-Mail!
|
Bitte antworte nicht auf diese E-Mail!
|
||||||
|
|
||||||
Mit freundlichen Grüßen,
|
Liebe Grüße
|
||||||
dein Gradido-Team`,
|
dein Gradido-Team`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import Decimal from 'decimal.js-light'
|
|||||||
|
|
||||||
export const transactionReceived = {
|
export const transactionReceived = {
|
||||||
de: {
|
de: {
|
||||||
subject: 'Gradido Überweisung',
|
subject: 'Du hast Gradidos erhalten',
|
||||||
text: (data: {
|
text: (data: {
|
||||||
senderFirstName: string
|
senderFirstName: string
|
||||||
senderLastName: string
|
senderLastName: string
|
||||||
@ -13,9 +13,9 @@ export const transactionReceived = {
|
|||||||
amount: Decimal
|
amount: Decimal
|
||||||
overviewURL: string
|
overviewURL: string
|
||||||
}): string =>
|
}): string =>
|
||||||
`Hallo ${data.recipientFirstName} ${data.recipientLastName}
|
`Hallo ${data.recipientFirstName} ${data.recipientLastName},
|
||||||
|
|
||||||
Du hast soeben ${data.amount.toFixed(2).replace('.', ',')} GDD von ${data.senderFirstName} ${
|
du hast soeben ${data.amount.toFixed(2).replace('.', ',')} GDD von ${data.senderFirstName} ${
|
||||||
data.senderLastName
|
data.senderLastName
|
||||||
} (${data.senderEmail}) erhalten.
|
} (${data.senderEmail}) erhalten.
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ Details zur Transaktion findest du in deinem Gradido-Konto: ${data.overviewURL}
|
|||||||
|
|
||||||
Bitte antworte nicht auf diese E-Mail!
|
Bitte antworte nicht auf diese E-Mail!
|
||||||
|
|
||||||
Mit freundlichen Grüßen,
|
Liebe Grüße
|
||||||
dein Gradido-Team`,
|
dein Gradido-Team`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,11 @@ import ContributionMessagesListItem from './ContributionMessagesListItem.vue'
|
|||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
|
const dateMock = jest.fn((d) => d)
|
||||||
|
|
||||||
const mocks = {
|
const mocks = {
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
$d: jest.fn((d) => d),
|
$d: dateMock,
|
||||||
$store: {
|
$store: {
|
||||||
state: {
|
state: {
|
||||||
firstName: 'Peter',
|
firstName: 'Peter',
|
||||||
@ -239,4 +241,63 @@ and here is the link to the repository: https://github.com/gradido/gradido`)
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('contribution message type HISTORY', () => {
|
||||||
|
const propsData = {
|
||||||
|
message: {
|
||||||
|
id: 111,
|
||||||
|
message: `Sun Nov 13 2022 13:05:48 GMT+0100 (Central European Standard Time)
|
||||||
|
---
|
||||||
|
This message also contains a link: https://gradido.net/de/
|
||||||
|
---
|
||||||
|
350.00`,
|
||||||
|
createdAt: '2022-08-29T12:23:27.000Z',
|
||||||
|
updatedAt: null,
|
||||||
|
type: 'HISTORY',
|
||||||
|
userFirstName: 'Peter',
|
||||||
|
userLastName: 'Lustig',
|
||||||
|
userId: 107,
|
||||||
|
__typename: 'ContributionMessage',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemWrapper = () => {
|
||||||
|
return mount(ContributionMessagesListItem, {
|
||||||
|
localVue,
|
||||||
|
mocks,
|
||||||
|
propsData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let messageField
|
||||||
|
|
||||||
|
describe('render HISTORY message', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
wrapper = itemWrapper()
|
||||||
|
messageField = wrapper.find('div.is-not-moderator.text-right > div:nth-child(4)')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders the date', () => {
|
||||||
|
expect(dateMock).toBeCalledWith(
|
||||||
|
new Date('Sun Nov 13 2022 13:05:48 GMT+0100 (Central European Standard Time'),
|
||||||
|
'short',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders the amount', () => {
|
||||||
|
expect(messageField.text()).toContain('350.00 GDD')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('contains the link as text', () => {
|
||||||
|
expect(messageField.text()).toContain(
|
||||||
|
'This message also contains a link: https://gradido.net/de/',
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('contains a link to the given address', () => {
|
||||||
|
expect(messageField.find('a').attributes('href')).toBe('https://gradido.net/de/')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -4,25 +4,25 @@
|
|||||||
<b-avatar variant="info"></b-avatar>
|
<b-avatar variant="info"></b-avatar>
|
||||||
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
||||||
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
||||||
<linkify-message :message="message.message"></linkify-message>
|
<parse-message v-bind="message"></parse-message>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="is-moderator text-left">
|
<div v-else class="is-moderator text-left">
|
||||||
<b-avatar square variant="warning"></b-avatar>
|
<b-avatar square variant="warning"></b-avatar>
|
||||||
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
<span class="ml-2 mr-2">{{ message.userFirstName }} {{ message.userLastName }}</span>
|
||||||
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
<span class="ml-2">{{ $d(new Date(message.createdAt), 'short') }}</span>
|
||||||
<small class="ml-4 text-success">{{ $t('community.moderator') }}</small>
|
<small class="ml-4 text-success">{{ $t('community.moderator') }}</small>
|
||||||
<linkify-message :message="message.message"></linkify-message>
|
<parse-message v-bind="message"></parse-message>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import LinkifyMessage from '@/components/ContributionMessages/LinkifyMessage.vue'
|
import ParseMessage from '@/components/ContributionMessages/ParseMessage.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ContributionMessagesListItem',
|
name: 'ContributionMessagesListItem',
|
||||||
components: {
|
components: {
|
||||||
LinkifyMessage,
|
ParseMessage,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
message: {
|
message: {
|
||||||
|
|||||||
@ -1,7 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
<span v-for="({ type, text }, index) in linkifiedMessage" :key="index">
|
<span v-for="({ type, text }, index) in parsedMessage" :key="index">
|
||||||
<b-link v-if="type === 'link'" :href="text" target="_blank">{{ text }}</b-link>
|
<b-link v-if="type === 'link'" :href="text" target="_blank">{{ text }}</b-link>
|
||||||
|
<span v-else-if="type === 'date'">
|
||||||
|
{{ $d(new Date(text), 'short') }}
|
||||||
|
<br />
|
||||||
|
</span>
|
||||||
|
<span v-else-if="type === 'amount'">
|
||||||
|
<br />
|
||||||
|
{{ text | GDD }}
|
||||||
|
</span>
|
||||||
<span v-else>{{ text }}</span>
|
<span v-else>{{ text }}</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -11,17 +19,28 @@
|
|||||||
const LINK_REGEX_PATTERN = /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*))/i
|
const LINK_REGEX_PATTERN = /(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*))/i
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'LinkifyMessage',
|
name: 'ParseMessage',
|
||||||
props: {
|
props: {
|
||||||
message: {
|
message: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
type: {
|
||||||
|
type: String,
|
||||||
|
reuired: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
linkifiedMessage() {
|
parsedMessage() {
|
||||||
const linkified = []
|
|
||||||
let string = this.message
|
let string = this.message
|
||||||
|
const linkified = []
|
||||||
|
let amount
|
||||||
|
if (this.type === 'HISTORY') {
|
||||||
|
const split = string.split(/\n\s*---\n\s*/)
|
||||||
|
string = split[1]
|
||||||
|
linkified.push({ type: 'date', text: split[0].trim() })
|
||||||
|
amount = split[2].trim()
|
||||||
|
}
|
||||||
let match
|
let match
|
||||||
while ((match = string.match(LINK_REGEX_PATTERN))) {
|
while ((match = string.match(LINK_REGEX_PATTERN))) {
|
||||||
if (match.index > 0)
|
if (match.index > 0)
|
||||||
@ -30,6 +49,7 @@ export default {
|
|||||||
string = string.substring(match.index + match[0].length)
|
string = string.substring(match.index + match[0].length)
|
||||||
}
|
}
|
||||||
if (string.length > 0) linkified.push({ type: 'text', text: string })
|
if (string.length > 0) linkified.push({ type: 'text', text: string })
|
||||||
|
if (amount) linkified.push({ type: 'amount', text: amount })
|
||||||
return linkified
|
return linkified
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Loading…
x
Reference in New Issue
Block a user