From 29f8860b1643f535d1eab95dda17097910621d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Gyebrovszki?= Date: Fri, 17 Nov 2023 09:47:32 +0100 Subject: [PATCH] Add an e2e test conditional buttons. --- apps/sensenet/cypress/e2e/setup/setup.cy.ts | 23 ++++++++++++++++--- .../src/components/settings/content-card.tsx | 11 +++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/apps/sensenet/cypress/e2e/setup/setup.cy.ts b/apps/sensenet/cypress/e2e/setup/setup.cy.ts index b70deb140..708a8d6d9 100644 --- a/apps/sensenet/cypress/e2e/setup/setup.cy.ts +++ b/apps/sensenet/cypress/e2e/setup/setup.cy.ts @@ -42,7 +42,7 @@ describe('Setup', () => { it('should open a binary editor with the content of the "settings item" if Edit button is clicked', () => { cy.get('[data-test="content-card-documentpreview.settings"]') .within(() => { - cy.get('[data-test="documentpreview.settings-edit-button"]').click() + cy.get('[data-test="documentpreview-edit-button"]').click() }) .get('[data-test="editor-title"]') .should('have.text', 'DocumentPreview.settings') @@ -50,8 +50,8 @@ describe('Setup', () => { it('should open the document of the selected "settings item" if "Learn more" button is clicked', () => { cy.get('[data-test="content-card-documentpreview.settings"]').within(() => { - cy.get('[data-test="content-card-learnmore-button"]') - .get('a[href="https://docs.sensenet.com/concepts/basics/07-settings#documentpreview-settings"]') + cy.get('[data-test="documentpreview-learnmore-button"]') + .get('a[href="https://docs.sensenet.com/guides/settings/setup#documentpreview-settings"]') .should('have.attr', 'target', '_blank') }) }) @@ -86,6 +86,23 @@ describe('Setup', () => { }) }) + it('check white- and blacklisted buttons', () => { + // custom settings can be deleted and never hasn't documentation + cy.get(`[data-test="testsettings-delete-button"]`).should('exist') + cy.get(`[data-test="testsettings-edit-button"]`).should('exist') + cy.get(`[data-test="testsettings-learnmore-button"]`).should('not.exist') + + // indexing is system and documented + cy.get(`[data-test="indexing-delete-button"]`).should('not.exist') + cy.get(`[data-test="indexing-edit-button"]`).should('exist') + cy.get(`[data-test="indexing-learnmore-button"]`).should('exist') + + // logging is system and not documented + cy.get(`[data-test="logging-delete-button"]`).should('not.exist') + cy.get(`[data-test="logging-edit-button"]`).should('exist') + cy.get(`[data-test="logging-learnmore-button"]`).should('not.exist') + }) + it('should delete a setup file', () => { cy.get('[data-test="settings-container"]').then((grid) => { cy.scrollToItem({ diff --git a/apps/sensenet/src/components/settings/content-card.tsx b/apps/sensenet/src/components/settings/content-card.tsx index 0462938ea..5dc32247f 100644 --- a/apps/sensenet/src/components/settings/content-card.tsx +++ b/apps/sensenet/src/components/settings/content-card.tsx @@ -55,6 +55,7 @@ type ContentCardProps = { const hasDocumentation = ['Portal', 'OAuth', 'DocumentPreview', 'OfficeOnline', 'Indexing', 'Sharing'] const isSystemSettings = [ + 'DocumentPreview', 'OAuth', 'OfficeOnline', 'Indexing', @@ -75,9 +76,10 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => { const uiSettings = useContext(ResponsivePersonalSettings) const history = useHistory() const classes = useStyles() + const { openDialog } = useDialog() const settingsName = settings.DisplayName || settings.Name const settingsTitle = settingsName.replace(/\.settings/gi, '') - const { openDialog } = useDialog() + const dataTestName = settingsTitle.replace(/\s+/g, '-').toLowerCase() return ( { {!isSystemSettings.includes(settingsTitle) && ( { openDialog({ @@ -121,8 +123,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => { aria-label={localization.edit} size="small" className={classes.button} - //style={{ marginRight: '35px' }} - data-test={`${settings.Name.replace(/\s+/g, '-').toLowerCase()}-edit-button`}> + data-test={`${dataTestName}-edit-button`}> {localization.edit} @@ -136,7 +137,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => { aria-label={localization.learnMore} size="small" className={classes.button} - data-test="content-card-learnmore-button"> + data-test={`${dataTestName}-learnmore-button`}> {localization.learnMore}