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

O3 - 2199 : Add BDD steps on tests #40

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dilankavishka
Copy link

@dilankavishka dilankavishka commented Dec 20, 2023

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
  • My work conforms to the OpenMRS 3.0 Styleguide.
  • I checked for feature overlap with existing widgets.

Summary

This PR enhances the existing End-to-End (E2E) tests by incorporating Behavior-Driven Development (BDD) steps using Gherkin syntax. The modifications utilize Playwright's test.step function to organize the test scenarios into well-defined steps, making the test suite more readable and aligned with BDD principles.

Screenshots

Screenshot 2023-12-20 at 15 31 37

Updated changes.
Screenshot 2023-12-21 at 12 47 58

None.

Issue

None.

Other

None.

@dilankavishka
Copy link
Author

@Piumal1999 @jayasanka-sack Please review this PR.

@dilankavishka
Copy link
Author

@jayasanka-sack @Piumal1999 I do some updates and commit that on to this. please review this issue.

e2e/specs/openConceptLab.spec.ts Outdated Show resolved Hide resolved
e2e/specs/openConceptLab.spec.ts Outdated Show resolved Hide resolved
Comment on lines 32 to 35
await test.step('And I unsubscribes', async () => {
await openConceptLabPage.subscriptionTab().click();
await openConceptLabPage.unsubscribe();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to move this block into an afterEach block. (maybe with another ticket)

Suggested change
await test.step('And I unsubscribes', async () => {
await openConceptLabPage.subscriptionTab().click();
await openConceptLabPage.unsubscribe();
});
await openConceptLabPage.subscriptionTab().click();
await openConceptLabPage.unsubscribe();

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed since there's only one test case

@dilankavishka dilankavishka marked this pull request as draft January 18, 2024 06:23
@dilankavishka dilankavishka marked this pull request as ready for review January 18, 2024 06:47
@dilankavishka
Copy link
Author

@Piumal1999 I committed the suggestions. can you please review this?

@Piumal1999
Copy link
Contributor

Hi @dilankavishka,
There are some indentation issues. Could you please reformat the code?

@dilankavishka
Copy link
Author

@Piumal1999 Done with the issue. can you please review this?

// Unsubscribe
await openConceptLabPage.subscriptionTab().click();
await openConceptLabPage.unsubscribe();
await test.step('And I unsubscribes', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
await test.step('And I unsubscribes', async () => {
await test.step('And I unsubscribe', async () => {

await openConceptLabPage.goto();
await openConceptLabPage.previousImportsTab().click();
await expect(openConceptLabPage.previousImportsTable()).toHaveText(/\d+ items fetched/);
await test.step('Then the import results should appear in the test report', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
await test.step('Then the import results should appear in the test report', async () => {
await test.step('Then the import results should appear in previous imports', async () => {

@dilankavishka
Copy link
Author

@Piumal1999 Done with the suggestions.

Comment on lines +32 to +35
await test.step('And I unsubscribe', async () => {
await openConceptLabPage.subscriptionTab().click();
await openConceptLabPage.unsubscribe();
});
Copy link
Member

Choose a reason for hiding this comment

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

Don't we need to expect anything after performing this step?

@Piumal1999 @dilankavishka

Copy link
Author

Choose a reason for hiding this comment

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

@jayasanka-sack
Do you mean that we can add "Click on that subscription tab" after this step?

Copy link
Member

Choose a reason for hiding this comment

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

No. I mean, what we can expect after unsubscribing? A success message?

I think an extra "Then" step would be nice to have.

await openConceptLabPage.addOclSubscription();
await test.step('When I setup the subscription', async () => {
await openConceptLabPage.goto();
await openConceptLabPage.addOclSubscription();
Copy link
Member

Choose a reason for hiding this comment

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

@Piumal1999 @dilankavishka Since addOclSubscription function isn't reused anywhere, I think it would be better to move things back to here from the page.

Then break down it in to steps.
ex:

  • When I go to the "OCL module page"
  • And I enter the subscription URL
  • And I enter the token
  • And I click the save button
  • Then I should ....
  • When I click on the import tab
  • ...

Copy link
Author

Choose a reason for hiding this comment

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

@@ -13,22 +13,26 @@ test.beforeEach(async ({ api }) => {
test('should be able to setup a subscription and import concepts', async ({ page }) => {
Copy link
Member

Choose a reason for hiding this comment

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

Test name should be renamed with the action. Check other repos.

Copy link
Author

Choose a reason for hiding this comment

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

@denniskigen
Copy link
Member

This is very close, @dilankavishka. Do you have the bandwidth to wrap it up?

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.

4 participants