Skip to content

Fix disabled tests #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/integration/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ describe('interactions', () => {
})
})

describe.only('setFormFieldValue', () => {
describe('setFormFieldValue', () => {
const test = () => {
const newTrackName = { ...trackName, value: 'Pretender' }
setFormFieldValue(newTrackName)
Expand Down
8 changes: 5 additions & 3 deletions cypress/integration/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ describe('getTableColumnSorter', () => {

it('finds column sorter by column label', () => {
getTableColumnSorter(idLabel).should('not.exist')
getTableColumnSorter(nameLabel).should('be.visible').click().should('have.class', 'active')
// Force this because the descending sorter has a negative margin and partially covers the ascending sorter.
getTableColumnSorter(nameLabel).should('be.visible').click({ force: true }).should('have.class', 'active')
})

it('finds column sorter for specific sort order', () => {
getTableColumnSorter(1).click()
// Force this because the descending sorter has a negative margin and partially covers the ascending sorter.
getTableColumnSorter(1).click({ force: true })
getTableColumnSorter(1, { sortOrder: SORT_ORDER.DESCENDING }).should('not.have.class', 'active')
})
})
Expand Down Expand Up @@ -217,7 +219,7 @@ describe('getTableCell', () => {
})
})

describe.only('getTableLoadingIndicator', () => {
describe('getTableLoadingIndicator', () => {
it('finds loading indicator', () => {
renderTable({ loading: true })
getTableLoadingIndicator().should('be.visible')
Expand Down
13 changes: 12 additions & 1 deletion src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ export function getFormField({ label, ...options }: FormFieldOptions & CommonOpt
const opts = logAndMute('getFormField', label, options)
return isUndefined(label)
? cy.get('.ant-form-item', opts)
: getFormFieldLabel({ label, ...opts }).closest('.ant-form-item', opts)
: getFormFieldLabel({ label, ...opts })
// Workaround for https://github.com/cypress-io/cypress/issues/21303.
.should(() => {
// This empty assertion prevents Cypress from failing when the label does not exist.
})
Comment on lines +54 to +56
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite right. It will prevent retries when the label does not exist but should.

.then($label => {
// If the label wasn't found, do the query again but this time with the existence check on.
if ($label.length === 0) {
return getFormFieldLabel({ label, ...opts })
}
return cy.wrap($label).closest('.ant-form-item', opts)
})
}

type FormInputOptions = FormFieldOptions & { type?: FieldType }
Expand Down
10 changes: 6 additions & 4 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ export function filterTableBy(columnIdxOrLabel: number | Label, values: Label[],
absoluteRoot(opts)
.find('.ant-table-filter-dropdown:visible')
.within(() => {
values.forEach(value => cy.contains('.ant-dropdown-menu-item', value).click())
cy.get(`.ant-table-filter-dropdown-btns`)
.find(values.length ? '.ant-btn-primary' : '.ant-btn-link')
.click()
if (values.length === 0) {
cy.get(`.ant-table-filter-dropdown-btns`).find('.ant-btn-link').click()
} else {
values.forEach(value => cy.contains('.ant-dropdown-menu-item', value).click())
}
cy.get(`.ant-table-filter-dropdown-btns`).find('.ant-btn-primary').click()
})
absoluteRoot(opts).find('.ant-table-filter-dropdown').should('not.be.visible')
}
Expand Down