Skip to content

Add integration tests for search by a catalog in user's collection #1097

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
0pdd opened this issue Jul 22, 2019 · 15 comments
Closed

Add integration tests for search by a catalog in user's collection #1097

0pdd opened this issue Jul 22, 2019 · 15 comments
Assignees
Labels
area/integration tests estimation/30m Estimated time: 30 minutes kind/task Task that is part of some feature
Milestone

Comments

@0pdd
Copy link

0pdd commented Jul 22, 2019

The puzzle 673-67e9da55 from #673 has to be resolved:

<!-- @todo #673 Add integration tests for search by a catalog in user's collection -->

The puzzle was created by Mukesh Katariya on 22-Jul-19.

@0pdd 0pdd added the techdebt label Jul 22, 2019
@php-coder php-coder changed the title Add integration tests for search by a catalog in user's collection --> Add integration tests for search by a catalog in user's collection Jul 22, 2019
@php-coder php-coder added this to the 0.4.1 milestone Jul 22, 2019
@php-coder php-coder added kind/task Task that is part of some feature and removed techdebt labels Jul 22, 2019
@mukeshk
Copy link
Contributor

mukeshk commented Jul 24, 2019

How do we enable the feature in the test case?

@php-coder
Copy link
Owner

That's a good question, let's enable it then! (To make life easier to us.)

@mukeshk
Copy link
Contributor

mukeshk commented Jul 25, 2019

Are this test-cases scenario good?

-search\access
`An Anonymous user cannot request search in his collection
Page Should Not Contain Element id=in-collection

An Authorized user can request search in his collection
Log In As login=admin password=test
Page Should Not Contain Element id=in-collection`

- search\validation
Search in my collection is unchecked on load Log In As login=admin password=test Checkbox Should Not Be Selected id=in-collection

@mukeshk
Copy link
Contributor

mukeshk commented Jul 25, 2019

What would be the test data set for "no search result" in my collection?
admin/test - any catalogue - result in no result

What would be the test data set for "search result" to have some data for in my collection search?

@mukeshk
Copy link
Contributor

mukeshk commented Jul 25, 2019

Please suggest

@php-coder
Copy link
Owner

@mukeshk I'm looking on it right now :)

@php-coder
Copy link
Owner

  1. we need to test the same cases as we have for an anonymous user -- nothing found and something found. No need to test anything else
  2. let's put these cases into src/test/robotframework/series/search/logic-user.robot
  3. let's use user "coder" user for tests (not "admin")

What would be the test data set for "no search result" in my collection?

use the same data as for anonymous user (just copy&paste + we need to check a checkbox)

What would be the test data set for "search result" to have some data for in my collection search?

use the same data as for anonymous user (just copy&paste + we need to check a checkbox) -- it should work AFAIR because user "coder" has series #1 in his collection

@mukeshk
Copy link
Contributor

mukeshk commented Aug 1, 2019

with coder/test account.
I am looking for a CatalogName and CatalogNumber for which I will get the result when I check "in my collection" and "no result" when checked is false.

So the test case differs only in checkbox flag.
What is the Catalog Name and Number for this test case scenario?

@php-coder
Copy link
Owner

So the test case differs only in checkbox flag.

Actually, no. The checkbox is always selected. They differ by catalog name/number.

What is the Catalog Name and Number for this test case scenario?

That's a great question! I've checked and see that "coder" has no series in his collection. That means that we can't use this user for this test and have to create another one.

So, we need:

  1. create a test user who has series with id=1 in this collection
  2. add 2 test cases similar to Search series by non-existing catalog number and Search series by existing catalog number but with checkbox activated

Let me know if you need help/guidance here.

@mukeshk
Copy link
Contributor

mukeshk commented Aug 2, 2019

1.create a test user who has series with id=1 in this collection
How do we do this? I see something in test-data.properties but not fully aware of how it translates into SQL scripts?

Also, can you put together something on the data model - any diagram, data dictionary to explain the DB design. Not immediately though :).

@php-coder
Copy link
Owner

Thanks for the response! There 2 ways -- slow (when you wait the full instructions) and a little faster (where I give you pointers, you try, I help you to remove roadblocks and after few iterations we have make it working). Which one do you prefer?

@mukeshk
Copy link
Contributor

mukeshk commented Aug 2, 2019 via email

@php-coder
Copy link
Owner

So, the first step is to add a test user that will have a series in his collection. We need to add a new database migration.

  • here is an example on how to create a user and his collection:

    <insert tableName="users">
    <column name="login" value="admin" />
    <column name="role" value="ADMIN" />
    <column name="name" value="Admin" />
    <column name="email" value="root@localhost" />
    <column name="hash" value="no-password" />
    <column name="registered_at" valueComputed="${NOW}" />
    <column name="activated_at" valueComputed="${NOW}" />
    </insert>
    <insert tableName="collections">
    <column name="user_id" valueComputed="(SELECT id FROM users WHERE login = 'admin')" />
    <column name="slug" value="admin" />
    </insert>

    Here we need a real hash for password in order to be able to log in later. Let's use valid_user_password_hash from test-data.properties

  • in order to add a series to user's collection, we need to add a record to collections_series table.

If you want to play with database, try the following:

  • open http://localhost:8080/console
  • use "org.h2.Driver" as the driver
  • use "jdbc:h2:mem:mystamps" as the URL
  • use "sa" as the username and a blank password

There you will see the current state of database, all the tables and you might play with queries in order to make everything work.

@mukeshk
Copy link
Contributor

mukeshk commented Aug 4, 2019

  1. I have created a new User.
  2. I have created a new Collection.
  3. I have created a record in collection_series with an existing series.

I build a SQL script by looking at other scripts.
I assume I need to put the SQL under 0.4.1 version in liquibase.

Am I correct?
Apologize for the delay was stuck in some other work.

@php-coder
Copy link
Owner

Yes, everything sounds good. Let's continue the discussion in PR ;-)

php-coder added a commit that referenced this issue Aug 6, 2019
Related to #1097 where we will have logic-user.robot also.

[skip ci]
mukeshk added a commit to mukeshk/mystamps that referenced this issue Aug 7, 2019
mukeshk added a commit to mukeshk/mystamps that referenced this issue Aug 7, 2019
@php-coder php-coder added the estimation/30m Estimated time: 30 minutes label Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/integration tests estimation/30m Estimated time: 30 minutes kind/task Task that is part of some feature
Projects
None yet
Development

No branches or pull requests

3 participants