Skip to content

Commit

Permalink
quick tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Jan 13, 2025
1 parent c23fa05 commit e598635
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
21 changes: 12 additions & 9 deletions src/lib/components/documents/Search.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" context="module">
import { listOrgs, listUsers } from "@/lib/api/accounts";
import { list as listProjects } from "@/lib/api/projects";
import { listOrgs, listUsers } from "$lib/api/accounts";
import { list as listProjects } from "$lib/api/projects";
export interface SearchProps {
query?: string;
Expand Down Expand Up @@ -202,11 +202,14 @@
</script>

<script lang="ts">
import { _ } from "svelte-i18n";
import type { Maybe } from "$lib/api/types";
import { page } from "$app/stores";
import { goto } from "$app/navigation";
import { browser } from "$app/environment";
import type { Maybe } from "$lib/api/types";
import { _ } from "svelte-i18n";
import Search from "../inputs/Search.svelte";
import Filter, { type FilterFields, defaultFilters } from "./Filter.svelte";
import Sort, {
Expand Down Expand Up @@ -254,13 +257,13 @@
}
// We should call the submit function when the search parameters change
$: {
/* $: {
const search = serialize({ query, filters, sort, direction });
if (browser) {
submit(search);
}
}
*/
// DEBUG LOGGING STRINGS: REMOVE BEFORE MERGE
// $: {
// console.log({
Expand All @@ -277,13 +280,13 @@
</script>

<form class="search" bind:this={form} on:submit={handleSearch}>
<div class="text">
<Search name="q" bind:value={query} />
</div>
<div class="controls">
<Filter bind:filters />
<Sort bind:direction bind:sort {fields} />
</div>
<div class="text">
<Search name="q" bind:value={query} />
</div>
</form>

<style>
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/documents/tests/Search.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { vi, describe, it, expect, type Mock } from "vitest";
import { serialize, deserialize, type SearchProps } from "../Search.svelte";
import type { Org, Project, User } from "@/lib/api/types";
import type { Org, Project, User } from "$lib/api/types";
import { organizationsList, usersList } from "@/test/fixtures/accounts";
import { projectList } from "@/test/fixtures/projects";
import { listUsers, listOrgs } from "@/lib/api/accounts";
import { listUsers, listOrgs } from "$lib/api/accounts";

const mockUser = usersList.results[0];
const mockProjects = projectList.results.slice(0, 2);
const mockOrgs = organizationsList.results.slice(0, 2);

vi.mock("@/lib/api/accounts");
vi.mock("$lib/api/accounts");

const mockListOrgs = vi.fn().mockResolvedValue({
data: {
Expand All @@ -31,7 +31,7 @@ const mockListUsers = vi.fn().mockResolvedValue({
vi.mocked(listOrgs).mockImplementation(mockListOrgs);
vi.mocked(listUsers).mockImplementation(mockListUsers);

vi.mock("@/lib/api/projects", () => ({
vi.mock("$lib/api/projects", () => ({
list: () =>
Promise.resolve({
data: {
Expand Down

0 comments on commit e598635

Please sign in to comment.