mirror of
https://github.com/hcengineering/platform.git
synced 2026-08-17 18:05:42 +02:00
Allow workspace owners to edit spaces (#9194)
Signed-off-by: Anton Alexeyev <alexeyev.anton@gmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import core, {
|
||||
checkPermission,
|
||||
getCurrentAccount,
|
||||
toIdMap,
|
||||
AccountRole,
|
||||
type Doc,
|
||||
type Space,
|
||||
type TypedSpace
|
||||
@@ -29,6 +30,11 @@ function isTypedSpace (space: Space): space is TypedSpace {
|
||||
return getClient().getHierarchy().isDerived(space._class, core.class.TypedSpace)
|
||||
}
|
||||
|
||||
function isSpaceOwner (space: Space): boolean {
|
||||
const currentAccount = getCurrentAccount()
|
||||
return currentAccount.role === AccountRole.Owner || (space.owners ?? []).includes(currentAccount.uuid)
|
||||
}
|
||||
|
||||
export async function canDeleteObject (doc?: Doc | Doc[]): Promise<boolean> {
|
||||
if (doc === undefined) {
|
||||
return false
|
||||
@@ -57,7 +63,7 @@ export async function canEditSpace (doc?: Doc | Doc[]): Promise<boolean> {
|
||||
|
||||
const space = doc as Space
|
||||
|
||||
if ((space.owners ?? []).includes(getCurrentAccount().uuid)) {
|
||||
if (isSpaceOwner(space)) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -83,7 +89,7 @@ export async function canArchiveSpace (doc?: Doc | Doc[]): Promise<boolean> {
|
||||
|
||||
const space = doc as Space
|
||||
|
||||
if ((space.owners ?? []).includes(getCurrentAccount().uuid)) {
|
||||
if (isSpaceOwner(space)) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -109,7 +115,7 @@ export async function canDeleteSpace (doc?: Doc | Doc[]): Promise<boolean> {
|
||||
|
||||
const space = doc as Space
|
||||
|
||||
if ((space.owners ?? []).includes(getCurrentAccount().uuid)) {
|
||||
if (isSpaceOwner(space)) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
DocumentURI,
|
||||
generateId,
|
||||
getSecondPage,
|
||||
getThirdPage,
|
||||
HomepageURI,
|
||||
PlatformSettingSecond,
|
||||
PlatformURI
|
||||
@@ -121,18 +122,24 @@ test.describe('ISO 13485, 4.2.4 Control of documents ensure that documents of ex
|
||||
})
|
||||
})
|
||||
|
||||
test('TESTS-404. As a space member only, I cannot create any doc from that space', async ({ page }) => {
|
||||
test('TESTS-404. As a space member only, I cannot create any doc from that space', async ({ page, browser }) => {
|
||||
await allure.description('Requirement\nUser is not able to create any document from that space')
|
||||
await allure.tms('TESTS-404', 'https://tracex.hc.engineering/workbench/platform/tracker/TESTS-404')
|
||||
await test.step('2. cCheck if user can not create documents as a space member', async () => {
|
||||
const folderName = faker.word.words(1)
|
||||
const documentContentPage = new DocumentContentPage(page)
|
||||
const folderName = faker.word.words(1)
|
||||
const userThirdPage = await getThirdPage(browser)
|
||||
const documentContentPage = new DocumentContentPage(page)
|
||||
const documentContentPageThird = new DocumentContentPage(userThirdPage)
|
||||
await (await userThirdPage.goto(`${PlatformURI}/${DocumentURI}`))?.finished()
|
||||
await test.step('2. Add a user as a space member', async () => {
|
||||
await documentContentPage.clickAddFolderButton()
|
||||
await documentContentPage.createDocumentSpaceMembersToJustMember(folderName)
|
||||
await documentContentPage.checkIfEditSpaceButtonExists(folderName, false)
|
||||
await page.keyboard.press('Escape')
|
||||
await documentContentPage.checkIfUserCanSelectSpace(folderName, false)
|
||||
await attachScreenshot('TESTS-404_non_space_member_can_not_create_documents.png', page)
|
||||
await documentContentPage.addThirdUserToMembers(folderName)
|
||||
})
|
||||
await test.step('3. Check if user can not create documents as a space member', async () => {
|
||||
await documentContentPageThird.checkIfEditSpaceButtonExists(folderName, false)
|
||||
await userThirdPage.keyboard.press('Escape')
|
||||
await documentContentPageThird.checkIfUserCanSelectSpace(folderName, false)
|
||||
await attachScreenshot('TESTS-404_non_space_member_can_not_create_documents.png', userThirdPage)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -589,6 +589,17 @@ export class DocumentContentPage extends DocumentCommonPage {
|
||||
await this.createButton.click()
|
||||
}
|
||||
|
||||
async addThirdUserToMembers (spaceName: string): Promise<void> {
|
||||
await this.page.getByRole('button', { name: spaceName }).hover()
|
||||
await this.page.getByRole('button', { name: spaceName }).getByRole('button').click()
|
||||
await this.editDocumentSpace.click()
|
||||
await this.page.getByRole('button', { name: 'AJ DK 2 members' }).click()
|
||||
await this.page.getByRole('button', { name: 'VC Velasquez Cain' }).click()
|
||||
await this.page.keyboard.press('Escape')
|
||||
await this.page.waitForTimeout(1000)
|
||||
await this.saveButton.click()
|
||||
}
|
||||
|
||||
async checkIfTheSpaceIsVisible (spaceName: string, visible: boolean): Promise<void> {
|
||||
if (visible) {
|
||||
await expect(this.page.getByRole('button', { name: spaceName })).toBeVisible()
|
||||
|
||||
@@ -57,6 +57,11 @@ export async function getSecondPage (browser: Browser): Promise<Page> {
|
||||
return await userSecondContext.newPage()
|
||||
}
|
||||
|
||||
export async function getThirdPage (browser: Browser): Promise<Page> {
|
||||
const userSecondContext = await browser.newContext({ storageState: PlatformSettingThird })
|
||||
return await userSecondContext.newPage()
|
||||
}
|
||||
|
||||
export async function getNewPage (browser: Browser): Promise<Page> {
|
||||
const context = await browser.newContext({ storageState: undefined })
|
||||
return await context.newPage()
|
||||
|
||||
@@ -21,7 +21,9 @@ export class CommonRecruitingPage extends CalendarPage {
|
||||
this.page.locator('.popupPanel > .hulyHeader-container > .hulyHeader-buttonsGroup.actions > button').first()
|
||||
|
||||
readonly buttonDelete = (): Locator => this.page.locator('button[class*="menuItem"] span', { hasText: 'Delete' })
|
||||
readonly buttonAddSocialLinks = (): Locator => this.page.locator('button[id="presentation:string:AddSocialLinks"]')
|
||||
readonly buttonAddSocialLinks = (): Locator =>
|
||||
this.page.locator('button[id="presentation:string:AddSocialLinks"]').last()
|
||||
|
||||
readonly buttonContactPhone = (): Locator =>
|
||||
this.page.locator('div[class^="popupPanel-body"] div.horizontal button[id="contact:string:Phone"]')
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export class TalentsPage extends CommonRecruitingPage {
|
||||
|
||||
talentsTab = (): Locator => this.page.locator('.antiPanel-navigator').locator('text=Talents')
|
||||
newTalentButton = (): Locator => this.page.locator('button:has-text("New Talent")')
|
||||
addSocialLinksButton = (): Locator => this.page.locator('[id="presentation\\:string\\:AddSocialLinks"]')
|
||||
addSocialLinksButton = (): Locator => this.page.locator('[id="presentation\\:string\\:AddSocialLinks"]').last()
|
||||
emailSelectorButton = (): Locator => this.page.locator('.antiPopup').locator('text=Email')
|
||||
confirmEmailButton = (): Locator => this.page.locator('#channel-ok.antiButton')
|
||||
createTalentButton = (): Locator => this.page.locator('.antiCard button:has-text("Create")')
|
||||
|
||||
Reference in New Issue
Block a user