Skip to content

Commit

Permalink
fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Romuald Caplier committed Sep 20, 2024
1 parent 11b719b commit ba93874
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 53 deletions.
8 changes: 6 additions & 2 deletions apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('dashboard', () => {
cy.get('@draft')
.children('div')
.eq(5)
.should('contain', ' Not published ')
.should('include.text', 'Not published')
cy.get('@draft').children('div').eq(6).should('contain', ' - ')
cy.clearRecordDrafts()
})
Expand All @@ -204,7 +204,11 @@ describe('dashboard', () => {
.find('span')
.invoke('text')
.should('eq', 'admin admin')
cy.get('@record').children('div').eq(5).should('contain', ' Published ')
cy.get('@record')
.children('div')
.eq(5)
.find('span')
.should('include.text', 'Published')
cy.get('@record').children('div').eq(6).should('not.contain', ' - ')
cy.clearRecordDrafts()
})
Expand Down
4 changes: 3 additions & 1 deletion apps/metadata-editor-e2e/src/e2e/edit.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable cypress/no-unnecessary-waiting */

describe('editor form', () => {
let recordUuid
let recordUuid: any
before(() => {
cy.login('admin', 'admin', false)
cy.viewport(1920, 2400)

cy.clearRecordDrafts()

Expand Down Expand Up @@ -53,6 +54,7 @@ describe('editor form', () => {
})
beforeEach(() => {
cy.login('admin', 'admin', false)
cy.visit('/catalog/search')
cy.wrap(recordUuid).as('recordUuid')

cy.get('@recordUuid').then((recordUuid) => {
Expand Down
41 changes: 0 additions & 41 deletions apps/metadata-editor-e2e/src/e2e/my-org.cy.ts

This file was deleted.

20 changes: 11 additions & 9 deletions apps/metadata-editor-e2e/src/e2e/record-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('record-actions', () => {
cy.visit('/catalog/search')
})
describe('delete', () => {
const recordId = `TEST_RECORD_${Date.now()}`
describe('record with draft', () => {
it('should delete the record, delete its associated draft and refresh the interface', () => {
// First create a record and its draft
Expand All @@ -13,13 +14,15 @@ describe('record-actions', () => {
.as('abstractField')
.focus()
cy.get('@abstractField').type('record abstract')
cy.get('[data-test="recordTitleInput"]').click()
cy.get('[data-test="recordTitleInput"]').type('{selectAll}{backspace}')
cy.get('[data-test="recordTitleInput"]').type(recordId)
cy.intercept({
method: 'PUT',
pathname: '**/records',
}).as('insertRecord')
cy.get('md-editor-publish-button').click()
cy.wait('@insertRecord')
cy.get('@abstractField').focus()
cy.get('@abstractField').type('draft abstract')
// Assert that the draft exists in the local storage
cy.editor_readFormUniqueIdentifier().then((uniqueIdentifier) =>
Expand All @@ -31,18 +34,17 @@ describe('record-actions', () => {
)
cy.visit('/my-space/my-records')
cy.get('[data-cy="table-row"]')
.contains('My new record')
.contains(recordId)
.should('have.length', 1)
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '1')
// Delete the record
cy.get('[data-test="record-menu-button"]').last().click()
cy.get('[data-test="record-menu-delete-button"]').click()
cy.get('[data-cy="confirm-button"]').click()
cy.get('[data-cy="table-row"]')
.contains('My new record')
.contains(recordId)
.should('have.length', 0)
cy.get('gn-ui-notification').should('contain', 'Delete success')
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '0')
})
})

Expand All @@ -51,6 +53,9 @@ describe('record-actions', () => {
// First create a draft
cy.get('[data-cy="create-record"]').click()
cy.url().should('include', '/create')
cy.get('[data-test="recordTitleInput"]').click()
cy.get('[data-test="recordTitleInput"]').type('{selectAll}{backspace}')
cy.get('[data-test="recordTitleInput"]').type(recordId)
cy.get('gn-ui-form-field[ng-reflect-model=abstract] textarea')
.as('abstractField')
.focus()
Expand All @@ -63,17 +68,14 @@ describe('record-actions', () => {
})
cy.visit('/my-space/my-draft')
cy.get('[data-cy="table-row"]')
.contains('My new record')
.contains(recordId)
.should('have.length', 1)
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '1')
// Delete the draft
cy.get('[data-test="record-menu-button"]').click()
cy.get('[data-test="record-menu-delete-button"]').click()
cy.get('[data-cy="confirm-button"]').click()
cy.get('[data-cy="table-row"]')
.contains('New record')
.should('have.length', 0)
cy.get('[data-cy="dashboard-drafts-count"]').should('contain', '0')
cy.get('[data-cy="table-row"]').should('not.exist')
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<div class="flex flex-row flex-start items-center gap-3 mb-[12px]">
<span
#titleInput
data-test="recordTitleInput"
class="grow font-title text-3xl font-normal"
[gnUiEditableLabel]="valueAsString"
(editableLabelChanged)="valueChange.emit($event)"
Expand Down

0 comments on commit ba93874

Please sign in to comment.