Skip to content

Commit

Permalink
feat: update query client and sdk for item visibility (#1563)
Browse files Browse the repository at this point in the history
* feat: update query client and sdk for item visibility

* refactor: fix test

* refactor: update deps
  • Loading branch information
pyphilia authored Nov 7, 2024
1 parent 463432b commit 737d2ab
Show file tree
Hide file tree
Showing 23 changed files with 224 additions and 299 deletions.
28 changes: 14 additions & 14 deletions cypress/e2e/item/hide/hideItem.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ItemTagType,
ItemVisibilityType,
PackedFolderItemFactory,
PermissionLevel,
} from '@graasp/sdk';
Expand All @@ -21,7 +21,7 @@ import { ItemForTest } from '../../../support/types';

const hiddenItem = PackedFolderItemFactory(
{},
{ hiddenTag: { type: ItemTagType.Hidden } },
{ hiddenVisibility: { type: ItemVisibilityType.Hidden } },
);
const HIDDEN_ITEM: ItemForTest = {
...hiddenItem,
Expand Down Expand Up @@ -74,9 +74,9 @@ describe('Hide Item', () => {

toggleHideButton(ITEM.id, false);

cy.wait(`@postItemTag-${ItemTagType.Hidden}`).then(
cy.wait(`@postItemVisibility-${ItemVisibilityType.Hidden}`).then(
({ request: { url } }) => {
expect(url).to.contain(ItemTagType.Hidden);
expect(url).to.contain(ItemVisibilityType.Hidden);
expect(url).to.contain(ITEM.id);
},
);
Expand All @@ -89,9 +89,9 @@ describe('Hide Item', () => {
// make sure to wait for the tags to be fetched
toggleHideButton(item.id, true);

cy.wait(`@deleteItemTag-${ItemTagType.Hidden}`).then(
cy.wait(`@deleteItemVisibility-${ItemVisibilityType.Hidden}`).then(
({ request: { url } }) => {
expect(url).to.contain(ItemTagType.Hidden);
expect(url).to.contain(ItemVisibilityType.Hidden);
expect(url).to.contain(item.id);
},
);
Expand All @@ -113,9 +113,9 @@ describe('Hide Item', () => {

cy.get(`#${SETTINGS_HIDE_ITEM_ID}`).click();

cy.wait(`@postItemTag-${ItemTagType.Hidden}`).then(
cy.wait(`@postItemVisibility-${ItemVisibilityType.Hidden}`).then(
({ request: { url } }) => {
expect(url).to.contain(ItemTagType.Hidden);
expect(url).to.contain(ItemVisibilityType.Hidden);
expect(url).to.contain(ITEM.id);
},
);
Expand All @@ -125,9 +125,9 @@ describe('Hide Item', () => {

cy.get(`#${SETTINGS_HIDE_ITEM_ID}`).click();

cy.wait(`@deleteItemTag-${ItemTagType.Hidden}`).then(
cy.wait(`@deleteItemVisibility-${ItemVisibilityType.Hidden}`).then(
({ request: { url } }) => {
expect(url).to.contain(ItemTagType.Hidden);
expect(url).to.contain(ItemVisibilityType.Hidden);
expect(url).to.contain(HIDDEN_ITEM.id);
},
);
Expand All @@ -146,9 +146,9 @@ describe('Hide Item', () => {

cy.get(`#${SETTINGS_HIDE_ITEM_ID}`).click();

cy.wait(`@postItemTag-${ItemTagType.Hidden}`).then(
cy.wait(`@postItemVisibility-${ItemVisibilityType.Hidden}`).then(
({ request: { url } }) => {
expect(url).to.contain(ItemTagType.Hidden);
expect(url).to.contain(ItemVisibilityType.Hidden);
expect(url).to.contain(ITEM.id);
},
);
Expand All @@ -158,9 +158,9 @@ describe('Hide Item', () => {

cy.get(`#${SETTINGS_HIDE_ITEM_ID}`).click();

cy.wait(`@deleteItemTag-${ItemTagType.Hidden}`).then(
cy.wait(`@deleteItemVisibility-${ItemVisibilityType.Hidden}`).then(
({ request: { url } }) => {
expect(url).to.contain(ItemTagType.Hidden);
expect(url).to.contain(ItemVisibilityType.Hidden);
expect(url).to.contain(HIDDEN_ITEM.id);
},
);
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/item/pin/pinItem.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ITEM = PackedFolderItemFactory({ settings: { isPinned: false } });
describe('Anonymous', () => {
const PUBLIC_TTEM = PackedFolderItemFactory(
{ settings: { isPinned: false } },
{ permission: null, publicTag: {} },
{ permission: null, publicVisibility: {} },
);
const itemId = PUBLIC_TTEM.id;
beforeEach(() => {
Expand Down
18 changes: 9 additions & 9 deletions cypress/e2e/item/publish/ccLicense.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
CCLicenseAdaptions,
ItemTagType,
ItemVisibilityType,
PackedFolderItemFactory,
} from '@graasp/sdk';

Expand Down Expand Up @@ -57,10 +57,10 @@ const itemWithoutLicense = PackedFolderItemFactory({
const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
{
...itemCCLicenseCCBY,
tags: [
visibilities: [
{
id: 'ecbfbd2a-5688-11eb-ae93-0242ac130002',
type: ItemTagType.Public,
type: ItemVisibilityType.Public,
item: itemCCLicenseCCBY,
createdAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand All @@ -76,10 +76,10 @@ const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
},
{
...itemCCLicenseCCBYNC,
tags: [
visibilities: [
{
id: 'ecbfbd2a-5688-11eb-ae93-0242ac130002',
type: ItemTagType.Public,
type: ItemVisibilityType.Public,
item: itemCCLicenseCCBYNC,
createdAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand All @@ -95,10 +95,10 @@ const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
},
{
...itemCCLicenseCCBYSA,
tags: [
visibilities: [
{
id: 'ecbfbd2a-5688-11eb-ae93-0242ac130002',
type: ItemTagType.Public,
type: ItemVisibilityType.Public,
item: itemCCLicenseCCBYSA,
createdAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand All @@ -114,10 +114,10 @@ const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
},
{
...itemCCLicenseCCBYNCND,
tags: [
visibilities: [
{
id: 'ecbfbd2a-5688-11eb-ae93-0242ac130002',
type: ItemTagType.Public,
type: ItemVisibilityType.Public,
item: itemCCLicenseCCBYNCND,
createdAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/item/publish/coEditorSettings.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ItemTagType, PackedFolderItemFactory } from '@graasp/sdk';
import { ItemVisibilityType, PackedFolderItemFactory } from '@graasp/sdk';

import { DISPLAY_CO_EDITORS_OPTIONS } from '../../../../src/config/constants';
import { buildItemPath } from '../../../../src/config/paths';
Expand Down Expand Up @@ -53,7 +53,7 @@ it('Change choice', () => {

const item = PackedFolderItemFactory(
{},
{ permission: null, publicTag: { type: ItemTagType.Public } },
{ permission: null, publicVisibility: { type: ItemVisibilityType.Public } },
);

describe('Co-editor setting permissions', () => {
Expand Down
13 changes: 8 additions & 5 deletions cypress/e2e/item/publish/publishedItem.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
ItemTagType,
ItemType,
ItemTypeUnion,
ItemValidationGroup,
ItemValidationStatus,
ItemVisibilityType,
Member,
PackedFolderItemFactory,
PackedItem,
Expand Down Expand Up @@ -95,7 +95,7 @@ const waitOnPublishItem = (
};

const waitOnSetItemPublic = (item: PackedItem) => {
waitOnRequest(`@postItemTag-${ItemTagType.Public}`, item);
waitOnRequest(`@postItemVisibility-${ItemVisibilityType.Public}`, item);
};

const waitOnUnpublishItem = (item: PackedItem) => {
Expand All @@ -110,7 +110,10 @@ describe('Unauthorized members should not have access to publish tab', () => {
});

it('Unlogged members should not view publish tab', () => {
item = PackedFolderItemFactory({}, { permission: null, publicTag: {} });
item = PackedFolderItemFactory(
{},
{ permission: null, publicVisibility: {} },
);
setUpAndVisitItemPage(item, { currentMember: null });
});

Expand All @@ -126,7 +129,7 @@ describe('Unauthorized members should not have access to publish tab', () => {
});

describe('Private Item', () => {
const privateItem = PackedFolderItemFactory({}, { publicTag: null });
const privateItem = PackedFolderItemFactory({}, { publicVisibility: null });

describe('Unpublished Item', () => {
const status = PublicationStatus.Unpublished;
Expand Down Expand Up @@ -206,7 +209,7 @@ describe('Private Item', () => {
});

describe('Public Item', () => {
const publicItem = PackedFolderItemFactory({}, { publicTag: {} });
const publicItem = PackedFolderItemFactory({}, { publicVisibility: {} });

describe('Unpublished Item', () => {
const status = PublicationStatus.Unpublished;
Expand Down
14 changes: 7 additions & 7 deletions cypress/e2e/item/publish/tags.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ItemTagType,
ItemVisibilityType,
PackedFolderItemFactory,
PermissionLevel,
} from '@graasp/sdk';
Expand Down Expand Up @@ -101,14 +101,14 @@ describe('Tags permissions', () => {
it('User signed out cannot edit tags', () => {
const item = PackedFolderItemFactory(
{},
{ permission: null, publicTag: {} },
{ permission: null, publicVisibility: {} },
);
const publishedItem = {
...item,
tags: [
visibilities: [
{
id: 'ecbfbd2a-5688-11eb-ae93-0242ac130002',
type: ItemTagType.Public,
type: ItemVisibilityType.Public,
item,
createdAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand Down Expand Up @@ -136,14 +136,14 @@ describe('Tags permissions', () => {
it('Read-only user cannot edit tags', () => {
const item = PackedFolderItemFactory(
{},
{ permission: PermissionLevel.Read, publicTag: {} },
{ permission: PermissionLevel.Read, publicVisibility: {} },
);
const publishedItem = {
...item,
tags: [
visibilities: [
{
id: 'ecbfbd2a-5688-11eb-ae93-0242ac130002',
type: ItemTagType.Public,
type: ItemVisibilityType.Public,
item,
createdAt: '2021-08-11T12:56:36.834Z',
creator: MEMBERS.ANNA,
Expand Down
26 changes: 13 additions & 13 deletions cypress/e2e/item/share/changeVisibility.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ItemLoginSchemaStatus,
ItemLoginSchemaType,
ItemTagType,
ItemVisibilityType,
PackedFolderItemFactory,
PublicationStatus,
} from '@graasp/sdk';
Expand Down Expand Up @@ -40,15 +40,15 @@ describe('Visibility of an Item', () => {

// change private -> public
changeVisibility(SETTINGS.ITEM_PUBLIC.name);
cy.wait(`@postItemTag-${ItemTagType.Public}`).then(
cy.wait(`@postItemVisibility-${ItemVisibilityType.Public}`).then(
({ request: { url } }) => {
expect(url).to.contain(item.id);
},
);
});

it('Change Public Item to Private', () => {
const item = PackedFolderItemFactory({}, { publicTag: {} });
const item = PackedFolderItemFactory({}, { publicVisibility: {} });
cy.setUpApi({ items: [item] });
cy.visit(buildItemPath(item.id));
cy.get(`#${buildShareButtonId(item.id)}`).click();
Expand All @@ -62,15 +62,15 @@ describe('Visibility of an Item', () => {

// change public -> private
changeVisibility(SETTINGS.ITEM_PRIVATE.name);
cy.wait(`@deleteItemTag-${ItemTagType.Public}`).then(
cy.wait(`@deleteItemVisibility-${ItemVisibilityType.Public}`).then(
({ request: { url } }) => {
expect(url).to.contain(item.id);
},
);
});

it('Change Public Item to Item Login', () => {
const item = PackedFolderItemFactory({}, { publicTag: {} });
const item = PackedFolderItemFactory({}, { publicVisibility: {} });
cy.setUpApi({ items: [item] });
cy.visit(buildItemPath(item.id));
cy.get(`#${buildShareButtonId(item.id)}`).click();
Expand All @@ -85,14 +85,14 @@ describe('Visibility of an Item', () => {
// change public -> item login
changeVisibility(SETTINGS.ITEM_LOGIN.name);
cy.wait([
`@deleteItemTag-${ItemTagType.Public}`,
`@deleteItemVisibility-${ItemVisibilityType.Public}`,
'@putItemLoginSchema',
]).then((data) => {
const {
request: { url },
} = data[0];
expect(url).to.contain(item.id);
expect(url).to.contain(ItemTagType.Public); // originally item login
expect(url).to.contain(ItemVisibilityType.Public); // originally item login

const {
request: { body, url: itemLoginUrl },
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('Visibility of an Item', () => {
});

it('Show hidden alert', () => {
const item = PackedFolderItemFactory({}, { hiddenTag: {} });
const item = PackedFolderItemFactory({}, { hiddenVisibility: {} });
const ITEM_LOGIN_ITEM = {
...item,
itemLoginSchema: {
Expand All @@ -160,7 +160,7 @@ describe('Visibility of an Item', () => {
describe('Change visibility of published item', () => {
it('User should validate the change to private', () => {
const item = PublishedItemFactory(
PackedFolderItemFactory({}, { publicTag: {} }),
PackedFolderItemFactory({}, { publicVisibility: {} }),
);
cy.setUpApi({
items: [item],
Expand All @@ -181,7 +181,7 @@ describe('Visibility of an Item', () => {
cy.get(
`${buildDataCyWrapper(UPDATE_VISIBILITY_MODAL_VALIDATE_BUTTON)}`,
).click();
cy.wait(`@deleteItemTag-${ItemTagType.Public}`).then(
cy.wait(`@deleteItemVisibility-${ItemVisibilityType.Public}`).then(
({ request: { url } }) => {
expect(url).to.contain(item.id);
},
Expand All @@ -190,7 +190,7 @@ describe('Visibility of an Item', () => {

it('User should validate the change to item login', () => {
const item = PublishedItemFactory(
PackedFolderItemFactory({}, { publicTag: {} }),
PackedFolderItemFactory({}, { publicVisibility: {} }),
);
cy.setUpApi({
items: [item],
Expand All @@ -212,14 +212,14 @@ describe('Visibility of an Item', () => {
`${buildDataCyWrapper(UPDATE_VISIBILITY_MODAL_VALIDATE_BUTTON)}`,
).click();
cy.wait([
`@deleteItemTag-${ItemTagType.Public}`,
`@deleteItemVisibility-${ItemVisibilityType.Public}`,
'@putItemLoginSchema',
]).then((data) => {
const {
request: { url },
} = data[0];
expect(url).to.contain(item.id);
expect(url).to.contain(ItemTagType.Public); // originally item login
expect(url).to.contain(ItemVisibilityType.Public); // originally item login

const {
request: { url: itemLoginUrl, body },
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/memberships/viewMemberships.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('View Memberships - Individual', () => {

describe('View Memberships - Hidden item', () => {
it('view disabled memberships for hidden item', () => {
const hiddenItem = PackedFolderItemFactory({}, { hiddenTag: {} });
const hiddenItem = PackedFolderItemFactory({}, { hiddenVisibility: {} });
const adminHiddenMembership = buildItemMembership({
item: hiddenItem,
permission: PermissionLevel.Admin,
Expand Down
Loading

0 comments on commit 737d2ab

Please sign in to comment.