-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add short links feature (graasp/graasp#664) (#861)
* feat: add short links view (#664) - The view is not responsive yet - Contain problems yet with the SDK and the query-client feat: improve UI, add translations and messages (graasp/graasp#664) - Update the UI to be more responsive - Update the UI to not allow to edit or create multiple short links at same time - Add membership admin check to hide short links view if forbbiden - Add notifier for short links actions and show error messages to the user feat: add Context colours in ShortLink view and use last SDK types test: add short links cypress tests (graasp/graasp#664) chore: add ENV variable for redirection host fix(test): remove shortLinkRenderId should exist to pass in CI chore: improve code form PR (#861) - Remove unnecessary nested cypress waits - Check the item path too in the isItemAdminAllowedForMember - Add Skeleton when loading short links - Allow to use Library platform for published items only - Update checkShortLink by shortLinkAvailable - Split ManageShortLink into smaller components - Remove not null assertions test: try to debug cypress in CI fix: add redirection host environment variable in cypress CI feat: update short links to future merge with full links feat: add shortlinks skeletons and move ManageShortLink dialog to parent feat: allow readers to display short links in read only mode feat: remove ShareItem component chore: update query-client, sdk and translations NPM version - query-client v2.1.0 - sdk v3.2.0 - translations v1.21.0 test: udpate the shortlink test for read only members chore: improve the code from the PR #861 - Update the redirection host to the short link’s backend route (go.graasp.org for prod) - Update mockGetShortLinksItem to filter by item id - Update SDK version - Adding changeVisibility test (part of tests from deleted shareItem) - Update shareItem tests to test short links displayed links - Moved short link test into share folder - Replace alias by short link in translations - Translates alias input - Replace aliasUnchanged state by hasAliasChanged in ShortLinkDialogContent - Regroup the useEffect in AliasValidation - Set GraaspLogo as default icon when PlatformIcon get invalid platform - Encapsulate debounce of API calls in a custom hooks - Others minor improvements chore: improve aliasAvailable check and make the item's platforms static - Use Boolean wrapper to check the aliasAvailable in AliasValidation.tsx - Set the item’s platforms static in the ShortLinkRenderer.tsx * fix(test): use an id for custom app instead of translated name * fix: use translated text for flag item button content --------- Co-authored-by: spaenleh <[email protected]>
- Loading branch information
Showing
49 changed files
with
2,412 additions
and
2,030 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { ItemLoginSchemaType, ItemTagType } from '@graasp/sdk'; | ||
|
||
import { buildItemPath } from '@/config/paths'; | ||
|
||
import { SETTINGS } from '../../../../src/config/constants'; | ||
import { | ||
SHARE_ITEM_PSEUDONYMIZED_SCHEMA_ID, | ||
SHARE_ITEM_VISIBILITY_SELECT_ID, | ||
buildShareButtonId, | ||
} from '../../../../src/config/selectors'; | ||
import { | ||
ITEM_LOGIN_ITEMS, | ||
SAMPLE_ITEMS, | ||
SAMPLE_PUBLIC_ITEMS, | ||
} from '../../../fixtures/items'; | ||
|
||
const changeVisibility = (value: string): void => { | ||
cy.get(`#${SHARE_ITEM_VISIBILITY_SELECT_ID}`).click(); | ||
cy.get(`li[data-value="${value}"]`, { timeout: 1000 }).click(); | ||
}; | ||
|
||
describe('Visibility of an Item', () => { | ||
it('Change Private Item to Public', () => { | ||
const item = SAMPLE_ITEMS.items[0]; | ||
cy.setUpApi({ ...SAMPLE_ITEMS }); | ||
cy.visit(buildItemPath(item.id)); | ||
cy.get(`#${buildShareButtonId(item.id)}`).click(); | ||
|
||
const visiblitySelect = cy.get( | ||
`#${SHARE_ITEM_VISIBILITY_SELECT_ID} + input`, | ||
); | ||
|
||
// visibility select default value | ||
visiblitySelect.should('have.value', SETTINGS.ITEM_PRIVATE.name); | ||
|
||
// change private -> public | ||
changeVisibility(SETTINGS.ITEM_PUBLIC.name); | ||
cy.wait(`@postItemTag-${ItemTagType.Public}`).then( | ||
({ request: { url } }) => { | ||
expect(url).to.contain(item.id); | ||
}, | ||
); | ||
}); | ||
|
||
it('Change Public Item to Private', () => { | ||
const item = SAMPLE_PUBLIC_ITEMS.items[0]; | ||
cy.setUpApi({ ...SAMPLE_PUBLIC_ITEMS }); | ||
cy.visit(buildItemPath(item.id)); | ||
cy.get(`#${buildShareButtonId(item.id)}`).click(); | ||
cy.wait(1000); | ||
const visiblitySelect = cy.get( | ||
`#${SHARE_ITEM_VISIBILITY_SELECT_ID} + input`, | ||
); | ||
|
||
// visibility select default value | ||
visiblitySelect.should('have.value', SETTINGS.ITEM_PUBLIC.name); | ||
|
||
// change public -> private | ||
changeVisibility(SETTINGS.ITEM_PRIVATE.name); | ||
cy.wait(`@deleteItemTag-${ItemTagType.Public}`).then( | ||
({ request: { url } }) => { | ||
expect(url).to.contain(item.id); | ||
}, | ||
); | ||
}); | ||
|
||
it('Change Public Item to Item Login', () => { | ||
const item = SAMPLE_PUBLIC_ITEMS.items[0]; | ||
cy.setUpApi({ ...SAMPLE_PUBLIC_ITEMS }); | ||
cy.visit(buildItemPath(item.id)); | ||
cy.get(`#${buildShareButtonId(item.id)}`).click(); | ||
cy.wait(1000); | ||
const visiblitySelect = cy.get( | ||
`#${SHARE_ITEM_VISIBILITY_SELECT_ID} + input`, | ||
); | ||
|
||
// visibility select default value | ||
visiblitySelect.should('have.value', SETTINGS.ITEM_PUBLIC.name); | ||
|
||
// change public -> item login | ||
changeVisibility(SETTINGS.ITEM_LOGIN.name); | ||
cy.wait([ | ||
`@deleteItemTag-${ItemTagType.Public}`, | ||
'@putItemLoginSchema', | ||
]).then((data) => { | ||
const { | ||
request: { url }, | ||
} = data[0]; | ||
expect(url).to.contain(item.id); | ||
expect(url).to.contain(ItemTagType.Public); // originally item login | ||
}); | ||
}); | ||
|
||
it('Change Pseudonymized Item to Private Item', () => { | ||
const item = ITEM_LOGIN_ITEMS.items[0]; | ||
cy.setUpApi({ items: [item] }); | ||
cy.visit(buildItemPath(item.id)); | ||
cy.get(`#${buildShareButtonId(item.id)}`).click(); | ||
|
||
// visibility select default value | ||
cy.get(`#${SHARE_ITEM_VISIBILITY_SELECT_ID} + input`).should( | ||
'have.value', | ||
SETTINGS.ITEM_LOGIN.name, | ||
); | ||
|
||
// change item login schema | ||
cy.get(`#${SHARE_ITEM_PSEUDONYMIZED_SCHEMA_ID} + input`).should( | ||
'have.value', | ||
ItemLoginSchemaType.Username, | ||
); | ||
// item login edition is done in itemLogin.cy.js | ||
|
||
// change pseudonymized -> private | ||
changeVisibility(SETTINGS.ITEM_PRIVATE.name); | ||
cy.wait(`@deleteItemLoginSchema`).then(({ request: { url } }) => { | ||
expect(url).to.include(item.id); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.