Browse Source

fix: Fixed tests issues with view sidebar removal

pull/6444/head
Muhammed Mustafa 1 year ago
parent
commit
f6948d8564
  1. 14
      packages/nc-gui/components/smartsheet/grid/GroupBy.vue
  2. 2
      packages/nc-gui/pages/index/[typeOrId]/[projectId]/index/index/index.vue
  3. 4
      packages/nc-gui/pages/index/[typeOrId]/view/[viewId].vue
  4. 4
      packages/nc-gui/store/tables.ts
  5. 2
      tests/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts
  6. 10
      tests/playwright/pages/Dashboard/TreeView.ts
  7. 2
      tests/playwright/pages/Dashboard/common/Cell/index.ts
  8. 26
      tests/playwright/pages/Dashboard/common/Topbar/Share.ts
  9. 9
      tests/playwright/pages/Dashboard/common/Topbar/index.ts
  10. 2
      tests/playwright/pages/SharedForm/index.ts
  11. 4
      tests/playwright/tests/db/features/baseShare.spec.ts

14
packages/nc-gui/components/smartsheet/grid/GroupBy.vue

@ -30,6 +30,8 @@ const emits = defineEmits(['update:paginationData'])
const vGroup = useVModel(props, 'group', emits)
const { isViewDataLoading, isPaginationLoading } = storeToRefs(useViewsStore())
const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())
const _depth = props.depth ?? 0
@ -85,13 +87,19 @@ reloadViewDataHook?.on(reloadViewDataHandler)
watch(
[() => vGroup.value.key],
(n, o) => {
async (n, o) => {
if (n !== o) {
isViewDataLoading.value = true
isPaginationLoading.value = true
if (vGroup.value.nested) {
props.loadGroups({}, vGroup.value)
await props.loadGroups({}, vGroup.value)
} else {
props.loadGroupData(vGroup.value, true)
await props.loadGroupData(vGroup.value, true)
}
isViewDataLoading.value = false
isPaginationLoading.value = false
}
},
{ immediate: true },

2
packages/nc-gui/pages/index/[typeOrId]/[projectId]/index/index/index.vue

@ -112,7 +112,7 @@ function openQuickImportDialog(type: QuickImportTypes, file: File) {
}
watch(
() => project.value.id,
() => project.value?.id,
() => {
if (project.value?.id && project.value.type === 'database') {
const { addTab } = useTabs()

4
packages/nc-gui/pages/index/[typeOrId]/view/[viewId].vue

@ -10,7 +10,7 @@ definePageMeta({
const route = useRoute()
const { loadSharedView } = useSharedView()
const { loadSharedView, meta } = useSharedView()
const { isViewDataLoading } = storeToRefs(useViewsStore())
const showPassword = ref(false)
@ -37,5 +37,5 @@ onMounted(async () => {
<LazySharedViewAskPassword v-model="showPassword" />
</div>
<LazySharedViewGrid v-else />
<LazySharedViewGrid v-else-if="meta" />
</template>

4
packages/nc-gui/store/tables.ts

@ -63,14 +63,10 @@ export const useTablesStore = defineStore('tablesStore', () => {
)
const loadProjectTables = async (projectId: string, force = false) => {
const projects = projectsStore.projects
if (!force && projectTables.value.get(projectId)) {
return
}
const workspaceProject = projects.get(projectId)
if (!workspaceProject) throw new Error('Project not found')
const existingTables = projectTables.value.get(projectId)
if (existingTables && !force) {
return

2
tests/playwright/pages/Dashboard/Grid/Column/LTAR/LinkRecord.ts

@ -24,7 +24,7 @@ export class LinkRecord extends BasePage {
{
const childList = linkRecord.getByTestId(`nc-excluded-list-item`);
expect.poll(() => linkRecord.getByTestId(`nc-excluded-list-item`).count()).toBe(cardTitle.length);
await expect.poll(() => linkRecord.getByTestId(`nc-excluded-list-item`).count()).toBe(cardTitle.length);
for (let i = 0; i < cardTitle.length; i++) {
await childList.nth(i).locator('.nc-display-value').scrollIntoViewIfNeeded();
await childList.nth(i).locator('.nc-display-value').waitFor({ state: 'visible' });

10
tests/playwright/pages/Dashboard/TreeView.ts

@ -99,7 +99,15 @@ export class TreeViewPage extends BasePage {
if (networkResponse === true) {
await this.waitForResponse({
uiAction: () => this.get().getByTestId(`nc-tbl-title-${title}`).click(),
uiAction: () =>
this.get()
.getByTestId(`nc-tbl-title-${title}`)
.click({
position: {
x: 10,
y: 10,
},
}),
httpMethodsToMatch: ['GET'],
requestUrlPathToMatch: `/api/v1/db/data/noco/`,
responseJsonMatcher: json => json.pageInfo,

2
tests/playwright/pages/Dashboard/common/Cell/index.ts

@ -341,7 +341,7 @@ export class CellPageObject extends BasePage {
await this.rootPage.waitForSelector('.nc-modal-child-list:visible');
// verify child list count & contents
expect.poll(() => this.rootPage.locator('.ant-card:visible').count()).toBe(count);
await expect.poll(() => this.rootPage.locator('.ant-card:visible').count()).toBe(count);
// close child list
await this.rootPage.locator('.nc-modal-child-list').locator('.nc-close-btn').last().click();

26
tests/playwright/pages/Dashboard/common/Topbar/Share.ts

@ -51,7 +51,16 @@ export class TopbarSharePage extends BasePage {
}
async clickShareBasePublicAccess() {
await this.get().locator(`[data-testid="nc-share-base-sub-modal"]`).locator('.ant-switch').nth(0).click();
await this.get()
.locator(`[data-testid="nc-share-base-sub-modal"]`)
.locator('.ant-switch')
.nth(0)
.click({
position: {
x: 4,
y: 4,
},
});
}
async isSharedBasePublicAccessEnabled() {
@ -63,14 +72,25 @@ export class TopbarSharePage extends BasePage {
}
async clickShareBaseEditorAccess() {
await this.get().locator(`[data-testid="nc-share-base-sub-modal"]`).locator('.ant-switch').nth(1).click();
await this.rootPage.waitForTimeout(1000);
const shareBaseSwitch = this.get().locator(`[data-testid="nc-share-base-sub-modal"]`).locator('.ant-switch');
const count = await shareBaseSwitch.count();
await this.get()
.locator(`[data-testid="nc-share-base-sub-modal"]`)
.locator('.ant-switch')
.nth(count - 1)
.click({
position: { x: 4, y: 4 },
});
}
async isSharedBaseEditorAccessEnabled() {
return await this.get()
.locator(`[data-testid="nc-share-base-sub-modal"]`)
.locator('.ant-switch')
.nth(1)
.nth(0)
.isChecked();
}

9
tests/playwright/pages/Dashboard/common/Topbar/index.ts

@ -54,12 +54,13 @@ export class TopbarPage extends BasePage {
return await this.getClipboardText();
}
async getSharedBaseUrl({ role }: { role: string }) {
async getSharedBaseUrl({ role, enableSharedBase }: { role: string; enableSharedBase: boolean }) {
await this.clickShare();
if (!(await this.share.isSharedBasePublicAccessEnabled())) await this.share.clickShareBasePublicAccess();
if (role === 'editor' && !(await this.share.isSharedBaseEditorAccessEnabled())) {
if (enableSharedBase) await this.share.clickShareBasePublicAccess();
if (role === 'editor' && enableSharedBase) {
await this.share.clickShareBaseEditorAccess();
} else if (role === 'viewer' && (await this.share.isSharedBaseEditorAccessEnabled())) {
} else if (role === 'viewer' && !enableSharedBase) {
await this.share.clickShareBaseEditorAccess();
}
await this.share.clickCopyLink();

2
tests/playwright/pages/SharedForm/index.ts

@ -58,7 +58,7 @@ export class SharedFormPage extends BasePage {
{
const childList = linkRecord.locator(`.ant-card`);
expect.poll(() => linkRecord.locator(`.ant-card`).count()).toBe(cardTitle.length);
await expect.poll(() => linkRecord.locator(`.ant-card`).count()).toBe(cardTitle.length);
for (let i = 0; i < cardTitle.length; i++) {
expect(await childList.nth(i).textContent()).toContain(cardTitle[i]);
}

4
tests/playwright/tests/db/features/baseShare.spec.ts

@ -66,7 +66,7 @@ test.describe('Shared base', () => {
let url = '';
// share button visible only if a table is opened
await dashboard.treeView.openTable({ title: 'Country' });
url = await dashboard.grid.topbar.getSharedBaseUrl({ role: 'editor' });
url = await dashboard.grid.topbar.getSharedBaseUrl({ role: 'editor', enableSharedBase: true });
await dashboard.rootPage.waitForTimeout(2000);
// access shared base link
@ -85,7 +85,7 @@ test.describe('Shared base', () => {
// await dashboard.treeView.openProject({ title: context.project.title });
await dashboard.treeView.openTable({ title: 'Country' });
url = await dashboard.grid.topbar.getSharedBaseUrl({ role: 'viewer' });
url = await dashboard.grid.topbar.getSharedBaseUrl({ role: 'viewer', enableSharedBase: false });
await dashboard.rootPage.waitForTimeout(2000);
// access shared base link

Loading…
Cancel
Save