Browse Source

fix: test errors

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6307/head
mertmit 1 year ago
parent
commit
eb60a02535
  1. 17
      packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue
  2. 3
      packages/nc-gui/components/workspace/CreateProjectDlg.vue
  3. 4
      packages/nc-gui/composables/useGlobal/state.ts
  4. 2
      packages/nc-gui/package-lock.json
  5. 2
      packages/nc-gui/package.json
  6. 13
      packages/nc-gui/pages/index.vue
  7. 1
      packages/nc-gui/store/projects.ts
  8. 7
      packages/nc-gui/store/workspace.ts
  9. 32
      packages/nocodb/package-lock.json
  10. 2
      tests/playwright/pages/Dashboard/Sidebar/UserMenu/index.ts
  11. 1
      tests/playwright/pages/Dashboard/index.ts

17
packages/nc-gui/components/dashboard/Sidebar/UserInfo.vue

@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import GithubButton from 'vue-github-button' import GithubButton from 'vue-github-button'
const { user, signOut, token, appInfo } = useGlobal() const { user, signOut, token, appInfo } = useGlobal()
const { clearWorkspaces } = useWorkspace() const { clearWorkspaces } = useWorkspace()
@ -52,12 +53,22 @@ watch(leftSidebarState, () => {
isMenuOpen.value = false isMenuOpen.value = false
} }
}) })
// This is a hack to prevent github button error (prevents navigateTo if user is not signed in)
const isMounted = ref(false)
onMounted(() => {
isMounted.value = true
})
</script> </script>
<template> <template>
<div class="nc-sidebar-userinfo flex w-full flex-col p-1 border-t-1 border-gray-200 gap-y-2"> <div class="flex w-full flex-col p-1 border-t-1 border-gray-200 gap-y-2">
<NcDropdown v-model:visible="isMenuOpen" placement="topLeft" overlay-class-name="!min-w-64"> <NcDropdown v-model:visible="isMenuOpen" placement="topLeft" overlay-class-name="!min-w-64">
<div class="flex flex-row py-2 px-3 gap-x-2 items-center hover:bg-gray-200 rounded-lg cursor-pointer h-10"> <div
class="flex flex-row py-2 px-3 gap-x-2 items-center hover:bg-gray-200 rounded-lg cursor-pointer h-10"
data-testid="nc-sidebar-userinfo"
>
<GeneralUserIcon /> <GeneralUserIcon />
<div class="flex truncate"> <div class="flex truncate">
{{ name ? name : user?.email }} {{ name ? name : user?.email }}
@ -130,7 +141,7 @@ watch(leftSidebarState, () => {
</NcDropdown> </NcDropdown>
<div v-if="appInfo.ee" class="text-gray-500 text-xs pl-3">© 2023 NocoDB. Inc</div> <div v-if="appInfo.ee" class="text-gray-500 text-xs pl-3">© 2023 NocoDB. Inc</div>
<div v-else class="flex flex-col gap-y-1 pt-1"> <div v-else-if="isMounted" class="flex flex-col gap-y-1 pt-1">
<div class="flex items-start flex-row justify-center px-2 gap-2"> <div class="flex items-start flex-row justify-center px-2 gap-2">
<GithubButton href="https://github.com/nocodb/nocodb" data-icon="octicon-star" data-show-count="true" data-size="large"> <GithubButton href="https://github.com/nocodb/nocodb" data-icon="octicon-star" data-show-count="true" data-size="large">
Star Star

3
packages/nc-gui/components/workspace/CreateProjectDlg.vue

@ -81,9 +81,8 @@ watch(dialogShow, async (n, o) => {
const typeLabel = computed(() => { const typeLabel = computed(() => {
switch (props.type) { switch (props.type) {
case NcProjectType.DB: case NcProjectType.DB:
return 'Database'
default: default:
return '' return 'Database'
} }
}) })
</script> </script>

4
packages/nc-gui/composables/useGlobal/state.ts

@ -78,7 +78,9 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
/** current token ref, used by `useJwt` to reactively parse our token payload */ /** current token ref, used by `useJwt` to reactively parse our token payload */
const token = computed({ const token = computed({
get: () => storage.value.token || '', get: () => storage.value.token || '',
set: (val) => (storage.value.token = val), set: (val) => {
storage.value.token = val
},
}) })
const config = useRuntimeConfig() const config = useRuntimeConfig()

2
packages/nc-gui/package-lock.json generated

@ -54,7 +54,7 @@
"vue-barcode-reader": "^1.0.3", "vue-barcode-reader": "^1.0.3",
"vue-chartjs": "^5.2.0", "vue-chartjs": "^5.2.0",
"vue-dompurify-html": "^3.0.0", "vue-dompurify-html": "^3.0.0",
"vue-github-button": "^3.0.3", "vue-github-button": "^3.1.0",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-qrcode-reader": "3.1.0-vue3-compatibility.2", "vue-qrcode-reader": "3.1.0-vue3-compatibility.2",
"vue3-calendar-heatmap": "^2.0.0", "vue3-calendar-heatmap": "^2.0.0",

2
packages/nc-gui/package.json

@ -77,7 +77,7 @@
"vue-barcode-reader": "^1.0.3", "vue-barcode-reader": "^1.0.3",
"vue-chartjs": "^5.2.0", "vue-chartjs": "^5.2.0",
"vue-dompurify-html": "^3.0.0", "vue-dompurify-html": "^3.0.0",
"vue-github-button": "^3.0.3", "vue-github-button": "^3.1.0",
"vue-i18n": "^9.2.2", "vue-i18n": "^9.2.2",
"vue-qrcode-reader": "3.1.0-vue3-compatibility.2", "vue-qrcode-reader": "3.1.0-vue3-compatibility.2",
"vue3-calendar-heatmap": "^2.0.0", "vue3-calendar-heatmap": "^2.0.0",

13
packages/nc-gui/pages/index.vue

@ -16,6 +16,8 @@ const projectsStore = useProjects()
const { populateWorkspace } = useWorkspace() const { populateWorkspace } = useWorkspace()
const { signedIn } = useGlobal()
const router = useRouter() const router = useRouter()
const route = router.currentRoute const route = router.currentRoute
@ -46,6 +48,17 @@ watch(
return return
} }
// avoid loading projects for shared base
if (route.value.params.typeOrId === 'base') {
await populateWorkspace()
return
}
if (!signedIn.value) {
navigateTo('/signIn')
return
}
// Load projects // Load projects
await populateWorkspace() await populateWorkspace()

1
packages/nc-gui/store/projects.ts

@ -40,7 +40,6 @@ export const useProjects = defineStore('projectsStore', () => {
return basesMap return basesMap
}) })
const workspaceStore = useWorkspace() const workspaceStore = useWorkspace()
const tableStore = useTablesStore() const tableStore = useTablesStore()

7
packages/nc-gui/store/workspace.ts

@ -2,12 +2,11 @@ import type { ProjectType } from 'nocodb-sdk'
import { acceptHMRUpdate, defineStore } from 'pinia' import { acceptHMRUpdate, defineStore } from 'pinia'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { isString } from '@vue/shared' import { isString } from '@vue/shared'
import { computed, navigateTo, ref, useCommandPalette, useNuxtApp, useRouter, useTheme } from '#imports' import { computed, navigateTo, ref, useCommandPalette, useNuxtApp, useProjects, useRouter, useTheme } from '#imports'
import type { ThemeConfig } from '#imports' import type { ThemeConfig } from '#imports'
export const useWorkspace = defineStore('workspaceStore', () => { export const useWorkspace = defineStore('workspaceStore', () => {
const projectsStore = useProjects() const projectsStore = useProjects()
const { clearProjects } = projectsStore
const collaborators = ref<any[] | null>() const collaborators = ref<any[] | null>()
@ -199,8 +198,8 @@ export const useWorkspace = defineStore('workspaceStore', () => {
$e('c:themes:change') $e('c:themes:change')
} }
const clearWorkspaces = async () => { async function clearWorkspaces() {
await clearProjects() await projectsStore.clearProjects()
workspaces.value.clear() workspaces.value.clear()
} }

32
packages/nocodb/package-lock.json generated

@ -98,7 +98,7 @@
"ncp": "^2.0.0", "ncp": "^2.0.0",
"nestjs-kafka": "^1.0.6", "nestjs-kafka": "^1.0.6",
"nestjs-throttler-storage-redis": "^0.3.0", "nestjs-throttler-storage-redis": "^0.3.0",
"nocodb-sdk": "0.111.1", "nocodb-sdk": "file:../nocodb-sdk",
"nodemailer": "^6.4.10", "nodemailer": "^6.4.10",
"object-hash": "^3.0.0", "object-hash": "^3.0.0",
"object-sizeof": "^2.6.1", "object-sizeof": "^2.6.1",
@ -211,7 +211,6 @@
}, },
"../nocodb-sdk": { "../nocodb-sdk": {
"version": "0.111.1", "version": "0.111.1",
"extraneous": true,
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
@ -14383,13 +14382,8 @@
} }
}, },
"node_modules/nocodb-sdk": { "node_modules/nocodb-sdk": {
"version": "0.111.1", "resolved": "../nocodb-sdk",
"resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.111.1.tgz", "link": true
"integrity": "sha512-FS5wyWd3XkPtRkqjO7Hdj5HKsco6/oYc8MPrZ7K/JRmqf0Yf1oydtarkv7h+dDTaNtfcp6Qm56b1JdwJP/EWvg==",
"dependencies": {
"axios": "^0.21.1",
"jsep": "^1.3.6"
}
}, },
"node_modules/node-abort-controller": { "node_modules/node-abort-controller": {
"version": "3.1.1", "version": "3.1.1",
@ -30908,12 +30902,24 @@
"requires": {} "requires": {}
}, },
"nocodb-sdk": { "nocodb-sdk": {
"version": "0.111.1", "version": "file:../nocodb-sdk",
"resolved": "https://registry.npmjs.org/nocodb-sdk/-/nocodb-sdk-0.111.1.tgz",
"integrity": "sha512-FS5wyWd3XkPtRkqjO7Hdj5HKsco6/oYc8MPrZ7K/JRmqf0Yf1oydtarkv7h+dDTaNtfcp6Qm56b1JdwJP/EWvg==",
"requires": { "requires": {
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"axios": "^0.21.1", "axios": "^0.21.1",
"jsep": "^1.3.6" "cspell": "^4.1.0",
"eslint": "^7.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^3.0.2",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-prettier": "^4.0.0",
"jsep": "^1.3.6",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"rimraf": "^5.0.1",
"tsc-alias": "^1.8.7",
"typescript": "^4.7.4"
} }
}, },
"node-abort-controller": { "node-abort-controller": {

2
tests/playwright/pages/Dashboard/Sidebar/UserMenu/index.ts

@ -11,7 +11,7 @@ export class SidebarUserMenuObject extends BasePage {
} }
get() { get() {
return this.sidebar.get().locator(`.nc-sidebar-userinfo`); return this.rootPage.getByTestId('nc-sidebar-userinfo');
} }
async click() { async click() {

1
tests/playwright/pages/Dashboard/index.ts

@ -186,6 +186,7 @@ export class DashboardPage extends BasePage {
async signOut() { async signOut() {
await this.sidebar.userMenu.click(); await this.sidebar.userMenu.click();
await this.rootPage.getByTestId('nc-sidebar-user-logout').waitFor({ state: 'visible' });
await this.sidebar.userMenu.clickLogout(); await this.sidebar.userMenu.clickLogout();
await this.rootPage.locator('[data-testid="nc-form-signin"]:visible').waitFor(); await this.rootPage.locator('[data-testid="nc-form-signin"]:visible').waitFor();
await new Promise(resolve => setTimeout(resolve, 150)); await new Promise(resolve => setTimeout(resolve, 150));

Loading…
Cancel
Save