Skip to content

Commit

Permalink
test(cy): use more robust selectors in file picker
Browse files Browse the repository at this point in the history
* Use the selectors used in server to test the files app.
* Rely on semantics (`nav`, `[aria-label=...]`).

Signed-off-by: Max <max@nextcloud.com>
  • Loading branch information
max-nextcloud committed Feb 4, 2024
1 parent 5474c01 commit d2f20b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions cypress/e2e/attachments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ describe('Test all attachment insertion methods', () => {
cy.intercept({ method: 'POST', url: '**/filepath' }).as(requestAlias)

cy.log('Go to sub folder (a)')
cy.get('.file-picker__main .file-picker__file-name[title="sub"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="a"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="a"]').click()
cy.get('.file-picker [data-filename="sub"]').click()
cy.get('.file-picker [data-filename="a"]').click()
cy.get('.file-picker [data-filename="a"]').click()

cy.get('.dialog__actions button.button-vue--vue-primary').click()

Expand All @@ -198,12 +198,12 @@ describe('Test all attachment insertion methods', () => {
cy.intercept({ method: 'POST', url: '**/filepath' }).as(requestAlias)

cy.log('Go back from home to sub folder')
cy.get('.file-picker__breadcrumbs button[title="Home"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="sub"]').click()
cy.get('.file-picker nav [aria-label="Home"]').click()
cy.get('.file-picker [data-filename="sub"]').click()

cy.log('Go to sub folder (b)')
cy.get('.file-picker__main .file-picker__file-name[title="b"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="b"]').click()
cy.get('.file-picker [data-filename="b"]').click()
cy.get('.file-picker [data-filename="b"]').click()

cy.get('.dialog__actions button.button-vue--vue-primary').click()

Expand All @@ -217,10 +217,10 @@ describe('Test all attachment insertion methods', () => {
cy.intercept({ method: 'POST', url: '**/filepath' }).as(requestAlias)

cy.log('Go back to home')
cy.get('.file-picker__breadcrumbs button[title="Home"]').click()
cy.get('.file-picker nav [aria-label="Home"]').click()

cy.log('Select the file in the filepicker')
cy.get('.file-picker__main .file-picker__file-name[title="github"]').click()
cy.get('.file-picker [data-filename="github"]').click()
cy.log('Click OK in the filepicker')
cy.get('.dialog__actions button.button-vue--vue-primary').click()

Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/workspace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ describe('Workspace', function() {
cy.getSubmenuEntry('insert-link', 'insert-link-file')
.click()

cy.get('.file-picker__main .file-picker__file-name[title="sub-folder"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="alpha"]').click()
cy.get('.file-picker__main .file-picker__file-name[title="test"]').click()
cy.get('.file-picker [data-filename="sub-folder"]').click()
cy.get('.file-picker [data-filename="alpha"]').click()
cy.get('.file-picker [data-filename="test"]').click()
cy.get('.dialog__actions button.button-vue--vue-primary').click()

cy.getEditor()
Expand Down

0 comments on commit d2f20b9

Please sign in to comment.