Skip to content

Commit 29f8860

Browse files
committed
Add an e2e test conditional buttons.
1 parent c9f5440 commit 29f8860

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

apps/sensenet/cypress/e2e/setup/setup.cy.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ describe('Setup', () => {
4242
it('should open a binary editor with the content of the "settings item" if Edit button is clicked', () => {
4343
cy.get('[data-test="content-card-documentpreview.settings"]')
4444
.within(() => {
45-
cy.get('[data-test="documentpreview.settings-edit-button"]').click()
45+
cy.get('[data-test="documentpreview-edit-button"]').click()
4646
})
4747
.get('[data-test="editor-title"]')
4848
.should('have.text', 'DocumentPreview.settings')
4949
})
5050

5151
it('should open the document of the selected "settings item" if "Learn more" button is clicked', () => {
5252
cy.get('[data-test="content-card-documentpreview.settings"]').within(() => {
53-
cy.get('[data-test="content-card-learnmore-button"]')
54-
.get('a[href="https://docs.sensenet.com/concepts/basics/07-settings#documentpreview-settings"]')
53+
cy.get('[data-test="documentpreview-learnmore-button"]')
54+
.get('a[href="https://docs.sensenet.com/guides/settings/setup#documentpreview-settings"]')
5555
.should('have.attr', 'target', '_blank')
5656
})
5757
})
@@ -86,6 +86,23 @@ describe('Setup', () => {
8686
})
8787
})
8888

89+
it('check white- and blacklisted buttons', () => {
90+
// custom settings can be deleted and never hasn't documentation
91+
cy.get(`[data-test="testsettings-delete-button"]`).should('exist')
92+
cy.get(`[data-test="testsettings-edit-button"]`).should('exist')
93+
cy.get(`[data-test="testsettings-learnmore-button"]`).should('not.exist')
94+
95+
// indexing is system and documented
96+
cy.get(`[data-test="indexing-delete-button"]`).should('not.exist')
97+
cy.get(`[data-test="indexing-edit-button"]`).should('exist')
98+
cy.get(`[data-test="indexing-learnmore-button"]`).should('exist')
99+
100+
// logging is system and not documented
101+
cy.get(`[data-test="logging-delete-button"]`).should('not.exist')
102+
cy.get(`[data-test="logging-edit-button"]`).should('exist')
103+
cy.get(`[data-test="logging-learnmore-button"]`).should('not.exist')
104+
})
105+
89106
it('should delete a setup file', () => {
90107
cy.get('[data-test="settings-container"]').then((grid) => {
91108
cy.scrollToItem({

apps/sensenet/src/components/settings/content-card.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type ContentCardProps = {
5555

5656
const hasDocumentation = ['Portal', 'OAuth', 'DocumentPreview', 'OfficeOnline', 'Indexing', 'Sharing']
5757
const isSystemSettings = [
58+
'DocumentPreview',
5859
'OAuth',
5960
'OfficeOnline',
6061
'Indexing',
@@ -75,9 +76,10 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
7576
const uiSettings = useContext(ResponsivePersonalSettings)
7677
const history = useHistory()
7778
const classes = useStyles()
79+
const { openDialog } = useDialog()
7880
const settingsName = settings.DisplayName || settings.Name
7981
const settingsTitle = settingsName.replace(/\.settings/gi, '')
80-
const { openDialog } = useDialog()
82+
const dataTestName = settingsTitle.replace(/\s+/g, '-').toLowerCase()
8183

8284
return (
8385
<Card
@@ -102,7 +104,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
102104
<CardActions style={{ justifyContent: 'flex-end' }}>
103105
{!isSystemSettings.includes(settingsTitle) && (
104106
<IconButton
105-
data-test="batch-delete"
107+
data-test={`${dataTestName}-delete-button`}
106108
aria-label="delete"
107109
onClick={() => {
108110
openDialog({
@@ -121,8 +123,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
121123
aria-label={localization.edit}
122124
size="small"
123125
className={classes.button}
124-
//style={{ marginRight: '35px' }}
125-
data-test={`${settings.Name.replace(/\s+/g, '-').toLowerCase()}-edit-button`}>
126+
data-test={`${dataTestName}-edit-button`}>
126127
{localization.edit}
127128
</Button>
128129
</Link>
@@ -136,7 +137,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
136137
aria-label={localization.learnMore}
137138
size="small"
138139
className={classes.button}
139-
data-test="content-card-learnmore-button">
140+
data-test={`${dataTestName}-learnmore-button`}>
140141
{localization.learnMore}
141142
</Button>
142143
</a>

0 commit comments

Comments
 (0)