Skip to content

Write tests for SelectedLicense component #39

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

Closed
akmadian opened this issue Sep 19, 2019 · 19 comments
Closed

Write tests for SelectedLicense component #39

akmadian opened this issue Sep 19, 2019 · 19 comments
Assignees
Labels
💻 aspect: code Concerns the software code in the repository 🤖 aspect: dx Concerns developers' experience with the codebase good first issue New-contributor friendly help wanted Open to participation from the community

Comments

@akmadian
Copy link
Member

Describe the solution you'd like
e2e and unit tests need to be written for the SelectedLicense.vue component (./src/components/SelectedLicense.vue). Please write e2e tests in a new file named SelectedLicense.js in ./test/e2e/specs/, and unit tests in a new file named SelectedLicense.specs.js in ./test/unit/specs/.

The frameworks being used are (Jest)[https://jestjs.io/] for unit testing, and the (nightwatch.js)[https://nightwatchjs.org/] for e2e testing.

Additional context
Please comment on this issue to tell us that you're interested in working on it before getting started!

@akmadian akmadian added help wanted Open to participation from the community good first issue New-contributor friendly outreachy labels Sep 19, 2019
@killvung
Copy link

killvung commented Sep 24, 2019

I am interested at the issue, but have some questions regarding to the libraries we used for testing. I looked at the example file HelloWorld.spec.js, and learn that the test will mount an actual Vue component then verify the content through querySelector. Thought it's just an example, instead of querying each part for content, can we use
the library vue-test-utils along with jest snapshot? Documentation? This will make the unit tests more efficient. For example this is an example where I shallow render the SelectedLicense component, then capture the snapshot.

import { shallowMount } from '@vue/test-utils'
import SelectedLicense from '@/components/SelectedLicense'

describe('SelectedLicense', () => {
    it('should render correct contents', () => {
        const wrapper = shallowMount(SelectedLicense, {
            propsData: {
                fullLicenseName: '',
                shortLicenseName: ''
            }
        })
        expect(wrapper.element).toMatchSnapshot()
    })
})

snapshot

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HelloWorld.vue should render correct contents 1`] = `
<div
  id="SelectedLicense"
>
  <div
    class="card chooser-selected"
  >
    <header
      class="card-header"
    >
      <h2
        class="title is-2"
      >
        Selected License
      </h2>
    </header>
     
    <div
      class="card-content"
    >
      <div>
        <licenseiconography-stub
          iconlist=","
        />
         
        <div
          class="selected-license-names"
        >
          <b
            class="selected-license-name"
          >
            
          </b>
           
          <a
            class="help"
            href="chooser.selected_license_link"
          >
            
          </a>
        </div>
      </div>
       
      <licensedescription-stub
        selectedlicense=""
      />
    </div>
  </div>
</div>
`;

@akmadian
Copy link
Member Author

akmadian commented Sep 25, 2019

You're all good to start working on this issue! I just pushed some changes, please pull them to your fork before getting started.

RE using vue-testing-utils, I think this should be alright. However, please make sure to not just test the template, also test that the content (license name(s), the link to the license info, etc.) is being tested as well.

Some things to keep in mind:

  • For components that require interaction, i.e. the IconSelector component, this will not replace nightwatch e2e testing.
  • The component will not work correctly if empty strings are passed as props. The props must be valid license names. I would like to see multiple license names being tested as well, not just cc by :)

@deboragaleano
Copy link

Hi @akmadian, I'm an Outreachy applicant and was wondering if this issue has been assigned already. If not, I'b interested in working on it. Thank you!

@killvung
Copy link

killvung commented Oct 3, 2019

I only have the discussion about the tools we can use for testing, so I haven't start picking up the issue yet. Feel free to claim it if you wish.

@deboragaleano
Copy link

Thanks @killvung, I have just being assigned other issues so I give this back to you :)

@akmadian
Copy link
Member Author

Hey @killvung, I'm going to free this issue up for others to take a shot at since It's been a while since you've posted in this thread, and there's no activity on your fork of the repo.

@obulat
Copy link
Contributor

obulat commented Oct 14, 2019

Hi, @akmadian, can I take up this issue as well?
I'm also an Outreachy applicant, by the way.

@akmadian
Copy link
Member Author

@obulat, I’m going to say no for now to try and give someone else a shot at an issue in the repo since you’ve already done one

@DevchamploO
Copy link

Hey @akmadian, I am an Outreachy applicant. Has this issue been assigned, I would like to work on it if available?

@akmadian
Copy link
Member Author

@DevchamploO go ahead :)

@DevchamploO
Copy link

Thanks, I'll get started!

@akmadian
Copy link
Member Author

Hey @DevchamploO, if I don't see any indication of progress on this issue in the next two days, I'll have to free up the issue so that someone else can work on it.

@akmadian
Copy link
Member Author

akmadian commented Nov 5, 2019

I'm gonna free this issue up because there have been long periods of inactivity, with the only progress being made when I warned the assignee that I was going to free it up if I didn't see more progress soon.

@onyijne
Copy link
Contributor

onyijne commented Nov 6, 2019

@akmadian I have made a contribution during the contribution period, can I also contribute to this?

@akmadian
Copy link
Member Author

akmadian commented Nov 8, 2019

Yep, go ahead! @onyijne

@onyijne
Copy link
Contributor

onyijne commented Nov 11, 2019

okay will start right away

@akmadian
Copy link
Member Author

Hey @onyijne, I haven't seen any progress on this issue in about a week. Please make some more progress in the next couple days, or I will unassign you so others have a chance to contribute.

@onyijne
Copy link
Contributor

onyijne commented Nov 21, 2019 via email

@akmadian
Copy link
Member Author

Closing because no longer relevant, most tests will need to be rewritten after the redesign is done.

@dhruvkb dhruvkb added 💻 aspect: code Concerns the software code in the repository 🤖 aspect: dx Concerns developers' experience with the codebase and removed test-coverage labels Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🤖 aspect: dx Concerns developers' experience with the codebase good first issue New-contributor friendly help wanted Open to participation from the community
Projects
None yet
7 participants