Skip to content

Commit

Permalink
test: udpate the shortlink test for read only members
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT committed Nov 28, 2023
1 parent ad34043 commit 2580c94
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1,763 deletions.
22 changes: 20 additions & 2 deletions cypress/e2e/item/shortLink/shortLink.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { buildItemPath } from '@/config/paths';
import {
SHORT_LINK_ALIAS_INPUT_ID,
SHORT_LINK_COMPONENT,
SHORT_LINK_MENU_START_ID,
SHORT_LINK_RANDOMIZE_BUTTON_ID,
SHORT_LINK_SAVE_BUTTON_ID,
SHORT_LINK_SHORTEN_START_ID,
buildShareButtonId,
buildShortLinkConfirmDeleteBtnId,
buildShortLinkDeleteBtnId,
Expand Down Expand Up @@ -422,8 +424,16 @@ describe('Short links', () => {

describe('Read permission', () => {
let itemId: string;
let shortLinks: ShortLink[];
beforeEach(() => {
const shortLinks: ShortLink[] = [];
shortLinks = [
{
alias: 'test-1',
platform: Context.Player,
item: { id: itemId },
createdAt: new Date().toISOString(),
},
];

cy.setUpApi({
...SAMPLE_READ_ITEMS,
Expand All @@ -434,9 +444,17 @@ describe('Short links', () => {
itemId = SAMPLE_READ_ITEMS.items[0].id;
});

it('Short links are not rendered', () => {
it('Short links are read only', () => {
cy.visit(buildItemPath(itemId));
cy.get(`#${buildShareButtonId(itemId)}`).click();
cy.wait('@getShortLinksItem').its('response.body.length').should('eq', 1);
cy.get(`.${SHORT_LINK_COMPONENT}`).should('have.length', 2);
// This wait is necessary to be sure that the UI render the short links with add and/or menu buttons
cy.wait(1000);
// It shouldn't have a shortLink menu button allowing user to edit it
cy.get(`[id^=${SHORT_LINK_MENU_START_ID}]`).should('have.length', 0);
// It shouldn't have a shortenize button allowing user to create a shortlink
cy.get(`[id^=${SHORT_LINK_SHORTEN_START_ID}]`).should('have.length', 0);
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"vite-plugin-istanbul": "5.0.0"
},
"resolutions": {
"@graasp/sdk": "github:graasp/graasp-sdk#664-add-short-links-feature"
"@graasp/sdk": "3.2.0"
},
"packageManager": "[email protected]"
}
6 changes: 4 additions & 2 deletions src/config/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,11 @@ export const SHORT_LINK_SAVE_BUTTON_ID = 'shortLinkSaveButtonID';
export const SHORT_LINK_RANDOMIZE_BUTTON_ID = 'shortLinkRandomizeButtonID';
export const SHORT_LINK_ALIAS_INPUT_ID = 'shortLinkAliasInputID';
export const SHORT_LINK_PLATFORM_SELECT_ID = 'shortLinkPlatformSelectID';
export const SHORT_LINK_MENU_START_ID = 'shortLinkMenuBtn';
export const SHORT_LINK_SHORTEN_START_ID = 'shortLinkShortenBtn';

export const buildShortLinkMenuBtnId = (alias: string): string =>
`shortLinkMenuBtn-${alias}`;
`${SHORT_LINK_MENU_START_ID}-${alias}`;
export const buildShortLinkCancelBtnId = (alias: string): string =>
`shortLinkCancelBtn-${alias}`;
export const buildShortLinkSaveBtnId = (alias: string): string =>
Expand All @@ -328,4 +330,4 @@ export const buildShortLinkEditBtnId = (alias: string): string =>
export const buildShortLinkShortenBtnId = (
itemId: string,
platform: ShortLinkPlatform,
): string => `shortLinkShortenBtn-${platform}-${itemId}`;
): string => `${SHORT_LINK_SHORTEN_START_ID}-${platform}-${itemId}`;
Loading

0 comments on commit 2580c94

Please sign in to comment.