Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed May 5, 2023
1 parent bbf0dff commit ab1f7c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/support/api/graph/userManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const createGroup = async ({
checkResponseStatus(response, 'Failed while creating group')

const usersEnvironment = new UsersEnvironment()
usersEnvironment.storeGroup({ group: { ...group, uuid: (await response.json()).id } })
usersEnvironment.storeCreatedGroup({ group: { ...group, uuid: (await response.json()).id } })
return group
}

Expand Down
35 changes: 11 additions & 24 deletions tests/e2e/support/environment/userManagement.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Group, User } from '../types'
import { dummyUserStore, dummyGroupStore } from '../store'
import { createdUserStore } from '../store/user'
import { dummyUserStore, dummyGroupStore, createdUserStore, createdGroupStore } from '../store'

export class UsersEnvironment {
getUser({ key }: { key: string }): User {
Expand Down Expand Up @@ -65,38 +64,26 @@ export class UsersEnvironment {
}

getGroup({ key }: { key: string }): Group {
const uniqueKey = key.toLowerCase()
const groupKey = key.toLowerCase()

if (!dummyGroupStore.has(uniqueKey)) {
throw new Error(`group with key '${uniqueKey}' not found`)
if (!dummyGroupStore.has(groupKey)) {
throw new Error(`group with key '${groupKey}' not found`)
}

return dummyGroupStore.get(uniqueKey)
return dummyGroupStore.get(groupKey)
}

getCreatedGroup({ key }: { key: string }): Group {
const uniqueKey = key.toLowerCase()
const groupKey = key.toLowerCase()

if (!createdGroupStore.has(uniqueKey)) {
throw new Error(`group with key '${uniqueKey}' not found`)
if (!createdGroupStore.has(groupKey)) {
throw new Error(`group with key '${groupKey}' not found`)
}
console.log(createdGroupStore.get(uniqueKey))
return createdGroupStore.get(uniqueKey)
console.log(createdGroupStore.get(groupKey))
return createdGroupStore.get(groupKey)
}

createGroup({ key, group }: { key: string; group: Group }): Group {
const uniqueKey = key.toLowerCase()

if (dummyUserStore.has(uniqueKey)) {
throw new Error(`group with key '${uniqueKey}' already exists`)
}

dummyGroupStore.set(uniqueKey, group)

return group
}

storeGroup({ group }: { group: Group }): Group {
storeCreatedGroup({ group }: { group: Group }): Group {
if (createdGroupStore.has(group.id)) {
throw new Error(`user with key '${group.id}' already exists`)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Groups {
async createGroup({ key }: { key: string }): Promise<void> {
const group = this.#usersEnvironment.getGroup({ key })
const response = await createGroup({ page: this.#page, key: group.displayName })
this.#usersEnvironment.storeGroup({
this.#usersEnvironment.storeCreatedGroup({
group: {
id: key,
uuid: response['id'],
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/support/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { actorStore } from './actor'
export { createdLinkStore } from './link'
export { createdSpaceStore } from './space'
export { dummyUserStore } from './user'
export { dummyGroupStore } from './group'
export { dummyUserStore, createdUserStore } from './user'
export { dummyGroupStore, createdGroupStore } from './group'
export { userRoleStore } from './role'

0 comments on commit ab1f7c0

Please sign in to comment.