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-791: Automated Test: New organization creation form #716

Merged
merged 17 commits into from
Jul 22, 2021

Conversation

jwnasambu
Copy link
Contributor

@jwnasambu jwnasambu commented Jul 6, 2021

JIRA TICKET NAME:

Automated Test: New organization creation form

Summary:

Created the feature files and steps description file create organisation.

@hadijahkyampeire
Copy link
Collaborator

@jwnasambu Great start here but I have noticed a few things,

  1. The Summary on the PR says dictionary instead of organization so correct that.
  2. Also since this ticket is only about creating an organization, it would be better to only write scenarios and step definitions for only creating an organization, that way we keep it simple and merge it quickly.

@jwnasambu
Copy link
Contributor Author

@hadijahkyampeire thanks for the review I have fixed it!

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 Thanks for this. It looks like you followed the patterns from the dictionary stuff correctly. I've added some suggested changes to make things a little cleaner. I'd suggest that we also need some tests to confirm:

  1. When creating an organisation, the user must provide an organisation id
  2. When creating an organisation, the user must provide an organisation name

These can be modeled on the tests for requiring a username and password from login.feature.

@@ -0,0 +1,66 @@
/// <reference types="cypress" />
Copy link
Member

Choose a reason for hiding this comment

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

This file should be in cypress/support/step_definitions/organisation/edit/edit.ts)

Copy link

Choose a reason for hiding this comment

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

any reasons for repeating edit/edit, wouldn't cypress/support/step_definitions/organisation/edit.js be better?

Copy link
Member

Choose a reason for hiding this comment

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

It is repetitive; unfortunately, it's also necessary for the way the preprocessor is configured. More exactly, it just loads all the scripts in /create/edit/*.{js,ts}. So the file could be called index.ts, junk.ts, etc. edit/edit.ts just makes things clear (so it has the same name as the feature file.

cy.visit(`/orgs/${organisationId}/edit/`)
);

When(/the user selects "(.+)" public_access => {
Copy link
Member

Choose a reason for hiding this comment

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

This is where the error you're getting occurs. This should be:

Suggested change
When(/the user selects "(.+)" public_access => {
When(/the user selects "(.+)"/, public_access => {

}
});
});

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

cy.deleteOrganisation(organisationID, user, true);
}
});
});
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
});
});

import { customAlphabet } from "nanoid";
import { isLoggedIn } from "../../../utils";

const user = Cypress.env("USERNAME") || "admin";
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need the user here?

);

Before({ tags: "@organisation" }, () => {
organisationID = `TD-${nanoid()}`;
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
organisationID = `TD-${nanoid()}`;
organisationID = `Org-${nanoid()}`;

TD = "Test Dictionary"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks so much @ibacher for the clear description.

);

Before({ tags: "@organisation" }, () => {
organisationId = `TD-${nanoid()}`;
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
organisationId = `TD-${nanoid()}`;
organisationId = `Org-${nanoid()}`;

Comment on lines 17 to 19
Given(/a (public) organisation exists/, type => {
cy.createOrganisation(organisationId, user, type === "public");
});
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
Given(/a (public) organisation exists/, type => {
cy.createOrganisation(organisationId, user, type === "public");
});
Given("a public organisation exists", () => {
cy.createOrganisation(organisationId, user, true);
});

@jwnasambu
Copy link
Contributor Author

@ibacher thanks for the review am gonna fix the changes shortly.

@organisation
Scenario: The user should be able to create a new organisation
Given the user is on the create new organisation page
When the user enters the organisation information
Copy link

@kaweesi kaweesi Jul 9, 2021

Choose a reason for hiding this comment

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

i would prefer Given, When, Then to have the same starting line for clarity, The sub steps can be indented

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@k-joseph thanks for the review. Let me fix right away.

Copy link
Member

Choose a reason for hiding this comment

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

@kaweesi I actually prefer this style. It keeps the actual steps aligned with each other, which I think is more useful for figuring out what's important. As a bonus, it also keeps And indented under the Given, When, Then which makes it easier, at least to me, to follow whats going on. In short, for me at least, it's easier to visually see what each scenario does.

@coveralls
Copy link

coveralls commented Jul 13, 2021

Coverage Status

Coverage remained the same at 46.783% when pulling bf1d5b4 on jwnasambu:OCLOMRS-791 into 648617b on openmrs:master.

@jwnasambu
Copy link
Contributor Author

@ibacher, @kaweesi and @hadijahkyampeire I removed the edit file file since its not what the ticket needs. Kindly feel free to review the PR again.

@jwnasambu jwnasambu marked this pull request as ready for review July 13, 2021 14:58
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.

Great work @jwnasambu just small changes needed.

cypress/support/utils.ts Outdated Show resolved Hide resolved
@hadijahkyampeire
Copy link
Collaborator

@jwnasambu just a small point:-while resolving these conflicts, try to keep what is coming from master but in the cypress/support/utils.ts you will add your organisationId in the cypress environment to be uniform with the dictionary and concept ids.

@hadijahkyampeire hadijahkyampeire removed the request for review from k-joseph July 16, 2021 13:02
cypress/support/index.ts Outdated Show resolved Hide resolved
cypress/support/index.ts Outdated Show resolved Hide resolved
cypress/support/utils.ts Outdated Show resolved Hide resolved
Then the new organisation should be created

@organisation
Scenario: The user should be able to create a public organisation
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we have a similar scenario for a private organisation? Apart from that, I think this PR is ready-to-merge.

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.

Well done @jwnasambu

@ibacher ibacher changed the title OCLOMRS-791:Automated Test: New organization creation form OCLOMRS-791: Automated Test: New organization creation form Jul 22, 2021
@ibacher ibacher merged commit be1d242 into openmrs:master Jul 22, 2021
@ibacher ibacher deleted the OCLOMRS-791 branch July 22, 2021 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants