Browse Source

fix tests (from project-page switch 4 commits ago) and fix linting

Trent Larson 3 weeks ago
parent
commit
93ed4657ad
  1. 7
      src/libs/endorserServer.ts
  2. 4
      src/views/DIDView.vue
  3. 4
      src/views/DiscoverView.vue
  4. 26
      src/views/HomeView.vue
  5. 35
      src/views/NewActivityView.vue
  6. 7
      test-playwright/20-create-project.spec.ts
  7. 6
      test-playwright/25-create-project-x10.spec.ts
  8. 3
      test-playwright/50-record-offer.spec.ts

7
src/libs/endorserServer.ts

@ -587,7 +587,12 @@ export async function setPlanInCache(
planCache.set(handleId, planSummary); planCache.set(handleId, planSummary);
} }
export async function getNewOffersToUser(axios: Axios, apiServer: string, activeDid: string, lastAckedOfferToUserJwtId?: string) { export async function getNewOffersToUser(
axios: Axios,
apiServer: string,
activeDid: string,
lastAckedOfferToUserJwtId?: string,
) {
let url = `${apiServer}/api/v2/report/offers?recipientDid=${activeDid}`; let url = `${apiServer}/api/v2/report/offers?recipientDid=${activeDid}`;
if (lastAckedOfferToUserJwtId) { if (lastAckedOfferToUserJwtId) {
url += "&afterId=" + lastAckedOfferToUserJwtId; url += "&afterId=" + lastAckedOfferToUserJwtId;

4
src/views/DIDView.vue

@ -200,7 +200,9 @@
</div> </div>
<!-- Results List --> <!-- Results List -->
<div v-if="claims.length > 0" class="mt-4"> <div v-if="claims.length > 0" class="mt-4">
<div class="text-l font-bold text-center">Claims That Involve {{ isMyDid ? "You" : "Them" }}</div> <div class="text-l font-bold text-center">
Claims That Involve {{ isMyDid ? "You" : "Them" }}
</div>
</div> </div>
<InfiniteScroll @reached-bottom="loadMoreData"> <InfiniteScroll @reached-bottom="loadMoreData">
<ul> <ul>

4
src/views/DiscoverView.vue

@ -99,9 +99,7 @@
<div v-else-if="projects.length === 0" class="text-center mt-8"> <div v-else-if="projects.length === 0" class="text-center mt-8">
<p class="text-lg text-slate-500"> <p class="text-lg text-slate-500">
<span v-if="isLocalActive"> <span v-if="isLocalActive">
<span v-if="searchBox"> <span v-if="searchBox"> None found in the selected area. </span>
None found in the selected area.
</span>
<!-- Otherwise there's no search area selected so we'll just leave the search box for them to click. --> <!-- Otherwise there's no search area selected so we'll just leave the search box for them to click. -->
</span> </span>
<span v-else>No projects were found with that search.</span> <span v-else>No projects were found with that search.</span>

26
src/views/HomeView.vue

@ -113,9 +113,7 @@
<!-- show the actions for recognizing a give --> <!-- show the actions for recognizing a give -->
<div class="flex"> <div class="flex">
<h2 class="text-xl font-bold"> <h2 class="text-xl font-bold">What have you seen someone do?</h2>
What have you seen someone do?
</h2>
<button <button
@click="openGiftedPrompts()" @click="openGiftedPrompts()"
class="ml-2 block text-xs text-center bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1 rounded-md" class="ml-2 block text-xs text-center bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1 rounded-md"
@ -179,7 +177,8 @@
<!-- Results List --> <!-- Results List -->
<div class="bg-slate-100 rounded-md px-4 py-3 mt-4 mb-4"> <div class="bg-slate-100 rounded-md px-4 py-3 mt-4 mb-4">
<div class="flex items-center mb-4"> <div class="flex items-center mb-4">
<h2 class="text-xl font-bold">Latest Activity <h2 class="text-xl font-bold">
Latest Activity
<button @click="openFeedFilters()"> <button @click="openFeedFilters()">
<span class="text-xs text-white"> <span class="text-xs text-white">
<fa <fa
@ -210,15 +209,11 @@
<span class="block text-center text-6xl"> <span class="block text-center text-6xl">
{{ numNewOffersToUser }} {{ numNewOffersToUser }}
</span> </span>
<p> <p>new offer{{ numNewOffersToUser === 1 ? "" : "s" }} to you</p>
new offer{{ numNewOffersToUser === 1 ? "" : "s" }} to you
</p>
</div> </div>
</div> </div>
<div class="flex justify-end mt-2"> <div class="flex justify-end mt-2">
<button class="text-blue-500"> <button class="text-blue-500">View All New Activity For You</button>
View All New Activity For You
</button>
</div> </div>
</div> </div>
@ -511,9 +506,14 @@ export default class HomeView extends Vue {
this.updateAllFeed(); this.updateAllFeed();
if (this.activeDid) { if (this.activeDid) {
this.numNewOffersToUser = this.numNewOffersToUser = (
(await getNewOffersToUser(this.axios, this.apiServer, this.activeDid, this.lastAckedOfferToUserJwtId)) await getNewOffersToUser(
.length; this.axios,
this.apiServer,
this.activeDid,
this.lastAckedOfferToUserJwtId,
)
).length;
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any

35
src/views/NewActivityView.vue

@ -4,7 +4,7 @@
<section id="Content" class="p-6 pb-24 max-w-3xl mx-auto"> <section id="Content" class="p-6 pb-24 max-w-3xl mx-auto">
<!-- Breadcrumb --> <!-- Breadcrumb -->
<div id="ViewBreadcrumb" class="mb-8"> <div id="ViewBreadcrumb" class="mb-8">
<h1 class="text-lg text-center font-light relative px-7" > <h1 class="text-lg text-center font-light relative px-7">
<!-- Back --> <!-- Back -->
<fa <fa
icon="chevron-left" icon="chevron-left"
@ -31,11 +31,18 @@
<div v-if="showOffersDetails" class="ml-4"> <div v-if="showOffersDetails" class="ml-4">
<ul> <ul>
<li v-for="offer in newOffersToUser" :key="offer.id" class="mt-2"> <li v-for="offer in newOffersToUser" :key="offer.id" class="mt-2">
<span>{{ didInfo(offer.offeredByDid, activeDid, allMyDids, allContacts) }}</span> <span>{{
didInfo(offer.offeredByDid, activeDid, allMyDids, allContacts)
}}</span>
offers offers
<span v-if="offer.description">{{ offer.description }}</span> <span v-if="offer.description">{{ offer.description }}</span>
<span v-if="offer.amount">{{ displayAmount(offer.unit, offer.amount) }}</span> <span v-if="offer.amount">{{
<router-link :to="{ path: '/claim/' + encodeURIComponent(offer.jwtId) }" class="text-blue-500"> displayAmount(offer.unit, offer.amount)
}}</span>
<router-link
:to="{ path: '/claim/' + encodeURIComponent(offer.jwtId) }"
class="text-blue-500"
>
<fa icon="file-lines" class="pl-2 text-blue-500 cursor-pointer" /> <fa icon="file-lines" class="pl-2 text-blue-500 cursor-pointer" />
</router-link> </router-link>
</li> </li>
@ -46,7 +53,6 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router";
import GiftedDialog from "@/components/GiftedDialog.vue"; import GiftedDialog from "@/components/GiftedDialog.vue";
import QuickNav from "@/components/QuickNav.vue"; import QuickNav from "@/components/QuickNav.vue";
@ -54,7 +60,12 @@ import EntityIcon from "@/components/EntityIcon.vue";
import { NotificationIface } from "@/constants/app"; import { NotificationIface } from "@/constants/app";
import { accountsDB, db, retrieveSettingsForActiveAccount } from "@/db/index"; import { accountsDB, db, retrieveSettingsForActiveAccount } from "@/db/index";
import { Contact } from "@/db/tables/contacts"; import { Contact } from "@/db/tables/contacts";
import { didInfo,displayAmount, getNewOffersToUser, OfferSummaryRecord } from "@/libs/endorserServer"; import {
didInfo,
displayAmount,
getNewOffersToUser,
OfferSummaryRecord,
} from "@/libs/endorserServer";
@Component({ @Component({
components: { GiftedDialog, QuickNav, EntityIcon }, components: { GiftedDialog, QuickNav, EntityIcon },
@ -88,8 +99,12 @@ export default class NewActivityView extends Vue {
if (allAccounts.length > 0) { if (allAccounts.length > 0) {
this.allMyDids = allAccounts.map((acc) => acc.did); this.allMyDids = allAccounts.map((acc) => acc.did);
} }
this.newOffersToUser = this.newOffersToUser = await getNewOffersToUser(
await getNewOffersToUser(this.axios, this.apiServer, this.activeDid, this.lastAckedOfferToUserJwtId); this.axios,
this.apiServer,
this.activeDid,
this.lastAckedOfferToUserJwtId,
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) { } catch (err: any) {
@ -99,9 +114,7 @@ export default class NewActivityView extends Vue {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: text: err.message || "There was an error retrieving your activity.",
err.message ||
"There was an error retrieving your activity.",
}, },
5000, 5000,
); );

7
test-playwright/20-create-project.spec.ts

@ -48,8 +48,8 @@ test('Create new project, then search for it', async ({ page }) => {
// Create new project // Create new project
await page.goto('./projects'); await page.goto('./projects');
await page.getByTestId('closeOnboardingAndFinish').click(); // close onboarding, but not with a click to go to the main screen
await page.getByRole('link', { name: 'Projects', exact: true }).click(); await page.locator('div > svg.fa-xmark').click();
await page.locator('button > svg.fa-plus').click(); await page.locator('button > svg.fa-plus').click();
await page.getByPlaceholder('Idea Name').fill(finalTitle); await page.getByPlaceholder('Idea Name').fill(finalTitle);
await page.getByPlaceholder('Description').fill(finalDescription); await page.getByPlaceholder('Description').fill(finalDescription);
@ -64,8 +64,7 @@ test('Create new project, then search for it', async ({ page }) => {
// Search for newly-created project in /projects // Search for newly-created project in /projects
await page.goto('./projects'); await page.goto('./projects');
await page.getByRole('link', { name: 'Projects', exact: true }).click(); await page.locator('ul#listProjects li').filter({ hasText: finalTitle });
await expect(page.locator('ul#listProjects li').filter({ hasText: finalTitle })).toBeVisible();
// Search for newly-created project in /discover // Search for newly-created project in /discover
await page.goto('./discover'); await page.goto('./discover');

6
test-playwright/25-create-project-x10.spec.ts

@ -43,10 +43,10 @@ test('Create 10 new projects', async ({ page }) => {
for (let i = 0; i < projectCount; i++) { for (let i = 0; i < projectCount; i++) {
await page.goto('./projects'); await page.goto('./projects');
if (i === 0) { if (i === 0) {
await page.getByTestId('closeOnboardingAndFinish').click(); // close onboarding, but not with a click to go to the main screen
await page.locator('div > svg.fa-xmark').click();
} }
await page.getByRole('link', { name: 'Projects', exact: true }).click(); await page.locator('button > svg.fa-plus').click();
await page.getByRole('button').click();
await page.getByPlaceholder('Idea Name').fill(finalTitles[i]); // Add random suffix await page.getByPlaceholder('Idea Name').fill(finalTitles[i]); // Add random suffix
await page.getByPlaceholder('Description').fill(finalDescriptions[i]); await page.getByPlaceholder('Description').fill(finalDescriptions[i]);
await page.getByPlaceholder('Website').fill(standardWebsite); await page.getByPlaceholder('Website').fill(standardWebsite);

3
test-playwright/50-record-offer.spec.ts

@ -27,6 +27,7 @@ test('Record an offer', async ({ page }) => {
// go to the offer and check the values // go to the offer and check the values
await page.goto('./projects'); await page.goto('./projects');
await page.getByRole('link', { name: 'Offers', exact: true }).click();
await page.locator('li').filter({ hasText: description }).locator('a').first().click(); await page.locator('li').filter({ hasText: description }).locator('a').first().click();
await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Verifiable Claim Details' })).toBeVisible();
await expect(page.getByText(description, { exact: true })).toBeVisible(); await expect(page.getByText(description, { exact: true })).toBeVisible();
@ -42,6 +43,7 @@ test('Record an offer', async ({ page }) => {
// find the edit page and check the old values again // find the edit page and check the old values again
await page.goto('./projects'); await page.goto('./projects');
await page.getByRole('link', { name: 'Offers', exact: true }).click();
await page.locator('li').filter({ hasText: description }).locator('a').first().click(); await page.locator('li').filter({ hasText: description }).locator('a').first().click();
await page.getByTestId('editClaimButton').click(); await page.getByTestId('editClaimButton').click();
await page.locator('heading', { hasText: 'What is offered' }).isVisible(); await page.locator('heading', { hasText: 'What is offered' }).isVisible();
@ -57,6 +59,7 @@ test('Record an offer', async ({ page }) => {
// go to the offer claim again and check the updated values // go to the offer claim again and check the updated values
await page.goto('./projects'); await page.goto('./projects');
await page.getByRole('link', { name: 'Offers', exact: true }).click();
await page.locator('li').filter({ hasText: description }).locator('a').first().click(); await page.locator('li').filter({ hasText: description }).locator('a').first().click();
const newItemDesc = await page.getByTestId('description'); const newItemDesc = await page.getByTestId('description');
await expect(newItemDesc).toHaveText(updatedDescription); await expect(newItemDesc).toHaveText(updatedDescription);

Loading…
Cancel
Save