From e73fedfa928289d6b82ea7625e346972d49e79d7 Mon Sep 17 00:00:00 2001 From: Thibault Reidy Date: Fri, 31 May 2024 16:28:45 +0200 Subject: [PATCH] fix(test): update ccLicense to solve ResizeObserver error - remove loop to improve clarity in the tests - create items with empty description to solve ResizeObserver issue --- cypress/e2e/item/publish/ccLicense.cy.ts | 55 +++++++++++++++++++----- package.json | 2 +- yarn.lock | 10 ++--- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/cypress/e2e/item/publish/ccLicense.cy.ts b/cypress/e2e/item/publish/ccLicense.cy.ts index 5b4850c65..2f7936335 100644 --- a/cypress/e2e/item/publish/ccLicense.cy.ts +++ b/cypress/e2e/item/publish/ccLicense.cy.ts @@ -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[] = [ @@ -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, @@ -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); + }); }); }); }); diff --git a/package.json b/package.json index 4b08507d6..de5258d2c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 1b9a4f0a9..fa6fda9ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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 @@ -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"