Skip to content

Commit

Permalink
[studio] rename user to profile #1520 (#1521)
Browse files Browse the repository at this point in the history
studio - rename user to profile
  • Loading branch information
janavlachova authored Jan 26, 2025
1 parent c2d3fc4 commit e9d1c4e
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion agdb_studio/src/components/auth/LoginForm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { loginMock, logoutMock, pushMock, currentRoute } = vi.hoisted(() => {
};
});

vi.mock("@/composables/user/auth", () => {
vi.mock("@/composables/profile/auth", () => {
return {
useAuth: () => ({
login: loginMock,
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/components/auth/LoginForm.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { ref } from "vue";
import { useAuth } from "@/composables/user/auth";
import { useAuth } from "@/composables/profile/auth";
import router from "@/router";
import SpinnerIcon from "@/components/base/icons/SpinnerIcon.vue";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, it, expect, vi } from "vitest";
import { mount } from "@vue/test-utils";
import UserDropdown from "./UserDropdown.vue";
import ProfileDropdown from "./ProfileDropdown.vue";
import DropdownContent from "../base/dropdown/DropdownContent.vue";

vi.mock("@/composables/user/account", () => {
vi.mock("@/composables/profile/account", () => {
return {
useAccount: () => ({
username: "testUser",
Expand All @@ -12,14 +12,14 @@ vi.mock("@/composables/user/account", () => {
};
});

describe("UserDropdown", () => {
describe("ProfileDropdown", () => {
it("renders", () => {
const wrapper = mount(UserDropdown);
const wrapper = mount(ProfileDropdown);
expect(wrapper.text()).toContain("testUser");
});

it("should open and close on click", async () => {
const wrapper = mount(UserDropdown);
const wrapper = mount(ProfileDropdown);
const trigger = wrapper.find(".trigger");
const dropdown = wrapper.findComponent(DropdownContent);
expect(dropdown.isVisible()).toBe(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts" setup>
import { useAccount } from "@/composables/user/account";
import { useAccount } from "@/composables/profile/account";
import AgdbDropdown from "../base/dropdown/AgdbDropdown.vue";
import { ClUser02 } from "@kalimahapps/vue-icons";
import UserMenu from "./UserMenu.vue";
import ProfileMenu from "./ProfileMenu.vue";
const { username } = useAccount();
</script>
Expand All @@ -16,7 +16,7 @@ const { username } = useAccount();
</div>
</template>
<template #content>
<UserMenu />
<ProfileMenu />
</template>
</AgdbDropdown>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { mount } from "@vue/test-utils";
import useModal from "@/composables/modal/modal";
import UserMenu from "./UserMenu.vue";
import ProfileMenu from "./ProfileMenu.vue";
import { user_change_password } from "@/tests/apiMock";
import { useContentInputs } from "@/composables/content/inputs";
import { KEY_MODAL } from "@/composables/modal/constants";
Expand All @@ -12,15 +12,15 @@ const { logout } = vi.hoisted(() => {
};
});

vi.mock("@/composables/user/auth", () => {
vi.mock("@/composables/profile/auth", () => {
return {
useAuth: () => ({
logout,
}),
};
});

vi.mock("@/composables/user/account", () => {
vi.mock("@/composables/profile/account", () => {
return {
useAccount: () => ({
username: "testUser",
Expand All @@ -32,19 +32,19 @@ vi.mock("@/composables/user/account", () => {
const { modalIsVisible, closeModal, handleConfirm, onConfirm } = useModal();
const { setInputValue } = useContentInputs();

describe("UserDropdown", () => {
describe("ProfileDropdown", () => {
beforeEach(() => {
vi.clearAllMocks();
closeModal();
});
it("renders the user actions", () => {
const wrapper = mount(UserMenu);
const wrapper = mount(ProfileMenu);
expect(wrapper.text()).toContain("Change password");
expect(wrapper.text()).toContain("Logout");
});

it("should logout on click", async () => {
const wrapper = mount(UserMenu);
const wrapper = mount(ProfileMenu);
const logoutElement = wrapper.find(".menu-item[data-key=logout]");
logoutElement.trigger("click");
await wrapper.vm.$nextTick();
Expand All @@ -55,7 +55,7 @@ describe("UserDropdown", () => {
});

it("should open the change password modal on click", async () => {
const wrapper = mount(UserMenu);
const wrapper = mount(ProfileMenu);
const changePasswordElement = wrapper.find(
".menu-item[data-key=change-password]",
);
Expand All @@ -66,7 +66,7 @@ describe("UserDropdown", () => {
});

it("should change password on confirm", async () => {
const wrapper = mount(UserMenu);
const wrapper = mount(ProfileMenu);
const changePasswordElement = wrapper.find(
".menu-item[data-key=change-password]",
);
Expand All @@ -83,7 +83,7 @@ describe("UserDropdown", () => {
});

it("should check the length of the new password", async () => {
const wrapper = mount(UserMenu);
const wrapper = mount(ProfileMenu);
const changePasswordElement = wrapper.find(
".menu-item[data-key=change-password]",
);
Expand All @@ -101,7 +101,7 @@ describe("UserDropdown", () => {
});

it("should check the match of the new password", async () => {
const wrapper = mount(UserMenu);
const wrapper = mount(ProfileMenu);
const changePasswordElement = wrapper.find(
".menu-item[data-key=change-password]",
);
Expand All @@ -119,7 +119,7 @@ describe("UserDropdown", () => {
});

it("should check the match of new password also in the confirm", async () => {
const wrapper = mount(UserMenu);
const wrapper = mount(ProfileMenu);
const changePasswordElement = wrapper.find(
".menu-item[data-key=change-password]",
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts" setup>
import AgdbMenu from "../base/menu/AgdbMenu.vue";
import { useUserActions } from "@/composables/user/userActions";
import { useUserActions } from "@/composables/profile/profileActions";
const { actions } = useUserActions();
</script>
<template>
<div class="user-dropdown-content">
<div class="profile-dropdown-content">
<AgdbMenu :actions="actions" />
</div>
</template>
4 changes: 2 additions & 2 deletions agdb_studio/src/components/layouts/MainLayout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { loginMock, isLoggedInMock, logoutMock } = vi.hoisted(() => {
};
});

vi.mock("@/composables/user/auth", () => {
vi.mock("@/composables/profile/auth", () => {
return {
useAuth: () => ({
login: loginMock,
Expand All @@ -26,7 +26,7 @@ vi.mock("@/composables/user/auth", () => {

const isAdminView = ref(false);

vi.mock("@/composables/user/admin", () => {
vi.mock("@/composables/profile/admin", () => {
return {
useAdmin: () => ({
isAdminView,
Expand Down
6 changes: 3 additions & 3 deletions agdb_studio/src/components/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import LogoIcon from "@/components/base/icons/LogoIcon.vue";
import AgdbModal from "@/components/base/modal/AgdbModal.vue";
import FadeTransition from "@/components/transitions/FadeTransition.vue";
import NotificationViewer from "../notification/NotificationViewer.vue";
import UserDropdown from "../header/UserDropdown.vue";
import ProfileDropdown from "../header/ProfileDropdown.vue";
import { computed } from "vue";
import { useAdmin } from "@/composables/user/admin";
import { useAdmin } from "@/composables/profile/admin";
const { isAdminView } = useAdmin();
Expand Down Expand Up @@ -40,7 +40,7 @@ const links = computed(() => {
>{{ link.text }}</RouterLink
>
</nav>
<UserDropdown />
<ProfileDropdown />
</div>
</header>
<main>
Expand Down
4 changes: 2 additions & 2 deletions agdb_studio/src/composables/db/dbActions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const { username, isAdmin, isAdminView } = vi.hoisted(() => {
isAdminView: { value: false },
};
});
vi.mock("../user/account", () => {
vi.mock("@/composables/profile/account", () => {
return {
useAccount: () => {
return {
Expand All @@ -56,7 +56,7 @@ vi.mock("../user/account", () => {
};
});

vi.mock("@/composables/user/admin", () => {
vi.mock("@/composables/profile/admin", () => {
return {
useAdmin: vi.fn().mockReturnValue({
isAdmin,
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/composables/db/dbActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useAdmin } from "../user/admin";
import { useAdmin } from "../profile/admin";
import { checkClient, client } from "@/services/api.service";
import type {
Components,
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/composables/db/dbConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { isAdmin, isAdminView } = vi.hoisted(() => {
isAdminView: { value: false },
};
});
vi.mock("@/composables/user/admin", () => {
vi.mock("@/composables/profile/admin", () => {
return {
useAdmin: vi.fn().mockReturnValue({
isAdmin,
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/composables/db/dbConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
dbRename,
dbRestore,
} from "./dbActions";
import { useAdmin } from "../user/admin";
import { useAdmin } from "../profile/admin";
import type { Column, TRow } from "../table/types";

const { getInputValue } = useContentInputs();
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/composables/db/dbStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const { username, admin, dbAdd, dbList } = vi.hoisted(() => {
}),
};
});
vi.mock("../user/account", () => {
vi.mock("@/composables/profile/account", () => {
return {
useAccount: () => {
return {
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/composables/db/dbStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ref } from "vue";
import type { DbType, ServerDatabase } from "agdb_api/dist/openapi";
import { useAccount } from "../user/account";
import { useAccount } from "../profile/account";
import { addNotification } from "../notification/notificationStore";
import type { AxiosResponse } from "axios";
import type { DbIdentification } from "./types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { isLoggedIn, token } = vi.hoisted(() => {
token: { value: "test" },
};
});
vi.mock("@/composables/user/auth", () => {
vi.mock("@/composables/profile/auth", () => {
return {
useAuth: vi.fn().mockReturnValue({
isLoggedIn,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { client } from "@/services/api.service";
import { useAuth } from "@/composables/user/auth";
import { useAuth } from "@/composables/profile/auth";
import { ref, watch } from "vue";

const username = ref<string | undefined>(undefined);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vi, describe, it, beforeEach, expect } from "vitest";
import { useAdmin } from "./admin";
import { triggerRef } from "vue";
import { useAccount } from "@/composables/user/account";
import { useAccount } from "@/composables/profile/account";

import router from "@/router";

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
USER_VIEW_KEY,
CHANGE_PASSWORD_KEY,
LOGOUT_KEY,
} from "./userActions";
} from "./profileActions";

const { isAdmin, isAdminView, pushMock } = vi.hoisted(() => {
return {
Expand All @@ -15,7 +15,7 @@ const { isAdmin, isAdminView, pushMock } = vi.hoisted(() => {
};
});

vi.mock("@/composables/user/admin", () => {
vi.mock("@/composables/profile/admin", () => {
return {
useAdmin: vi.fn().mockReturnValue({
isAdmin,
Expand All @@ -32,11 +32,11 @@ vi.mock("@/router", () => {
};
});

describe("userActions.ts", () => {
describe("profileActions.ts", () => {
beforeEach(() => {
vi.clearAllMocks();
});
it("returns the user actions when admin in user screen", () => {
it("returns the profile actions when admin in user screen", () => {
isAdmin.value = true;
isAdminView.value = false;
const { actions } = useUserActions();
Expand All @@ -55,7 +55,7 @@ describe("userActions.ts", () => {
);
});

it("returns the user actions when admin in admin screen", () => {
it("returns the profile actions when admin in admin screen", () => {
isAdmin.value = true;
isAdminView.value = true;
const { actions } = useUserActions();
Expand All @@ -74,7 +74,7 @@ describe("userActions.ts", () => {
);
});

it("returns the user actions when not admin in user screen", () => {
it("returns the profile actions when not admin in user screen", () => {
isAdmin.value = false;
isAdminView.value = false;
const { actions } = useUserActions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { convertArrayOfStringsToContent } from "../content/utils";
import { client } from "@/services/api.service";
import { KEY_MODAL } from "../modal/constants";
import { computed } from "vue";
import { useAdmin } from "@/composables/user/admin";
import { useAdmin } from "@/composables/profile/admin";

const { logout } = useAuth();
const { openModal } = useModal();
Expand Down
4 changes: 2 additions & 2 deletions agdb_studio/src/router/router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { isLoggedInMock, logoutMock, admin, fetchUserStatus } = vi.hoisted(
},
);

vi.mock("@/composables/user/auth", () => {
vi.mock("@/composables/profile/auth", () => {
return {
useAuth: () => ({
isLoggedIn: isLoggedInMock,
Expand All @@ -22,7 +22,7 @@ vi.mock("@/composables/user/auth", () => {
};
});

vi.mock("@/composables/user/account", () => {
vi.mock("@/composables/profile/account", () => {
return {
useAccount: () => ({
admin,
Expand Down
4 changes: 2 additions & 2 deletions agdb_studio/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
type RouteLocationNormalizedGeneric,
} from "vue-router";
import { createRoutes } from "./routes";
import { useAuth } from "@/composables/user/auth";
import { useAccount } from "@/composables/user/account";
import { useAuth } from "@/composables/profile/auth";
import { useAccount } from "@/composables/profile/account";

const { isLoggedIn } = useAuth();
const { admin, fetchUserStatus } = useAccount();
Expand Down

0 comments on commit e9d1c4e

Please sign in to comment.