Skip to content

Commit

Permalink
Merge pull request #521 from MuckRock/sveltekit-addonlistitemtest
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser authored Apr 23, 2024
2 parents 83afd29 + 692a99e commit eda5669
Show file tree
Hide file tree
Showing 6 changed files with 582 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/lib/components/addons/AddOnListItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { _ } from "svelte-i18n";
import AddOnPin from "@/addons/AddOnPin.svelte";
import AddOnPopularity from "@/addons/Popularity.svelte";
import PremiumBadge from "@/premium-credits/PremiumBadge.svelte";
export let addon: AddOnListItem;
Expand Down Expand Up @@ -35,11 +34,8 @@
>
</p>
{/if}
{#if addon.usage}
<AddOnPopularity useCount={addon.usage} />
{/if}
{#if isPremium}
<span class="badge"><PremiumBadge /></span>
<span class="badge" role="status"><PremiumBadge /></span>
{/if}
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/addons/AddOnsNavigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
href={`/app/add-ons?category=${key}`}
active={active === key}
>
<!-- <Hash16 fill="var(--gray-4)" /> -->
{label}
</SidebarItem>
{/each}
Expand Down
13 changes: 13 additions & 0 deletions src/lib/components/addons/tests/AddOnListItem.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { test, expect } from "vitest";
import { render } from "@testing-library/svelte";
import AddOnListItem from "../AddOnListItem.svelte";
import { addon, premiumAddon } from "@/test/fixtures/addons";

test("AddOnListItem", () => {
const result = render(AddOnListItem, { addon });
expect(result.getByRole("heading")).toHaveTextContent(addon.name);
expect(result.container).toMatchSnapshot();
const premium = render(AddOnListItem, { addon: premiumAddon });
expect(premium.getByRole("status")).toHaveTextContent("Premium");
expect(premium.container).toMatchSnapshot();
});
8 changes: 8 additions & 0 deletions src/lib/components/addons/tests/AddOnsNavigation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { test, expect } from "vitest";
import { render } from "@testing-library/svelte";
import AddOnsNavigation from "../AddOnsNavigation.svelte";

test("AddOnsNavigation", () => {
const result = render(AddOnsNavigation);
expect(result.container).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`AddOnListItem 1`] = `
<body>
<div>
<a
class="addon-link s-d6GYPCW87h6p"
href="/app/add-ons/MuckRock/documentcloud-bulk-edit-addon"
>
<div
class="container s-d6GYPCW87h6p"
id="MuckRock/documentcloud-bulk-edit-addon"
>
<div
class="row s-d6GYPCW87h6p"
>
<div
class="center-self s-d6GYPCW87h6p"
>
<div
style="display: contents; --fill: var(--gray-3);"
>
<button
class="pin s-aZevVea-K27J"
style="--padding:0.25em; --border-radius:4px;"
>
<svg
class="s-TuslcW8XKaBT"
height="16px"
viewBox="0 0 16 16"
width="16px"
>
<title
class="s-TuslcW8XKaBT"
>
Click to Pin
</title>
<path
class="s-TuslcW8XKaBT"
d="M3.00220543,1 C3.00220543,0.446875 3.44891524,0 4.00183577,0 L11.9988785,0 C12.551799,0 12.9985088,0.446875 12.9985088,1 C12.9985088,1.553125 12.551799,2 11.9988785,2 L11.0773442,2 L11.4334625,6.63125 C12.5799136,7.253125 13.4858286,8.29375 13.9169192,9.590625 L13.9481576,9.684375 C14.0512445,9.990625 13.9981391,10.325 13.8107084,10.584375 C13.6232777,10.84375 13.3202648,11 12.9985088,11 L3.00220543,11 C2.68044942,11 2.38056032,10.846875 2.19000578,10.584375 C1.99945125,10.321875 1.94946973,9.9875 2.05255661,9.684375 L2.08379506,9.590625 C2.51488564,8.29375 3.42080063,7.253125 4.56725167,6.63125 L4.92336998,2 L4.00183577,2 C3.44891524,2 3.00220543,1.553125 3.00220543,1 Z M7.00072677,12 L8.99998744,12 L8.99998744,15 C8.99998744,15.553125 8.55327764,16 8.00035711,16 C7.44743658,16 7.00072677,15.553125 7.00072677,15 L7.00072677,12 Z"
fill-rule="nonzero"
/>
</svg>
<!--&lt;Pin&gt;-->
</button>
<!--&lt;Pin&gt;-->
</div>
<!--&lt;AddOnPin&gt;-->
</div>
<div
class="stretch s-d6GYPCW87h6p"
>
<h3
class="addon-name s-d6GYPCW87h6p"
>
Bulk Edit
</h3>
</div>
<div
class="metadata s-d6GYPCW87h6p"
>
<p
class="author s-d6GYPCW87h6p"
>
<a
class="s-d6GYPCW87h6p"
href="http://github.com/MuckRock/documentcloud-bulk-edit-addon"
rel="noopener noreferrer"
target="_blank"
title="View Source"
>
MuckRock
</a>
</p>
</div>
</div>
<div
class="description s-d6GYPCW87h6p"
>
This will update document information for all documents in your current search. Please be sure you have edit access to these documents before running this add-on.
</div>
</div>
</a>
<!--&lt;AddOnListItem&gt;-->
</div>
</body>
`;

exports[`AddOnListItem 2`] = `
<body>
<div>
<a
class="addon-link s-d6GYPCW87h6p"
href="/app/add-ons/MuckRock/documentcloud-bulk-edit-addon"
>
<div
class="container s-d6GYPCW87h6p"
id="MuckRock/documentcloud-bulk-edit-addon"
>
<div
class="row s-d6GYPCW87h6p"
>
<div
class="center-self s-d6GYPCW87h6p"
>
<div
style="display: contents; --fill: var(--gray-3);"
>
<button
class="pin s-aZevVea-K27J"
style="--padding:0.25em; --border-radius:4px;"
>
<svg
class="s-TuslcW8XKaBT"
height="16px"
viewBox="0 0 16 16"
width="16px"
>
<title
class="s-TuslcW8XKaBT"
>
Click to Pin
</title>
<path
class="s-TuslcW8XKaBT"
d="M3.00220543,1 C3.00220543,0.446875 3.44891524,0 4.00183577,0 L11.9988785,0 C12.551799,0 12.9985088,0.446875 12.9985088,1 C12.9985088,1.553125 12.551799,2 11.9988785,2 L11.0773442,2 L11.4334625,6.63125 C12.5799136,7.253125 13.4858286,8.29375 13.9169192,9.590625 L13.9481576,9.684375 C14.0512445,9.990625 13.9981391,10.325 13.8107084,10.584375 C13.6232777,10.84375 13.3202648,11 12.9985088,11 L3.00220543,11 C2.68044942,11 2.38056032,10.846875 2.19000578,10.584375 C1.99945125,10.321875 1.94946973,9.9875 2.05255661,9.684375 L2.08379506,9.590625 C2.51488564,8.29375 3.42080063,7.253125 4.56725167,6.63125 L4.92336998,2 L4.00183577,2 C3.44891524,2 3.00220543,1.553125 3.00220543,1 Z M7.00072677,12 L8.99998744,12 L8.99998744,15 C8.99998744,15.553125 8.55327764,16 8.00035711,16 C7.44743658,16 7.00072677,15.553125 7.00072677,15 L7.00072677,12 Z"
fill-rule="nonzero"
/>
</svg>
<!--&lt;Pin&gt;-->
</button>
<!--&lt;Pin&gt;-->
</div>
<!--&lt;AddOnPin&gt;-->
</div>
<div
class="stretch s-d6GYPCW87h6p"
>
<h3
class="addon-name s-d6GYPCW87h6p"
>
Bulk Edit
</h3>
</div>
<div
class="metadata s-d6GYPCW87h6p"
>
<p
class="author s-d6GYPCW87h6p"
>
<a
class="s-d6GYPCW87h6p"
href="http://github.com/MuckRock/documentcloud-bulk-edit-addon"
rel="noopener noreferrer"
target="_blank"
title="View Source"
>
MuckRock
</a>
</p>
</div>
</div>
<div
class="description s-d6GYPCW87h6p"
>
This will update document information for all documents in your current search. Please be sure you have edit access to these documents before running this add-on.
</div>
</div>
</a>
<!--&lt;AddOnListItem&gt;-->
</div>
<div>
<a
class="addon-link s-d6GYPCW87h6p"
href="/app/add-ons/MuckRock/documentcloud-azure-document-intelligence-ocr-addon"
>
<div
class="container s-d6GYPCW87h6p"
id="MuckRock/documentcloud-azure-document-intelligence-ocr-addon"
>
<div
class="row s-d6GYPCW87h6p"
>
<div
class="center-self s-d6GYPCW87h6p"
>
<div
style="display: contents; --fill: var(--gray-3);"
>
<button
class="pin s-aZevVea-K27J"
style="--padding:0.25em; --border-radius:4px;"
>
<svg
class="s-TuslcW8XKaBT"
height="16px"
viewBox="0 0 16 16"
width="16px"
>
<title
class="s-TuslcW8XKaBT"
>
Click to Pin
</title>
<path
class="s-TuslcW8XKaBT"
d="M3.00220543,1 C3.00220543,0.446875 3.44891524,0 4.00183577,0 L11.9988785,0 C12.551799,0 12.9985088,0.446875 12.9985088,1 C12.9985088,1.553125 12.551799,2 11.9988785,2 L11.0773442,2 L11.4334625,6.63125 C12.5799136,7.253125 13.4858286,8.29375 13.9169192,9.590625 L13.9481576,9.684375 C14.0512445,9.990625 13.9981391,10.325 13.8107084,10.584375 C13.6232777,10.84375 13.3202648,11 12.9985088,11 L3.00220543,11 C2.68044942,11 2.38056032,10.846875 2.19000578,10.584375 C1.99945125,10.321875 1.94946973,9.9875 2.05255661,9.684375 L2.08379506,9.590625 C2.51488564,8.29375 3.42080063,7.253125 4.56725167,6.63125 L4.92336998,2 L4.00183577,2 C3.44891524,2 3.00220543,1.553125 3.00220543,1 Z M7.00072677,12 L8.99998744,12 L8.99998744,15 C8.99998744,15.553125 8.55327764,16 8.00035711,16 C7.44743658,16 7.00072677,15.553125 7.00072677,15 L7.00072677,12 Z"
fill-rule="nonzero"
/>
</svg>
<!--&lt;Pin&gt;-->
</button>
<!--&lt;Pin&gt;-->
</div>
<!--&lt;AddOnPin&gt;-->
</div>
<div
class="stretch s-d6GYPCW87h6p"
>
<h3
class="addon-name s-d6GYPCW87h6p"
>
Azure Document Intelligence OCR
</h3>
</div>
<div
class="metadata s-d6GYPCW87h6p"
>
<p
class="author s-d6GYPCW87h6p"
>
<a
class="s-d6GYPCW87h6p"
href="http://github.com/MuckRock/documentcloud-azure-document-intelligence-ocr-addon"
rel="noopener noreferrer"
target="_blank"
title="View Source"
>
MuckRock
</a>
</p>
<span
class="badge s-d6GYPCW87h6p"
role="status"
>
<div
class="badge s-mpeCNO6oawgL"
style="--badge-color: transparent; --label-color: var(--premium);"
>
<span
class="icon s-mpeCNO6oawgL"
>
<svg
class="s-OXbz8kfW0Fj9"
height="16px"
viewBox="0 0 16 16"
width="16px"
>
<title
class="s-OXbz8kfW0Fj9"
>
Premium
</title>
<path
class="s-OXbz8kfW0Fj9"
clip-rule="evenodd"
d="M7 1C7 3.76142 4.76142 6 2 6C4.76142 6 7 8.23858 7 11C7 8.23858 9.23858 6 12 6C9.23858 6 7 3.76142 7 1Z"
fill-rule="evenodd"
/>
<path
class="s-OXbz8kfW0Fj9"
clip-rule="evenodd"
d="M11 9C11 10.6569 9.65685 12 8 12C9.65685 12 11 13.3431 11 15C11 13.3431 12.3431 12 14 12C12.3431 12 11 10.6569 11 9Z"
fill-rule="evenodd"
/>
</svg>
<!--&lt;Premium&gt;-->
</span>
<span
class="label s-mpeCNO6oawgL"
>
Premium
</span>
</div>
<!--&lt;Badge&gt;-->
<!--&lt;PremiumBadge&gt;-->
</span>
</div>
</div>
<div
class="description s-d6GYPCW87h6p"
>
<p>
This Add-On uses Azure’s Document Intelligence API to OCR documents. The document(s) must be public to be processed. This Add-On uses 1 AI Credit per page.
</p>
</div>
</div>
</a>
<!--&lt;AddOnListItem&gt;-->
</div>
</body>
`;
Loading

0 comments on commit eda5669

Please sign in to comment.