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

OCLOMRS-913: The Basic User: AddConceptInDictionaryPage: Add a few concepts from CIEL in existing dictionary #723

Merged
merged 39 commits into from
Aug 10, 2021

Conversation

jwnasambu
Copy link
Contributor

@jwnasambu jwnasambu commented Jul 26, 2021

JIRA TICKET NAME:

The Basic User: AddConceptInDictionaryPage: Add a few concepts from CIEL in existing dictionary

Summary:

Created an automated test for "Add a few concepts from CIEL in existing dictionary"

@jwnasambu jwnasambu marked this pull request as draft July 26, 2021 14:50
Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

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

@jwnasambu I've added some comments here. Thanks for your hard work on this. I hope these comments are enough to get you unblocked!

cy.visit(`/users/${getUser()}/collections/${getDictionaryId()}/concepts/`);
});

When("the user clicks the Add concepts button", () => {
Copy link
Member

Choose a reason for hiding this comment

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

So, when I look at the build log for this, I see that the reason it is failing is this: Error: Step implementation missing for: the user clicks the "Add concepts" button. There are a couple of others like that.

In the feature file, the step is written as: When the user clicks the "Add concepts" button. Note the quotation marks around Add concepts those need to be here two, so you can either write this as:

When('the user clicks the "Add concepts" button')

Or:

When("the user clicks the \"Add concepts\" button")

To get the same result. Similarly with other tests where you have quotation marks.

});

Then("the user should be on the Import existing concept page", () => {
cy.visit("/orgs/CIEL/sources/CIEL/concepts/?addToDictionary=/users/openmrs/collections/")
Copy link
Member

Choose a reason for hiding this comment

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

This should be something like cy.url().should("contain", "<url>"). cy.url() gets the current URL. cy.visit() redirects the user to the provided url.

Copy link
Member

Choose a reason for hiding this comment

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

Also, instead of hard-coding openmrs as the user here, we should use ${getUser()}. Note that to support this the string should be surrounded by back-ticks `. (The difference between normal strings defined with ' or " and strings defined with ` is that the strings defined with ` allow this kind of inline string interpolation.

});

Given("the user is on the Import existing concept page", () => {
cy.visit("/orgs/CIEL/sources/CIEL/concepts/?addToDictionary")
Copy link
Member

Choose a reason for hiding this comment

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

We should fill in the addToDictionary here, e.g.,

Suggested change
cy.visit("/orgs/CIEL/sources/CIEL/concepts/?addToDictionary")
cy.visit(`/orgs/CIEL/sources/CIEL/concepts/?addToDictionary=/users/${getUser()}/collections/${getDictionaryId()}/`)

});

Then("the Serum concept should be added to the dictionary", () => {
cy.visit("/orgs/CIEL/sources/concepts/?addToDictionary=%2Fusers%2Fopenmrs%2Fcollections%2Fjst12%2F&page=1&q=Serum/")
Copy link
Member

Choose a reason for hiding this comment

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

Here we should actually be testing the dictionary contents right?

@jwnasambu
Copy link
Contributor Author

@ibacher thanks for the review and the proposed changes.

});

Then('the "Serum" concept should be added to the dictionary', () => {
cy.visit(`/orgs/CIEL/sources/CIEL/concepts/?addToDictionary=/users/${getUser()}/collections/${getDictionaryId()}/Serum/`)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it should be something like this?

Suggested change
cy.visit(`/orgs/CIEL/sources/CIEL/concepts/?addToDictionary=/users/${getUser()}/collections/${getDictionaryId()}/Serum/`)
cy.url().should('include', `/orgs/CIEL/sources/CIEL/concepts/?addToDictionary=/users/${getUser()}/collections/${getDictionaryId()}/Serum/`)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Is there any other way to determine whether the concept has been added? instead of checking the URL? A user-specific way.

ex: How a user knows when it has been created? Is it displays a success message? or it displays the created concept?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since for this case am importing the concept from the already existing concepts, it just displays the imported concept in the dictionary.

});

Given('the user is on the "Import existing concept" page', () => {
cy.url().should("contain", "/orgs/CIEL/sources/CIEL/concepts/");
Copy link
Member

Choose a reason for hiding this comment

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

I guess this one should be

Suggested change
cy.url().should("contain", "/orgs/CIEL/sources/CIEL/concepts/");
cy.visit("/orgs/CIEL/sources/CIEL/concepts/");

@jwnasambu jwnasambu force-pushed the OCLOMRS-913 branch 2 times, most recently from 40ed79f to b9aa234 Compare July 29, 2021 18:50
Given the user is on the view dictionary concepts page
When the user clicks the "Add concepts" button
And the user selects "Import existing concept"
And the user selects "Pick concepts"
Copy link
Member

Choose a reason for hiding this comment

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

Seems the step implementation missing for this one

});

When('the user clicks on the row for "Serum"', () => {
cy.findByText("Serum").click();
Copy link
Member

Choose a reason for hiding this comment

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

cypress throws the following error,

Unable to find an element with the text: Serum. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

as described in the error message, it seems there's no such element with the text "Serum"

Copy link
Member

Choose a reason for hiding this comment

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

Yes, to address this, we actually need to create a concept called "Serum" in a source called "CIEL" owned by an organisation called "CIEL". These tests are run against an empty instance of OCL (i.e., OCL without any content).

This will probably require a new command (since the createSource command only supports created a user source).

So we need something called before this function that does something like this:

cy.createOrganisation("CIEL", true).createOrgSource("CIEL", "CIEL", true);

And then afterwards,

cy.deleteOrganisation("CIEL", true);

Will also need a createConcept command that takes the source that the concept belongs to and the minimum number of properties we need so we can create a "Serum" concept before this test. Does that make some kind of sense?

cy.findByTitle("Add concepts").click();
});

Then('the user selects "Import existing concept"', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This on should be When not Then

Suggested change
Then('the user selects "Import existing concept"', () => {
When('the user selects "Import existing concept"', () => {

@ibacher
Copy link
Member

ibacher commented Aug 2, 2021

@jwnasambu Please see @jayasanka-sack's helpful comments and let me know if there's any additional guidance you need.

@jwnasambu
Copy link
Contributor Author

@ibacher and @jayasanka-sack for the guidance. Ian, am soon reaching out.

@jwnasambu
Copy link
Contributor Author

jwnasambu commented Aug 6, 2021

@suruchee I will be the happiest person to change the of status this PR but us you can see the build is still failing and basing on Ian's explanation Oh… I kind of see what the issue is. The loading of CIEL concepts is dependent on them not existing (since, in the environment that we run them in for CI, they don’t exist), but if you run it against staging, as you’re doing here, they’ll fail because CIEL already exists and has those concepts (and the user we login with doesn’t have permission to create CIEL concepts). The way to fix that is probably just to check if the CIEL Org, Source and concepts exist and only try to create them if they don’t. We have similar checks like that for some of the other create commands. I can work on that tomorrow, but I’m kind of busy the rest of this evening. Once the issue is fixed , the PR status will definitely change. Thanks in advance.

@jwnasambu
Copy link
Contributor Author

@jayasanka-sack am sorry I had not your comment. Kindly forgive me.

@jwnasambu
Copy link
Contributor Author

jwnasambu commented Aug 9, 2021

@jwnasambu The element you trying to click has CSS pointer-events: none. That means the element is not clickable.

Try clicking on a clickable element, or you can use {force: true} to click it forcefully (not a good idea, btw).

@jayasanka-sack Am still getting the same error.

cy.visit("users/openmrs/collections");
});

When('the user clicks on the "Add selected to dictionary" button', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
When('the user clicks on the "Add selected to dictionary" button', () => {
When('the user clicks the "Add selected to dictionary" button', () => {

.click();
});

When('the user clicks the "Add Serum to dictionary" button', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
When('the user clicks the "Add Serum to dictionary" button', () => {
When('the user clicks on the "Add Serum to dictionary" button', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jayasanka-sack and @ibacher it has be a tough journey but am glad am remaining with 1 error though the error on the PR is different from the one on the terminal.

@ibacher ibacher marked this pull request as ready for review August 10, 2021 17:15
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 46.768% when pulling 0085357 on jwnasambu:OCLOMRS-913 into 2a29e87 on openmrs:master.

@ibacher
Copy link
Member

ibacher commented Aug 10, 2021

@hadijahkyampeire If you have a chance, could you take a look at the changes to the ViewConceptsPage.tsx and let me know if any of the changes there don't make sense?

@jwnasambu
Copy link
Contributor Author

@ibacher and @jayasanka-sack I can't thank you enough. It has been a real fight I now have a glimpse of what it means to be a senior dev. Though with serious errors!

@hadijahkyampeire
Copy link
Collaborator

@hadijahkyampeire If you have a chance, could you take a look at the changes to the ViewConceptsPage.tsx and let me know if any of the changes there don't make sense?

Okay @ibacher I will do that.

Copy link
Collaborator

@hadijahkyampeire hadijahkyampeire left a comment

Choose a reason for hiding this comment

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

I think all is fine, they all make sense and will make the importing from another dictionary work well, great work @ibacher and @jwnasambu . LGTM

@@ -336,7 +334,10 @@ const ViewConceptsPage: React.FC<Props> = ({
)
}
dictionaryToAddTo={dictionaryToAddTo}
linkedDictionary={containerUrl}
linkedDictionary={
(containerType === DICTIONARY_CONTAINER && containerUrl) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice ❤️

@ibacher ibacher changed the title OCLOMRS-913:The Basic User: AddConceptInDictionaryPage: Add a few concepts from CIEL in existing dictionary OCLOMRS-913: The Basic User: AddConceptInDictionaryPage: Add a few concepts from CIEL in existing dictionary Aug 10, 2021
@ibacher ibacher merged commit 1375bce into openmrs:master Aug 10, 2021
@ibacher ibacher deleted the OCLOMRS-913 branch August 10, 2021 19:03
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.

7 participants