diff --git a/plugins/workbench-resources/src/components/SpaceHeader.svelte b/plugins/workbench-resources/src/components/SpaceHeader.svelte index a078db3a73..e33c2bba8f 100644 --- a/plugins/workbench-resources/src/components/SpaceHeader.svelte +++ b/plugins/workbench-resources/src/components/SpaceHeader.svelte @@ -47,8 +47,7 @@ showPopup(createItemDialog as AnyComponent, { space: spaceId }, ev.target as HTMLElement) } - let selectedViewlet = 0 - $: viewlet = viewlets[selectedViewlet] + $: updateViewlets(viewlets) $: if (prevSpaceId !== spaceId) { search = '' @@ -67,6 +66,12 @@ const editor = await getEditor(space._class) showPanel(editor ?? plugin.component.SpacePanel, space._id, space._class, 'right') } + + + function updateViewlets (viewlets: WithLookup[]) { + const index = viewlets.findIndex((p) => p.descriptor === viewlet?.descriptor) + viewlet = index === -1 ? viewlets[0] : viewlets[index] + }
@@ -74,11 +79,11 @@
{#if viewlets.length > 1}
- {#each viewlets as viewlet, i} - - diff --git a/plugins/workbench-resources/src/components/SpaceView.svelte b/plugins/workbench-resources/src/components/SpaceView.svelte index ec3bc6ee84..c46c55ddb7 100644 --- a/plugins/workbench-resources/src/components/SpaceView.svelte +++ b/plugins/workbench-resources/src/components/SpaceView.svelte @@ -47,7 +47,6 @@ }) _class = attachTo } - viewlet = viewlets[0] space = currentSpace } diff --git a/tests/sanity/tests/workbench.spec.ts b/tests/sanity/tests/workbench.spec.ts new file mode 100644 index 0000000000..db4cf90b7b --- /dev/null +++ b/tests/sanity/tests/workbench.spec.ts @@ -0,0 +1,50 @@ +import { expect, test } from '@playwright/test' +import { openWorkbench } from './utils' + +test.describe('workbench tests', () => { + test.beforeEach(async ({ page }) => { + // Create user and workspace + await openWorkbench(page) + }) + test('navigator', async ({ page }) => { + // Click [id="app-recruit\:string\:RecruitApplication"] + await page.click('[id="app-recruit\\:string\\:RecruitApplication"]') + await expect(page).toHaveURL('http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/recruit%3Aapp%3ARecruit') + // Click text=Applications + await page.click('text=Applications') + await expect(page).toHaveURL('http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/recruit%3Aapp%3ARecruit/applicants') + // Click text=Applications Application >> span + await expect(page.locator('text=Applications Application >> span')).toBeVisible() + await expect(page.locator('text=APP-1')).toBeVisible() + + // Click text=Candidates + await page.click('text=Candidates') + await expect(page).toHaveURL('http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/recruit%3Aapp%3ARecruit/candidates') + + await expect(page.locator('text=Candidates Candidate >> span')).toBeVisible() + await expect(page.locator('text=Andrey P.')).toBeVisible() + + // Click text=Vacancies + await page.click('text=Vacancies') + await expect(page).toHaveURL('http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/recruit%3Aapp%3ARecruit/vacancies') + // Click text=Software Engineer + await page.click('text=Software Engineer') + await expect(page.locator('text=Software Engineer')).toBeVisible() + await expect(page.locator('text=APP-1')).toBeVisible() + await page.click('[name="tooltip-task:string:Kanban"]') + + // Click [id="app-chunter\:string\:ApplicationLabelChunter"] + await page.click('[id="app-chunter\\:string\\:ApplicationLabelChunter"]') + await expect(page).toHaveURL('http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/chunter%3Aapp%3AChunter') + + await page.click('text=general') + + // Click .textInput + await expect(page.locator('.textInput')).toBeVisible() + + await page.click('[id="app-contact\\:string\\:Contacts"]') + await expect(page).toHaveURL('http://localhost:8083/workbench%3Acomponent%3AWorkbenchApp/contact%3Aapp%3AContacts') + // Click text=John Appleseed + await expect(page.locator('text=John Appleseed')).toBeVisible() + }) +})