Skip to content

Commit

Permalink
chore: fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 committed Sep 20, 2024
1 parent e2f64ec commit 8fd6a1c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ class PermissionsTestData {
var projectBuilder: ProjectBuilder
var organizationBuilder: OrganizationBuilder
var admin: UserAccountBuilder
var serverAdmin: UserAccountBuilder
lateinit var addedProject: Project
lateinit var englishLanguage: Language
lateinit var keys: List<Key>

val root: TestDataBuilder =
TestDataBuilder().apply {
admin = addUserAccount { username = "admin@admin.com" }

serverAdmin = addUserAccount {
username = "Server admin"
name = "Server admin"
role = UserAccount.Role.ADMIN
}

organizationBuilder = admin.defaultOrganizationBuilder

val member = addUserAccount { username = "member@member.com" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.tolgee.development.testDataBuilder.data

import io.tolgee.development.testDataBuilder.builders.*
import io.tolgee.model.Language
import io.tolgee.model.UserAccount
import io.tolgee.model.enums.OrganizationRoleType
import io.tolgee.model.enums.ProjectPermissionType
import io.tolgee.model.enums.Scope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum class Scope(
private val translationsView = HierarchyItem(TRANSLATIONS_VIEW, listOf(keysView))
private val screenshotsView = HierarchyItem(SCREENSHOTS_VIEW, listOf(keysView))
private val translationsEdit = HierarchyItem(TRANSLATIONS_EDIT, listOf(translationsView))
private val tasksView = HierarchyItem(TASKS_VIEW)
private val tasksView = HierarchyItem(TASKS_VIEW, listOf(translationsView))

val hierarchy =
HierarchyItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class PermissionsE2eDataController() : AbstractE2eDataController() {
translateLanguageTags = translateLanguageTags,
stateChangeLanguageTags = stateChangeLanguageTags,
)
this.permissionsTestData.addTasks(mutableSetOf(user))
this.permissionsTestData.addTasks(
mutableSetOf(user, permissionsTestData.serverAdmin.self)
)
return generate()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
} from '../../../common/shared';

describe('Server admin 1', { retries: { runMode: 5 } }, () => {
it('admin', () => {
it('Server admin', () => {
visitProjectWithPermissions({ scopes: ['admin'] }).then((projectInfo) => {
// login as admin
login('admin', 'admin');
login('Server admin', 'admin');

// check that admin has no warning banner on his home page
switchToOrganization('admin');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
} from '../../../common/permissions/main';

describe('Server admin 2', () => {
it('admin', () => {
it('Server admin', () => {
visitProjectWithPermissions({ scopes: ['admin'] }).then((projectInfo) => {
// login as admin
login('admin', 'admin');
login('Server admin', 'admin');
checkPermissions(projectInfo, {
'project-menu-item-dashboard': SKIP,
'project-menu-item-translations': RUN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
} from '../../../common/permissions/main';

describe('Server admin 3', () => {
it('admin', () => {
it('Server admin', () => {
visitProjectWithPermissions({ scopes: ['admin'] }).then((projectInfo) => {
// login as admin
login('admin', 'admin');
login('Server admin', 'admin');
checkPermissions(projectInfo, {
'project-menu-item-dashboard': SKIP,
'project-menu-item-translations': SKIP,
Expand Down
3 changes: 2 additions & 1 deletion e2e/cypress/e2e/projects/permissions/permissionsTask.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('Permissions task', () => {
checkPermissions(projectInfo, {
'project-menu-item-dashboard': RUN,
'project-menu-item-translations': RUN,
'project-menu-item-tasks': RUN,
'project-menu-item-export': RUN,
'project-menu-item-integrate': RUN,
});
Expand All @@ -24,7 +25,7 @@ describe('Permissions task', () => {
checkPermissions(projectInfo, {
'project-menu-item-dashboard': RUN,
'project-menu-item-translations': RUN,
'project-menu-item-import': RUN,
'project-menu-item-tasks': RUN,
'project-menu-item-export': RUN,
'project-menu-item-integrate': RUN,
});
Expand Down

0 comments on commit 8fd6a1c

Please sign in to comment.