add tests for new activity of offers-directly-to-user

This commit is contained in:
2024-11-03 20:09:54 -07:00
parent fcec9e53f5
commit 5f452dcf73
5 changed files with 109 additions and 10 deletions

View File

@@ -221,6 +221,7 @@
<button
class="text-sm bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-2 py-1.5 rounded-md border border-blue-400"
@click="openOfferDialog(contact.did, contact.name)"
data-testId="offerButton"
>
Offer
</button>

View File

@@ -206,7 +206,10 @@
v-if="numNewOffersToUser"
class="bg-gradient-to-b from-green-400 to-green-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] px-4 py-4 rounded-md text-white"
>
<span class="block text-center text-6xl">
<span
class="block text-center text-6xl"
data-testId="newDirectOffersActivityNumber"
>
{{ numNewOffersToUser }}
</span>
<p>new offer{{ numNewOffersToUser === 1 ? "" : "s" }} to you</p>

View File

@@ -25,18 +25,25 @@
:icon="showOffersDetails ? 'chevron-down' : 'chevron-right'"
class="cursor-pointer ml-4 text-lg"
@click="expandOffersToUserAndMarkRead()"
data-testid="showOffersToUser"
/>
</div>
<div v-if="showOffersDetails" class="ml-4">
<ul class="list-disc ml-4">
<li v-for="offer in newOffersToUser" :key="offer.id" class="mt-4 relative group">
<li
v-for="offer in newOffersToUser"
:key="offer.id"
class="mt-4 relative group"
>
<span>{{
didInfo(offer.offeredByDid, activeDid, allMyDids, allContacts)
}}</span>
offers
<span v-if="offer.objectDescription">{{ offer.objectDescription }}
</span>{{ offer.objectDescription && offer.amount ? ", and " : "" }}
<span v-if="offer.objectDescription">{{
offer.objectDescription
}}</span
>{{ offer.objectDescription && offer.amount ? ", and " : "" }}
<span v-if="offer.amount">{{
displayAmount(offer.unit, offer.amount)
}}</span>
@@ -67,7 +74,12 @@ import GiftedDialog from "@/components/GiftedDialog.vue";
import QuickNav from "@/components/QuickNav.vue";
import EntityIcon from "@/components/EntityIcon.vue";
import { NotificationIface } from "@/constants/app";
import { accountsDB, db, retrieveSettingsForActiveAccount, updateAccountSettings } from "@/db/index";
import {
accountsDB,
db,
retrieveSettingsForActiveAccount,
updateAccountSettings,
} from "@/db/index";
import { Contact } from "@/db/tables/contacts";
import {
didInfo,
@@ -151,7 +163,9 @@ export default class NewActivityView extends Vue {
}
async markOffersAsReadStartingWith(jwtId: string) {
const index = this.newOffersToUser.findIndex(offer => offer.jwtId === jwtId);
const index = this.newOffersToUser.findIndex(
(offer) => offer.jwtId === jwtId,
);
if (index !== -1 && index < this.newOffersToUser.length - 1) {
// Set to the next offer's jwtId
await updateAccountSettings(this.activeDid, {