From f00983d15e07a441bf47ee1f9b65a135cbda9630 Mon Sep 17 00:00:00 2001 From: Alex Boatwright Date: Wed, 8 Jan 2020 11:40:49 -0800 Subject: [PATCH 1/3] fix: stop looping so hard --- ui/src/tasks/components/TasksOptionsBucketDropdown.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx b/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx index f6147823c2a..3b65d449aa0 100644 --- a/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx +++ b/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx @@ -112,9 +112,13 @@ class TaskOptionsBucketDropdown extends PureComponent { } private setSelectedToFirst() { - const {buckets, onChangeBucketName} = this.props + const {buckets, selectedBucketName, onChangeBucketName} = this.props const firstBucketNameInList = get(buckets, '0.name', '') + if (firstBucketNameInList === selectedBucketName) { + return + } + onChangeBucketName(firstBucketNameInList) } } From b5bb8219eb9c168727e75ff4abc6818560423e8c Mon Sep 17 00:00:00 2001 From: Alex Boatwright Date: Wed, 8 Jan 2020 13:04:37 -0800 Subject: [PATCH 2/3] feat: adding a test on this one --- ui/cypress/e2e/explorer.test.ts | 26 +++++++++++++++++++ .../components/TasksOptionsBucketDropdown.tsx | 1 + 2 files changed, 27 insertions(+) diff --git a/ui/cypress/e2e/explorer.test.ts b/ui/cypress/e2e/explorer.test.ts index 1c2a45c0792..6a9370bc116 100644 --- a/ui/cypress/e2e/explorer.test.ts +++ b/ui/cypress/e2e/explorer.test.ts @@ -636,6 +636,32 @@ describe('DataExplorer', () => { }) }) + describe('saving', () => { + beforeEach(() => { + cy.fixture('routes').then(({orgs, explorer}) => { + cy.get('@org').then(({id}) => { + cy.visit(`${orgs}/${id}${explorer}/save`) + }) + }) + }) + + describe('as a task', () => { + beforeEach(() => { + cy.getByTestID('task--radio-button') + .click() + }) + + it.only('should autoselect the first bucket', () => { + cy.getByTestID('task-options-bucket-dropdown--button').within(() => { + cy.get('span.cf-dropdown--selected') + .then((elem) => { + expect(elem.text()).to.include('defbuck') + }) + }) + }) + }) + }) + // skipping until feature flag feature is removed for deleteWithPredicate describe.skip('delete with predicate', () => { beforeEach(() => { diff --git a/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx b/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx index 3b65d449aa0..d5aa0f65baf 100644 --- a/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx +++ b/ui/src/tasks/components/TasksOptionsBucketDropdown.tsx @@ -46,6 +46,7 @@ class TaskOptionsBucketDropdown extends PureComponent { active={active} onClick={onClick} status={this.status} + testID="task-options-bucket-dropdown--button" > {selectedBucketName} From b4820da1b10927ed722a54f9359dcff5ece4a1f0 Mon Sep 17 00:00:00 2001 From: Alex Boatwright Date: Wed, 8 Jan 2020 13:09:18 -0800 Subject: [PATCH 3/3] fix: ONLY --- ui/cypress/e2e/explorer.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/cypress/e2e/explorer.test.ts b/ui/cypress/e2e/explorer.test.ts index 6a9370bc116..27e93b92e12 100644 --- a/ui/cypress/e2e/explorer.test.ts +++ b/ui/cypress/e2e/explorer.test.ts @@ -651,7 +651,7 @@ describe('DataExplorer', () => { .click() }) - it.only('should autoselect the first bucket', () => { + it('should autoselect the first bucket', () => { cy.getByTestID('task-options-bucket-dropdown--button').within(() => { cy.get('span.cf-dropdown--selected') .then((elem) => {