Skip to content

Commit b74a16b

Browse files
committed
enh(Cypress): improve some selectors
Signed-off-by: Cleopatra Enjeck M. <patrathewhiz@gmail.com>
1 parent b6f8131 commit b74a16b

File tree

10 files changed

+52
-47
lines changed

10 files changed

+52
-47
lines changed

cypress/e2e/column-selection.cy.js

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ describe('Test column ' + columnTitle, () => {
1818
beforeEach(function() {
1919
cy.login(localUser)
2020
cy.visit('apps/tables')
21-
})
22-
23-
it('Table and column setup', () => {
2421
cy.createTable(tableTitle)
2522
})
2623

@@ -29,52 +26,52 @@ describe('Test column ' + columnTitle, () => {
2926
cy.createSelectionColumn(columnTitle, ['first option', 'second option', '👋 third option', '🤷🏻 fifths'], 'second option', true)
3027

3128
// check if default value is set on row creation
32-
cy.get('button').contains('Create row').click()
33-
cy.get('.modal-container__content h2').contains('Create row').should('be.visible')
34-
cy.get('.modal__content .title').contains(columnTitle).should('be.visible')
35-
cy.get('.modal__content .title').click()
29+
cy.get('[data-cy="createRowBtn"]').click()
30+
cy.get('[data-cy="createRowModal"]').should('be.visible')
31+
cy.get('[data-cy="createRowModal"] .title').should('be.visible')
32+
cy.get('[data-cy="createRowModal"] .title').click()
3633
cy.get('.vs__dropdown-toggle .vs__selected span[title="second option"]').should('exist')
37-
cy.get('button').contains('Save').click()
38-
cy.get('.custom-table table tr td div').contains('second option').should('be.visible')
34+
cy.get('[data-cy="createRowSaveButton"]').click()
35+
cy.get('[data-cy="ncTable"] tr td div').contains('second option').should('be.visible')
3936

4037
// create a row and select non default value
4138
cy.get('button').contains('Create row').click()
42-
cy.get('.modal__content .slot input').first().click()
39+
cy.get('[data-cy="createRowModal"] .slot input').first().click()
4340
cy.get('ul.vs__dropdown-menu li span[title="👋 third option"]').click()
44-
cy.get('button').contains('Save').click()
45-
cy.get('.custom-table table tr td div').contains('third option').should('be.visible')
41+
cy.get('[data-cy="createRowSaveButton"]').click()
42+
cy.get('[data-cy="ncTable"] tr td div').contains('third option').should('be.visible')
4643

4744
// delete first row
48-
cy.get('.NcTable tr td button').first().click()
49-
cy.get('button').contains('Delete').click()
50-
cy.get('button').contains('I really').click()
51-
cy.get('.custom-table table tr td div').contains('second').should('not.exist')
45+
cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').first().click()
46+
cy.get('[data-cy="editRowDeleteButton"]').click({ force: true })
47+
cy.get('[data-cy="editRowDeleteConfirmButton"]').click({ force: true })
48+
cy.get('[data-cy="ncTable"] tr td div').contains('second').should('not.exist')
5249

5350
// edit second row
54-
cy.get('.NcTable tr td button').first().click()
55-
cy.get('.modal__content .slot input').first().click()
51+
cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').first().click()
52+
cy.get('[data-cy="editRowModal"] .slot input').first().click()
5653
cy.get('ul.vs__dropdown-menu li span[title="first option"]').click()
57-
cy.get('button').contains('Save').click()
58-
cy.get('.custom-table table tr td div').contains('first option').should('be.visible')
54+
cy.get('[data-cy="editRowSaveButton"]').click()
55+
cy.get('[data-cy="ncTable"] tr td div').contains('first option').should('be.visible')
5956

6057
// delete first row
61-
cy.get('.NcTable tr td button').first().click()
62-
cy.get('button').contains('Delete').click()
63-
cy.get('button').contains('I really').click()
58+
cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').first().click()
59+
cy.get('[data-cy="editRowDeleteButton"]').click({ force: true })
60+
cy.get('[data-cy="editRowDeleteConfirmButton"]').click({ force: true })
6461

65-
cy.removeColumn(columnTitle)
62+
cy.deleteTable(tableTitle)
6663
})
6764

6865
it('Test empty selection', () => {
6966
cy.loadTable(tableTitle)
7067
cy.createSelectionColumn(columnTitle, ['first option', 'second option', '👋 third option', '🤷🏻 fifths'], null, true)
7168

7269
// check if default value is set on row creation
73-
cy.get('button').contains('Create row').click()
74-
cy.get('.modal-container__content h2').contains('Create row').should('be.visible')
75-
cy.get('button').contains('Save').click()
76-
cy.get('.custom-table table tr td div').should('exist')
77-
cy.get('.NcTable tr td button').should('exist')
70+
cy.get('[data-cy="createRowBtn"]').click()
71+
cy.get('[data-cy="createRowModal"]').should('be.visible')
72+
cy.get('[data-cy="createRowSaveButton"]').click()
73+
cy.get('[data-cy="ncTable"] tr td div').should('exist')
74+
cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').should('exist')
7875
})
7976

8077
})

cypress/e2e/context.cy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ describe('Manage a context', () => {
112112

113113
// verify that context was deleted from current user
114114
cy.get(`[data-cy="navigationContextItem"]:contains("${contextTitle}")`).find('button').click({ force: true })
115+
cy.wait(1000)
115116
cy.get('[data-cy="navigationContextDeleteBtn"]').contains('Delete application').click({ force: true })
116117
cy.get('[data-cy="deleteContextModal"]').should('be.visible')
117118
cy.get('[data-cy="deleteContextModal"] button').contains('Delete').click()
@@ -196,7 +197,7 @@ describe('Manage a context', () => {
196197
cy.get('[data-cy="ncTable"] table').contains('first row').should('exist')
197198
cy.get('[data-cy="ncTable"] table').contains('first row').parent().parent().find('[aria-label="Edit row"]').click()
198199
cy.get('[data-cy="editRowDeleteButton"]').click()
199-
cy.get('[data-cy="editRowEditConfirmButton"]').click()
200+
cy.get('[data-cy="editRowDeleteConfirmButton"]').click()
200201
cy.get('[data-cy="ncTable"] table').contains('first row').should('not.exist')
201202
})
202203
})

cypress/e2e/tables-table.cy.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,14 @@ describe('Manage a table', () => {
7575
})
7676

7777
it('Delete', () => {
78-
cy.get('.app-navigation__list').contains('ToDo list').click({ force: true })
79-
cy.get('[data-cy="customTableAction"] button').click()
80-
cy.get('.action-button__text').contains('Edit table').click()
81-
82-
cy.get('.modal-container button').contains('Delete').click()
83-
cy.get('.modal-container button').contains('I really want to delete this table!').click()
84-
85-
cy.wait(10).get('.toastify.toast-success').should('be.visible')
86-
cy.get('.app-navigation__list').contains('to do list').should('not.exist')
78+
cy.deleteTable('ToDo list')
8779
})
8880

8981
it('Transfer', () => {
9082
cy.get('.icon-loading').should('not.exist')
9183
cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true })
9284
cy.get('.tile').contains('ToDo').click({ force: true })
93-
cy.get('.modal__content input[type="text"]').clear().type('test table')
85+
cy.get('[data-cy="createTableModal"] input[type="text"]').clear().type('test table')
9486
cy.contains('button', 'Create table').click()
9587

9688
cy.get('.app-navigation__list').contains('test table').click({ force: true })

cypress/e2e/view.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('Interact with views', () => {
126126
// Delete rows in the view
127127
cy.get('[data-cy="customTableRow"]').contains('first row').parent().parent().find('[data-cy="editRowBtn"]').click()
128128
cy.get('[data-cy="editRowModal"] [data-cy="editRowDeleteButton"]').contains('Delete').click()
129-
cy.get('[data-cy="editRowModal"] [data-cy="editRowEditConfirmButton"]').contains('I really want to delete this row!').click()
129+
cy.get('[data-cy="editRowModal"] [data-cy="editRowDeleteConfirmButton"]').contains('I really want to delete this row!').click()
130130

131131
cy.get('[data-cy="editRowModal"]').should('not.exist')
132132
cy.get('[data-cy="customTableRow"]').contains('first row').should('not.exist')

cypress/support/commands.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ Cypress.Commands.add('createTable', (title) => {
8686
cy.contains('h1', title).should('be.visible')
8787
})
8888

89+
Cypress.Commands.add('deleteTable', (title) => {
90+
cy.get('[data-cy="navigationTableItem"]').contains(title).click({ force: true })
91+
cy.get('[data-cy="customTableAction"] button').click()
92+
cy.get('[data-cy="dataTableEditTableBtn"]').click()
93+
cy.get('[data-cy="editTableModal"] [data-cy="editTableDeleteBtn"]').click()
94+
cy.get('[data-cy="editTableModal"] [data-cy="editTableConfirmDeleteBtn"]').click()
95+
cy.wait(10).get('.toastify.toast-success').should('be.visible')
96+
cy.get('[data-cy="navigationTableItem"]').contains('to do list').should('not.exist')
97+
})
98+
8999
Cypress.Commands.add('createView', (title) => {
90100
cy.get('[data-cy="customTableAction"] button').click()
91101
cy.get('[data-cy="dataTableCreateViewBtn"]').contains('Create view').click({ force: true })
@@ -123,6 +133,7 @@ Cypress.Commands.add('createContext', (title) => {
123133

124134
Cypress.Commands.add('openContextEditModal', (title) => {
125135
cy.get(`[data-cy="navigationContextItem"]:contains("${title}")`).find('button').click({ force: true })
136+
cy.wait(1000)
126137
cy.get('[data-cy="navigationContextEditBtn"]').contains('Edit application').click({ force: true })
127138
cy.get('[data-cy="editContextModal"]').should('be.visible')
128139
})
@@ -142,7 +153,7 @@ Cypress.Commands.add('sortTableColumn', (columnTitle, mode = 'ASC') => {
142153
})
143154

144155
Cypress.Commands.add('loadTable', (name) => {
145-
cy.get('[data-cy="navigationTableItem"] a[title="' + name + '"]').click({ force: true })
156+
cy.get('[data-cy="navigationTableItem"] a[title="' + name + '"]').last().click({ force: true })
146157
})
147158

148159
Cypress.Commands.add('getTutorialTableName', () => {

src/modules/main/sections/DataTable.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<IconTool :size="20" />
1414
</template>
1515
<NcActionCaption v-if="canManageElement(table)" :name="t('tables', 'Manage table')" />
16-
<NcActionButton v-if="canManageElement(table) "
16+
<NcActionButton v-if="canManageElement(table)"
17+
data-cy="dataTableEditTableBtn"
1718
:close-after-click="true"
1819
@click="emit('tables:table:edit', table.id)">
1920
<template #icon>

src/modules/modals/EditRow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{{ t('tables', 'Delete') }}
2525
</NcButton>
2626
<NcButton v-if="prepareDeleteRow"
27-
data-cy="editRowEditConfirmButton"
27+
data-cy="editRowDeleteConfirmButton"
2828
:wide="true"
2929
:aria-label="t('tables', 'I really want to delete this row!')"
3030
type="error"

src/modules/modals/EditTable.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@
4848
</div>
4949
<div class="row">
5050
<div class="fix-col-4 space-T justify-between">
51-
<NcButton v-if="!prepareDeleteTable" type="error" @click="prepareDeleteTable = true">
51+
<NcButton v-if="!prepareDeleteTable" type="error" data-cy="editTableDeleteBtn" @click="prepareDeleteTable = true">
5252
{{ t('tables', 'Delete') }}
5353
</NcButton>
5454
<NcButton v-if="prepareDeleteTable"
5555
:wide="true"
5656
type="error"
57+
data-cy="editTableConfirmDeleteBtn"
5758
@click="actionDeleteTable">
5859
{{ t('tables', 'I really want to delete this table!') }}
5960
</NcButton>

src/modules/modals/TransferContext.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
<NcDialog v-if="showModal"
77
:name="t('tables', 'Transfer application')"
88
size="normal"
9+
data-cy="transferContextModal"
910
@closing="actionCancel">
10-
<div class="modal__content" data-cy="transferContextModal">
11+
<div class="modal__content">
1112
<div class="row">
1213
<h3>{{ t('tables', 'Transfer the application "{context}" to another user', { context: context.name }) }}</h3>
1314
<NcUserPicker :select-users="true" :select-groups="false" :selected-user-id.sync="newOwnerId" />

src/modules/modals/TransferTable.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
<template>
66
<NcDialog v-if="showModal"
77
:name="t('tables', 'Transfer table')"
8+
data-cy="transferTableModal"
89
size="normal"
910
@closing="actionCancel">
10-
<div class="modal__content" data-cy="transferTableModal">
11+
<div class="modal__content">
1112
<div class="row">
1213
<h3>{{ t('tables', 'Transfer this table to another user') }}</h3>
1314
<NcUserPicker :select-users="true" :select-groups="false" :selected-user-id.sync="selectedUserId" />

0 commit comments

Comments
 (0)