Skip to content
This repository was archived by the owner on Jun 24, 2021. It is now read-only.

Fix disabled progress buttons, add tests#25

Merged
bobheadxi merged 9 commits into
masterfrom
web/bugfix/progress-disabled
Aug 7, 2018
Merged

Fix disabled progress buttons, add tests#25
bobheadxi merged 9 commits into
masterfrom
web/bugfix/progress-disabled

Conversation

@bobheadxi

Copy link
Copy Markdown
Contributor

👷 Changes

Fix disabled progress buttons, add tests - still WIP

💭 Notes

n/a

🔦 Testing Instructions

make test

@coveralls

coveralls commented Jul 31, 2018

Copy link
Copy Markdown

Coverage Status

Coverage increased (+2.4%) to 36.512% when pulling fa0dd52 on web/bugfix/progress-disabled into d1e249a on master.

@bobheadxi

Copy link
Copy Markdown
Contributor Author

Reminder on this @chamkank @mingyokim

@mingyokim mingyokim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some minor comments on tests, otherwise looks good! tried it on my local as well

});

test('active button should have class "active"', () => {
expect(wrapper.childAt(activeIndex).hasClass('active')).toBeTruthy();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could also iterate through all the buttons to check that the non-active buttons don't have the class active


describe('when some steps are disabled', () => {
const count = 4;
const lastActiveIndex = 4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm confused... why is lastActiveIndex 4? The max it can be should be 3 based on count

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's very important - makes it easy to enable all buttons by setting lastActiveIndex as 999

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh yeah but i think this test is trying to test when some steps are disabled - so why is it enabling all buttons?

@bobheadxi bobheadxi Aug 1, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh wait, this isn't used at all:

     wrapper = getWrapper({
        count,
        onClick: (i) => { clicked = i; },
        activeIndex: 1,
        lastActiveIndex: count / 2,
      });

ill change this oops

for (let i = 0; i < count; i += 1) {
wrapper.childAt(i).simulate('click');
if (i <= lastActiveIndex) {
expect(clicked).toEqual(i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we could also test that the component has disabled property, especially since "Enzyme click simulations do not respect 'disabled' attribute" as you've mentioned.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's on the next line:

        if (i <= lastActiveIndex) {
          expect(clicked).toEqual(i);
        } else {
          expect(wrapper.childAt(i).props().disabled).toBeTruthy();

          // Enzyme click simulations do not respect 'disabled' attribute.
          // See https://github.com/airbnb/enzyme/issues/386
          // expect(clicked).not.toEqual(i)
        }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh sorry, i meant to test that the component does NOT have disabled property when it's less than lastActiveIndex

i.e. expect(wrapper.childAt(i).props().disabled).toBeFalsy();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure!

@bobheadxi bobheadxi requested a review from mingyokim August 1, 2018 06:07
for (let i = 0; i < count; i += 1) {
wrapper.find('button').at(i).simulate('click');
if (i <= lastValidIndex) {
expect(clicked).toEqual(i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we test that the prop does not have disabled property when it's less than lastActiveIndex?

i.e. expect(wrapper.childAt(i).props().disabled).toBeFalsy();

I think it's especially important here since enzyme click simulations don't work with disabled attribute - onClick can be triggered even if the button is disabled, so testing that onClick is triggered by itself would not guarantee that the button is not disabled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

true - see fa0dd52

@bobheadxi bobheadxi requested a review from mingyokim August 2, 2018 06:56

@mingyokim mingyokim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry for the delay, but looks good!!

@bobheadxi

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @mingyokim

@bobheadxi bobheadxi merged commit 69b4409 into master Aug 7, 2018
@bobheadxi bobheadxi deleted the web/bugfix/progress-disabled branch August 7, 2018 01:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants