Fixed hanging dash when no attribution is present (#20869)

ref PLG-198

- Fixed trailing dash when no attribution is present
This commit is contained in:
Ronald Langeveld 2024-08-29 15:22:31 +09:00 committed by GitHub
parent 7be7112e68
commit 8e1a730731
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 59 additions and 7 deletions

View File

@ -28,8 +28,10 @@
<span class="gh-members-activity-event-join">{{event.join}}</span> <span class="gh-members-activity-event-join">{{event.join}}</span>
<LinkTo class="gh-members-activity-object-link" @route={{event.route.name}} @model={{event.route.model}}>{{event.object}}</LinkTo> <LinkTo class="gh-members-activity-object-link" @route={{event.route.name}} @model={{event.route.model}}>{{event.object}}</LinkTo>
{{else if event.url}} {{else if event.url}}
<span class="gh-members-activity-event-join">{{event.join}}</span> {{#if event.object}}
<span data-test-id="event-join-row" class="gh-members-activity-event-join">{{event.join}}</span>
<a class="ghost-members-activity-object-link" href="{{event.url}}" target="_blank" rel="noopener noreferrer">{{event.object}}</a> <a class="ghost-members-activity-object-link" href="{{event.url}}" target="_blank" rel="noopener noreferrer">{{event.object}}</a>
{{/if}}
{{else if event.email}} {{else if event.email}}
<span class="gh-members-activity-event-dash"></span> <span class="gh-members-activity-event-dash"></span>
<GhEmailPreviewLink @data={{event.email}} /> <GhEmailPreviewLink @data={{event.email}} />

View File

@ -1,6 +1,6 @@
import moment from 'moment-timezone'; import moment from 'moment-timezone';
import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support'; import {authenticateSession, invalidateSession} from 'ember-simple-auth/test-support';
import {click, currentURL, findAll} from '@ember/test-helpers'; import {click, currentURL, find, findAll} from '@ember/test-helpers';
import {describe, it} from 'mocha'; import {describe, it} from 'mocha';
import {expect} from 'chai'; import {expect} from 'chai';
import {setupApplicationTest} from 'ember-mocha'; import {setupApplicationTest} from 'ember-mocha';
@ -63,10 +63,6 @@ describe('Acceptance: Members activity', function () {
await authenticateSession(); await authenticateSession();
// this.server.createList('member', 3, {status: 'free'});
// this.server.createList('member', 4, {status: 'paid'});
// this.server.createList('member-activity-event', 10, {createdAt: moment('2024-08-18 08:18:08').format('YYYY-MM-DD HH:mm:ss')});
// create 1 member with id 1 // create 1 member with id 1
this.server.create('member', {id: 1, name: 'Member 1', email: '', status: 'free'}); this.server.create('member', {id: 1, name: 'Member 1', email: '', status: 'free'});
@ -97,5 +93,59 @@ describe('Acceptance: Members activity', function () {
await click('[data-test-id="event-type-filter-checkbox-payment_event"]'); await click('[data-test-id="event-type-filter-checkbox-payment_event"]');
expect(findAll('.gh-members-activity-event').length).to.equal(1); expect(findAll('.gh-members-activity-event').length).to.equal(1);
}); });
it('has a donation event with attribution from homepage and has a dash', async function () {
this.server.create('member-activity-event', {
memberId: 1,
createdAt: moment('2024-08-18 08:18:08').format('YYYY-MM-DD HH:mm:ss'),
type: 'donation_event',
data: {
amount: 500000, // or whatever amount you want to test with
currency: 'krw',
attribution: {
title: 'homepage',
url: 'https://example.com'
}
}
});
await visit('/members-activity');
const events = findAll('.gh-members-activity-event');
let donationEvent = null;
for (let event of events) {
if (event.textContent.includes('homepage')) {
donationEvent = event;
break;
}
}
donationEvent = find('.gh-members-activity-event-join');
expect(donationEvent.textContent).to.include('');
});
it('has a donation event without attribution and does not contain a dash', async function () {
this.server.create('member-activity-event', {
memberId: 1,
createdAt: moment('2024-08-18 08:18:08').format('YYYY-MM-DD HH:mm:ss'),
type: 'donation_event',
data: {
amount: 500000, // or whatever amount you want to test with
currency: 'krw'
}
});
await visit('/members-activity');
const events = findAll('.gh-members-activity-event');
const donationEventWithoutAttribution = events[0];
expect(donationEventWithoutAttribution).to.exist;
expect(donationEventWithoutAttribution.textContent).to.not.include('');
});
}); });
}); });