Skip to content

Commit

Permalink
fix(test): update ccLicense to solve ResizeObserver error
Browse files Browse the repository at this point in the history
- remove loop to improve clarity in the tests
- create items with empty description to solve ResizeObserver issue
  • Loading branch information
ReidyT committed May 31, 2024
1 parent f8d9589 commit e73fedf
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 17 deletions.
55 changes: 44 additions & 11 deletions cypress/e2e/item/publish/ccLicense.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,34 @@ import {
import { MEMBERS } from '../../../fixtures/members';
import { ItemForTest } from '../../../support/types';

// Set empty description to avoid having issue
const EMPTY_DESCRIPTION = '';

const itemCCLicenseCCBY = PackedFolderItemFactory({
name: 'public item with cc by',
settings: { ccLicenseAdaption: 'CC BY' },
description: EMPTY_DESCRIPTION,
});
const itemCCLicenseCCBYNC = PackedFolderItemFactory({
name: 'public item with cc by nc',
settings: { ccLicenseAdaption: 'CC BY-NC' },
description: EMPTY_DESCRIPTION,
});
const itemCCLicenseCCBYSA = PackedFolderItemFactory({
name: 'public item with cc by sa',
settings: { ccLicenseAdaption: 'CC BY-SA' },
description: EMPTY_DESCRIPTION,
});
const itemCCLicenseCCBYNCND = PackedFolderItemFactory({
name: 'public item with cc by nc nd',
settings: { ccLicenseAdaption: 'CC BY-NC-ND' },
description: EMPTY_DESCRIPTION,
});

const itemWithoutLicense = PackedFolderItemFactory({
name: 'public item without license',
settings: { ccLicenseAdaption: null },
description: EMPTY_DESCRIPTION,
});

const PUBLISHED_ITEMS_WITH_CC_LICENSE: ItemForTest[] = [
Expand Down Expand Up @@ -200,19 +208,23 @@ describe('Creative Commons License', () => {
});
});

it('Current license is selected', () => {
for (const publishedItem of PUBLISHED_ITEMS_WITH_CC_LICENSE) {
describe('Current license is selected', () => {
const setUpAndOpenLicenseModal = (publishedItem: ItemForTest) => {
setUpAndVisitItemPage(publishedItem);
openLicenseModal();
};

const getLicenseAdaptations = (publishedItem: ItemForTest) => ({
requireAttribution:
publishedItem.settings.ccLicenseAdaption.includes('BY'),
noncommercial: publishedItem.settings.ccLicenseAdaption.includes('NC'),
shareAlike: publishedItem.settings.ccLicenseAdaption.includes('SA'),
noDerivative: publishedItem.settings.ccLicenseAdaption.includes('ND'),
});

const requireAttribution =
publishedItem.settings.ccLicenseAdaption.includes('BY');
const noncommercial =
publishedItem.settings.ccLicenseAdaption.includes('NC');
const shareAlike =
publishedItem.settings.ccLicenseAdaption.includes('SA');
const noDerivative =
publishedItem.settings.ccLicenseAdaption.includes('ND');
const ensureState = (publishedItem: ItemForTest) => {
const { requireAttribution, noncommercial, shareAlike, noDerivative } =
getLicenseAdaptations(publishedItem);

ensureRadioCheckedState(
CC_REQUIRE_ATTRIBUTION_CONTROL_ID,
Expand Down Expand Up @@ -243,7 +255,28 @@ describe('Creative Commons License', () => {
cy.get(`#${CC_SHARE_ALIKE_CONTROL_ID}`).should('not.exist');
cy.get(`#${CC_DERIVATIVE_CONTROL_ID}`).should('not.exist');
}
}
};

it('CCBY license is selected', () => {
const publishedItem = PUBLISHED_ITEMS_WITH_CC_LICENSE[0];
setUpAndOpenLicenseModal(publishedItem);
ensureState(publishedItem);
});
it('CCBYNC license is selected', () => {
const publishedItem = PUBLISHED_ITEMS_WITH_CC_LICENSE[1];
setUpAndOpenLicenseModal(publishedItem);
ensureState(publishedItem);
});
it('CCBYSA license is selected', () => {
const publishedItem = PUBLISHED_ITEMS_WITH_CC_LICENSE[2];
setUpAndOpenLicenseModal(publishedItem);
ensureState(publishedItem);
});
it('CCBYNCND license is selected', () => {
const publishedItem = PUBLISHED_ITEMS_WITH_CC_LICENSE[3];
setUpAndOpenLicenseModal(publishedItem);
ensureState(publishedItem);
});
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@emotion/styled": "11.11.5",
"@graasp/chatbox": "3.1.0",
"@graasp/map": "1.14.0",
"@graasp/query-client": "github:graasp/graasp-query-client#allow-disable-notifications",
"@graasp/query-client": "3.11.0",
"@graasp/sdk": "4.12.0",
"@graasp/translations": "1.28.0",
"@graasp/ui": "4.19.1",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1751,9 +1751,9 @@ __metadata:
languageName: node
linkType: hard

"@graasp/query-client@github:graasp/graasp-query-client#allow-disable-notifications":
version: 3.10.0
resolution: "@graasp/query-client@https://github.com/graasp/graasp-query-client.git#commit=8773660c4a216751dbbcf7ef8c543651880bd8e4"
"@graasp/query-client@npm:3.11.0":
version: 3.11.0
resolution: "@graasp/query-client@npm:3.11.0"
dependencies:
"@tanstack/react-query": "npm:4.36.1"
"@tanstack/react-query-devtools": "npm:4.36.1"
Expand All @@ -1764,7 +1764,7 @@ __metadata:
"@graasp/sdk": ^4.0.0
"@graasp/translations": ^1.23.0
react: ^18.0.0
checksum: 10/62a5e02524efbbdaa0b06c2ed3000555e02b58baeb861c6573859be16613b9236c4274353f108f26e819104dc2df8bb6c121cfad6c23e51f22326e3bf2c318df
checksum: 10/08e2b56136e2e1ae48dc2c619a0eff9d5594eb277572c8a3ae85953932fec94be5b97bec78817402a5c833dbd2d709cce556549af0e47b13a360ebdbeb85e0ec
languageName: node
linkType: hard

Expand Down Expand Up @@ -8061,7 +8061,7 @@ __metadata:
"@emotion/styled": "npm:11.11.5"
"@graasp/chatbox": "npm:3.1.0"
"@graasp/map": "npm:1.14.0"
"@graasp/query-client": "github:graasp/graasp-query-client#allow-disable-notifications"
"@graasp/query-client": "npm:3.11.0"
"@graasp/sdk": "npm:4.12.0"
"@graasp/translations": "npm:1.28.0"
"@graasp/ui": "npm:4.19.1"
Expand Down

0 comments on commit e73fedf

Please sign in to comment.