Skip to content

Commit

Permalink
Merge pull request #387 from alkem-io/refactor/getProfileDocumentAndS…
Browse files Browse the repository at this point in the history
…torageData

* refactored getting documents from subspace to use lookup

* further usage of getProfileDocuments
  • Loading branch information
valentinyanakiev authored Dec 11, 2024
2 parents 5951ba8 + dc08dd7 commit 78dcc3d
Show file tree
Hide file tree
Showing 16 changed files with 1,054 additions and 1,146 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
query getSpaceDocumentAndStorageData($ID: UUID_NAMEID!) {
space(ID: $ID) {
profile {
query GetProfileDocuments($profileID: UUID!) {
lookup {
profile(ID: $profileID) {
id
storageBucket {
id
authorization {
anonymousReadAccess
myPrivileges
}
id
parentEntity {
displayName
id
type
url
}
authorization {
anonymousReadAccess
myPrivileges
}
documents {
id
authorization {
Expand Down

This file was deleted.

41 changes: 0 additions & 41 deletions graphql/queries/user/getUserDocumentAndStorageData.graphql

This file was deleted.

5 changes: 4 additions & 1 deletion test/functional-api/roleset/roles-request.params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { CommunityRoleType, OrganizationRole } from '../../generated/alkemio-schema';
import {
CommunityRoleType,
OrganizationRole,
} from '../../generated/alkemio-schema';
import { TestUser } from '../../utils';
import { graphqlErrorWrapper } from '../../utils/graphql.wrapper';
import { getGraphqlClient } from '../../utils/graphqlClient';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { uniqueId } from '@test/utils/mutations/create-mutation';
import { TestUser } from '@test/utils';
import {
deleteDocument,
getOrganizationProfileDocuments,
getProfileDocuments,
uploadFileOnRef,
uploadFileOnStorageBucket,
uploadImageOnVisual,
Expand Down Expand Up @@ -78,13 +78,12 @@ describe('Organization - documents', () => {
path.join(__dirname, 'files-to-upload', '190-410.jpg'),
visualId
);
const getDocId = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const getDocId = await getProfileDocuments(
entitiesId.organization.profileId,
TestUser.GLOBAL_ADMIN
);
documentId =
getDocId.data?.organization?.profile?.storageBucket?.documents[0].id ??
'';
getDocId.data?.lookup?.profile?.storageBucket?.documents[0].id ?? '';
});

// Arrange
Expand All @@ -99,12 +98,11 @@ describe('Organization - documents', () => {
`(
'User: "$userRole" has this privileges: "$privileges" to organization profile visual document',
async ({ userRole, privileges, anonymousReadAccess }) => {
const res = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const res = await getProfileDocuments(
entitiesId.organization.profileId,
userRole
);
const data =
res.data?.organization?.profile?.storageBucket?.documents[0];
const data = res.data?.lookup?.profile?.storageBucket?.documents[0];
const dataAuthorization = data?.authorization;

expect(dataAuthorization?.myPrivileges?.sort()).toEqual(privileges);
Expand All @@ -130,11 +128,11 @@ describe('Organization - documents', () => {
anonymousReadAccess,
parentEntityType,
}) => {
const res = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const res = await getProfileDocuments(
entitiesId.organization.profileId,
userRole
);
const data = res.data?.organization?.profile?.storageBucket;
const data = res.data?.lookup?.profile?.storageBucket;

expect(data?.authorization?.myPrivileges?.sort()).toEqual(privileges);
expect(data?.authorization?.anonymousReadAccess).toEqual(
Expand All @@ -159,13 +157,12 @@ describe('Organization - documents', () => {
refId
);

const getDocId = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const getDocId = await getProfileDocuments(
entitiesId.organization.profileId,
TestUser.GLOBAL_ADMIN
);
documentId =
getDocId.data?.organization?.profile?.storageBucket?.documents[0].id ??
'';
getDocId.data?.lookup?.profile?.storageBucket?.documents[0].id ?? '';
});

// Arrange
Expand All @@ -180,12 +177,11 @@ describe('Organization - documents', () => {
`(
'User: "$userRole" has this privileges: "$privileges" to organization reference document',
async ({ userRole, privileges, anonymousReadAccess }) => {
const res = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const res = await getProfileDocuments(
entitiesId.organization.profileId,
userRole
);
const data =
res.data?.organization?.profile?.storageBucket?.documents[0];
const data = res.data?.lookup?.profile?.storageBucket?.documents[0];
const dataAuthorization = data?.authorization;

expect(dataAuthorization?.myPrivileges?.sort()).toEqual(privileges);
Expand All @@ -211,11 +207,11 @@ describe('Organization - documents', () => {
anonymousReadAccess,
parentEntityType,
}) => {
const res = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const res = await getProfileDocuments(
entitiesId.organization.profileId,
userRole
);
const data = res.data?.organization?.profile?.storageBucket;
const data = res.data?.lookup?.profile?.storageBucket;

expect(data?.authorization?.myPrivileges?.sort()).toEqual(privileges);
expect(data?.authorization?.anonymousReadAccess).toEqual(
Expand All @@ -231,27 +227,26 @@ describe('Organization - documents', () => {
await deleteDocument(documentId);
});
beforeAll(async () => {
const getSpaceStorageId = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const getSpaceStorageId = await getProfileDocuments(
entitiesId.organization.profileId,
TestUser.GLOBAL_ADMIN
);

const storageId =
getSpaceStorageId.data?.organization?.profile?.storageBucket?.id ?? '';
getSpaceStorageId.data?.lookup?.profile?.storageBucket?.id ?? '';

await uploadFileOnStorageBucket(
path.join(__dirname, 'files-to-upload', 'image.png'),
storageId
);

const getDocId = await getOrganizationProfileDocuments(
entitiesId.spaceId,
const getDocId = await getProfileDocuments(
entitiesId.space.profileId,
TestUser.GLOBAL_ADMIN
);

documentId =
getDocId.data?.organization?.profile?.storageBucket?.documents[0].id ??
'';
getDocId.data?.lookup?.profile?.storageBucket?.documents[0].id ?? '';
});

// Arrange
Expand All @@ -266,12 +261,11 @@ describe('Organization - documents', () => {
`(
'User: "$userRole" has this privileges: "$privileges" to organization description visual document',
async ({ userRole, privileges, anonymousReadAccess }) => {
const res = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const res = await getProfileDocuments(
entitiesId.organization.profileId,
userRole
);
const data =
res.data?.organization?.profile?.storageBucket?.documents[0];
const data = res.data?.lookup?.profile?.storageBucket?.documents[0];
const dataAuthorization = data?.authorization;

expect(dataAuthorization?.myPrivileges?.sort()).toEqual(privileges);
Expand All @@ -297,11 +291,11 @@ describe('Organization - documents', () => {
anonymousReadAccess,
parentEntityType,
}) => {
const res = await getOrganizationProfileDocuments(
entitiesId.organization.id,
const res = await getProfileDocuments(
entitiesId.organization.profileId,
userRole
);
const data = res.data?.organization?.profile?.storageBucket;
const data = res.data?.lookup?.profile?.storageBucket;

expect(data?.authorization?.myPrivileges?.sort()).toEqual(privileges);
expect(data?.authorization?.anonymousReadAccess).toEqual(
Expand Down
Loading

0 comments on commit 78dcc3d

Please sign in to comment.