fix: bucket save (#14582)

* fix(ui/buckets): close edit bucket modal on save

* test(e2e): test that modal closes after save
pull/14587/head
Andrew Watkins 2019-08-06 14:50:07 -07:00 committed by GitHub
parent 972392f698
commit 6f14174c32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 14 deletions

View File

@ -20,7 +20,7 @@ describe('Buckets', () => {
describe('from the org view', () => { describe('from the org view', () => {
it('can create a bucket', () => { it('can create a bucket', () => {
const newBucket = '🅱ucket' const newBucket = '🅱ucket'
cy.getByTestID('resource-card').should('have.length', 1) cy.getByTestID('bucket--card').should('have.length', 1)
cy.getByTestID('Create Bucket').click() cy.getByTestID('Create Bucket').click()
cy.getByTestID('overlay--container').within(() => { cy.getByTestID('overlay--container').within(() => {
@ -30,19 +30,17 @@ describe('Buckets', () => {
.click() .click()
}) })
cy.getByTestID('resource-card') cy.getByTestID('bucket--card')
.should('have.length', 2) .should('have.length', 2)
.and('contain', newBucket) .and('contain', newBucket)
}) })
it("can update a bucket's retention rules", () => { it.only("can update a bucket's retention rules", () => {
cy.get<Bucket>('@bucket').then(({name}) => { cy.get<Bucket>('@bucket').then(({name}: Bucket) => {
cy.contains(name).click() cy.getByTestID(`bucket--card ${name}`).click()
}) })
cy.contains('Periodically').click() cy.getByTestID('retention-intervals--button').click()
// Switch back to line 47 when radio buttons from clockface support testID
// cy.get('retention-intervals').click()
cy.getByInputName('days').type('{uparrow}') cy.getByInputName('days').type('{uparrow}')
cy.getByInputName('hours').type('{uparrow}') cy.getByInputName('hours').type('{uparrow}')
@ -53,22 +51,33 @@ describe('Buckets', () => {
cy.contains('Save').click() cy.contains('Save').click()
}) })
cy.getByTestID('resource-card').should('contain', '1 day') cy.getByTestID('bucket--card').should('contain', '1 day')
cy.get<Bucket>('@bucket').then(({name}: Bucket) => {
cy.getByTestID(`bucket--card ${name}`).click()
})
cy.getByTestID('retention-never--button').click()
cy.getByTestID('overlay--container').within(() => {
cy.contains('Save').click()
})
cy.getByTestID('overlay--container').should('not.be.visible')
}) })
it.skip('can delete a bucket', () => { it.skip('can delete a bucket', () => {
cy.get<Organization>('@org').then(({id, name}) => { cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, 'newbucket1') cy.createBucket(id, name, 'newbucket1')
cy.createBucket(id, name, 'newbucket2') cy.createBucket(id, name, 'newbucket2')
}) })
cy.getByTestID('resource-card').should('have.length', 3) cy.getByTestID('bucket--card').should('have.length', 3)
cy.getByTestID('confirmation-button') cy.getByTestID('confirmation-button')
.last() .last()
.click({force: true}) .click({force: true})
cy.getByTestID('resource-card').should('have.length', 2) cy.getByTestID('bucket--card').should('have.length', 2)
}) })
}) })
}) })

View File

@ -31,7 +31,7 @@ class BucketRow extends PureComponent<Props & WithRouterProps> {
return ( return (
<> <>
<ResourceCard <ResourceCard
testID="resource-card" testID="bucket--card"
contextMenu={ contextMenu={
<BucketContextMenu <BucketContextMenu
bucket={bucket} bucket={bucket}
@ -45,6 +45,7 @@ class BucketRow extends PureComponent<Props & WithRouterProps> {
} }
name={ name={
<ResourceCard.Name <ResourceCard.Name
testID={`bucket--card ${bucket.name}`}
onClick={this.handleNameClick} onClick={this.handleNameClick}
name={bucket.name} name={bucket.name}
/> />

View File

@ -32,6 +32,7 @@ export default class Retention extends PureComponent<Props> {
<Radio shape={ButtonShape.StretchToFit} className="retention--radio"> <Radio shape={ButtonShape.StretchToFit} className="retention--radio">
<Radio.Button <Radio.Button
id="never" id="never"
testID="retention-never--button"
active={type === null} active={type === null}
onClick={this.handleRadioClick} onClick={this.handleRadioClick}
value={null} value={null}
@ -44,7 +45,7 @@ export default class Retention extends PureComponent<Props> {
active={type === BucketRetentionRules.TypeEnum.Expire} active={type === BucketRetentionRules.TypeEnum.Expire}
onClick={this.handleRadioClick} onClick={this.handleRadioClick}
value={BucketRetentionRules.TypeEnum.Expire} value={BucketRetentionRules.TypeEnum.Expire}
testID="retention-intervals" testID="retention-intervals--button"
titleText="Compress data at regular intervals" titleText="Compress data at regular intervals"
> >
Periodically Periodically

View File

@ -114,6 +114,7 @@ class UpdateBucketOverlay extends PureComponent<Props, State> {
if (ruleType === null) { if (ruleType === null) {
onUpdateBucket({...bucket, retentionRules: []}) onUpdateBucket({...bucket, retentionRules: []})
this.handleClose()
return return
} }