Skip to content
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

feat(ui): added labels to buckets #16855

Merged
merged 16 commits into from
Feb 13, 2020
Merged

feat(ui): added labels to buckets #16855

merged 16 commits into from
Feb 13, 2020

Conversation

asalem1
Copy link
Contributor

@asalem1 asalem1 commented Feb 13, 2020

Closes #16740

Problem

Buckets did not have labels

Solution

Added labels to buckets, normalized some data, add buckets label test

bucket_labels

  • CHANGELOG.md updated with a link to the PR (not the Issue)

@asalem1 asalem1 changed the title Bucket labels feat(ui): added labels to buckets Feb 13, 2020
@@ -61,7 +61,7 @@ const UpdateBucketOverlay: FunctionComponent<Props> = ({
handleClose()
return
}
setBucketDraft(resp.data)
setBucketDraft(resp.data as Bucket)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

setting this type here as a way of resolving a TS error that stemmed from a disparity between the expectations of the useState func and the data type being returned by the getBucket function

@desa desa requested a review from ebb-tide February 13, 2020 16:48
@@ -61,27 +75,28 @@ describe('Buckets', () => {
describe('Searching and Sorting', () => {
it('can sort by name and retention', () => {
cy.getByTestID('name-sorter').click()
cy.getByTestID('bucket-card')

cy.get('.cf-resource-card')
Copy link
Contributor

Choose a reason for hiding this comment

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

why did these get less specific? that's a trigger to go add testID params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great question. The original was created to test out the sort order. In order to validate those assumptions, we were getting all the bucket-cards (previously by a less specific test-ID that worked). Then we were clicking the sort order to see if the first value changed (since it should've been reflected in the UI). I tried creating a solution where we were getting the resource list body and seeing if the children were in a particular order, but couldn't get that configured in cypress. The solution I came up with was to revert to the original construct (generalized grab all the cards), then see if the first one matched our expectations when changing the sort order

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. So the label tests are working magically without any issue because of the specificity added to the test-IDs.

What you linked seems to be a much better way of addressing the tests. I'll go ahead and refactor it so it looks like:

https://github.com/influxdata/influxdb/blob/master/ui/cypress/e2e/collectors.test.ts#L236-L238

<ResourceList.Body emptyState={emptyState}>
{this.listBuckets}
</ResourceList.Body>
<GetResources resources={[ResourceType.Labels]}>
Copy link
Contributor

Choose a reason for hiding this comment

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

can we put this next to where buckets are fetched?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@drdelambre when I did, the empty state was never fulfilled, so I moved it out one layer (by empty state, I mean there's a message that's typically displayed when there are no buckets output in a search)

Copy link
Contributor

Choose a reason for hiding this comment

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

here i think:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally, good eye

cy.getByTestID('name-sorter')
.click()
.then(() => {
cy.get('.cf-resource-name').each((val, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

still have to change this (and change bucket + name back to bucket on the testid in the component)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why is that? We changed it for greater specificity to access a specific bucket card.

Copy link
Contributor

Choose a reason for hiding this comment

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

so use that specificity in the test by generating ids to look up (instead of evaluating the text value). i think we're still straddling two solutions right now and just need to pick one and push it through.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@drdelambre i'm not quite sure I understand your solution, would you mind expanding upon that with an example of what you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah. so you have the name of the resource in both the test id and in the text content of the dom node you are trying to pinpoint. So you have two sources of truth, and two directions to go to unify them:

  1. revert the test id specificity in the component, and test that the value within the component (with expect(val.text()).to.include(buckets[index])) is equal to the resource name. that keeps things scoped to buckets (good) but also ties the representation of the key to the value of the key (bad).
  2. don't test for the value of the node, but instead look for the test id that meets the key you are looking for( cy.getByTestId(`bucket ${cool name}`) ). this scopes it to the bucket (good) as well as decouples the representation from the state (good)

seems like you're leaning towards #2. either one is fine, it's just that generic resource selector has got to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but wouldn't the second solution defeat the purpose of the test? If we're trying to test the sorting mechanism to present a specific order, targeting a bucket by the name would only validate that the bucket exists. It wouldn't represent the order with which that bucket exists in the context of the page

Copy link
Contributor

@drdelambre drdelambre left a comment

Choose a reason for hiding this comment

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

feature work looks great. thanks for taking the time to hone in on that test!

@asalem1 asalem1 merged commit 47ab6d6 into master Feb 13, 2020
@asalem1 asalem1 deleted the bucket-labels branch February 13, 2020 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add labels to buckets
2 participants