-
Notifications
You must be signed in to change notification settings - Fork 76
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-970:Automated test for creating a version, releasing it and copy subscriptionURL #724
Changes from 2 commits
4451cb9
4cfbf64
5c73ffb
974d5ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||
Feature: Creating a dictionary version Releasing it and copy subscription URL | ||||
Background: | ||||
Given the user is logged in | ||||
|
||||
@dictionary | ||||
Scenario: The user should be able to click the button to create a new version | ||||
Given a dictionary exists | ||||
And the user is on the dictionary page | ||||
When the user clicks the create new version button | ||||
Then the user should be on the create new version dialog box | ||||
|
||||
@dictionary | ||||
@version | ||||
Scenario: The user should be able to create a new version, release it and copy subscription URL | ||||
Given a dictionary exists | ||||
And the user is on the create new version dialog box | ||||
When the user enters the version information | ||||
And the user submits the form | ||||
Then the new version should be created | ||||
When the user clicks release status switch | ||||
And the release dialog opens | ||||
And the user clicks yes button | ||||
Then the version should be released | ||||
When the user clicks the more actions button | ||||
And the user selects the "Copy Subscription URL" menu list item | ||||
Then the subscription url should be copied | ||||
|
||||
|
||||
|
||||
|
||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -2,7 +2,14 @@ | |||||||
/// <reference types="../../" /> | ||||||||
import { After, Before, Given } from "cypress-cucumber-preprocessor/steps"; | ||||||||
import { customAlphabet } from "nanoid"; | ||||||||
import { getDictionaryId, getUser, isLoggedIn, setConceptId, setDictionaryId } from "../../utils"; | ||||||||
import { | ||||||||
getDictionaryId, | ||||||||
getUser, | ||||||||
isLoggedIn, | ||||||||
setConceptId, | ||||||||
setDictionaryId, | ||||||||
setVersionId | ||||||||
} from "../../utils"; | ||||||||
|
||||||||
const nanoid = customAlphabet("abcdefghijklmnopqrstuvwxyz", 4); | ||||||||
|
||||||||
|
@@ -19,10 +26,12 @@ Given("a dictionary exists", () => { | |||||||
Before({ tags: "@dictionary" }, () => { | ||||||||
setDictionaryId(`TD-${nanoid()}`); | ||||||||
}); | ||||||||
|
||||||||
Before({ tags: "@concept" }, () => { | ||||||||
setConceptId(`CT-${nanoid()}`); | ||||||||
}); | ||||||||
Before({ tags: "@version" }, () => { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
setVersionId(`Ver-${nanoid()}`); | ||||||||
}); | ||||||||
|
||||||||
After({ tags: "@dictionary" }, () => { | ||||||||
isLoggedIn().then(loggedIn => { | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||||||||||
import { Given, Then, When } from "cypress-cucumber-preprocessor/steps"; | ||||||||||||||
import {getDictionaryId, getUser, getVersionId} from "../../../utils"; | ||||||||||||||
|
||||||||||||||
Given("the user is on the dictionary page", () => { | ||||||||||||||
cy.visit(`/users/${getUser()}/collections/${getDictionaryId()}/`); | ||||||||||||||
cy.findByText("Versions").should("be.visible"); | ||||||||||||||
}); | ||||||||||||||
When("the user clicks the create new version button", () => { | ||||||||||||||
cy.findByRole("button", { name: /Create new version/i }).click(); | ||||||||||||||
}); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
Then("the user should be on the create new version dialog box", () => | ||||||||||||||
cy.get("h2").contains("Create new version") | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @ibacher, but this code will cause Found multiple elements with the text error. So I tried this one. Will you please suggest another idea? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cy.findByText("Create new version", { selector: "h2" }).should("be.visible") |
||||||||||||||
); | ||||||||||||||
|
||||||||||||||
Given("the user is on the create new version dialog box", () => { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And a similar change to the |
||||||||||||||
cy.visit(`/users/${getUser()}/collections/${getDictionaryId()}/`); | ||||||||||||||
cy.findByRole("button", { name: /Create new version/i }).click(); | ||||||||||||||
cy.get("h2").contains("Create new version"); | ||||||||||||||
}); | ||||||||||||||
When("the user enters the version information", () => { | ||||||||||||||
cy.findByLabelText("ID").type("1"); | ||||||||||||||
cy.get("#released").type("{enter}"); | ||||||||||||||
}); | ||||||||||||||
When("the user submits the form", () => { | ||||||||||||||
cy.get("#versionForm").submit(); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no cy.findByRole("button", { name: /Submit/i }).click(); |
||||||||||||||
}); | ||||||||||||||
Then("the new version should be created", () => { | ||||||||||||||
cy.get("table").should("exist"); | ||||||||||||||
cy.get("table tbody tr").should("have.length", 1); | ||||||||||||||
cy.get("table").contains("td", "1"); | ||||||||||||||
cy.get("table").contains("td", "No"); | ||||||||||||||
}); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are probably too many assertions here we don't need. E.g., what we care about is there is a row with the ID we filled in. Also, I'm not sure what the "No" here is supposed to match, but we'd probably need to check the actual checkbox if its the release status. |
||||||||||||||
|
||||||||||||||
When("the user clicks release status switch", () => { | ||||||||||||||
cy.get('[type="checkbox"]').check(); | ||||||||||||||
}); | ||||||||||||||
When("the release dialog opens", () => { | ||||||||||||||
cy.get("#confirmation-dialog-title").should("exist"); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
}); | ||||||||||||||
When("the user clicks yes button", () => { | ||||||||||||||
cy.get("button.MuiButton-textPrimary") | ||||||||||||||
.eq(1) | ||||||||||||||
.click(); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cy.findByText(/Yes/i).click() |
||||||||||||||
}); | ||||||||||||||
Then("the version should be released", () => | ||||||||||||||
cy.get('[type="checkbox"]').should("be.checked") | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
When("the user clicks the more actions button", () => { | ||||||||||||||
cy.findByTitle("More actions").click(); | ||||||||||||||
}); | ||||||||||||||
When(/the user selects the "(.+)" menu list item/, menuItem => | ||||||||||||||
cy.findByText(menuItem).click() | ||||||||||||||
); | ||||||||||||||
Then("the subscription url should be copied", () => | ||||||||||||||
cy.visit(`/users/${getUser()}/collections/${getDictionaryId()}/${getVersionId()}`) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I see how this code checks that the subscription URL was copied? This looks like a good approach to verify that the correct text was copied. |
||||||||||||||
); |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -26,7 +26,11 @@ export const getDictionaryId = () => Cypress.env("dictionaryId"); | |||||||
export const setDictionaryId = (dictionaryId: string) => | ||||||||
Cypress.env("dictionaryId", dictionaryId); | ||||||||
export const getConceptId = () => Cypress.env("conceptId"); | ||||||||
export const setConceptId = (conceptId: string) => Cypress.env("conceptId", conceptId); | ||||||||
export const setConceptId = (conceptId: string) => | ||||||||
Cypress.env("conceptId", conceptId); | ||||||||
export const getOrganisationId = () => Cypress.env("organisationId"); | ||||||||
export const setOrganisationId = (organisationId: string) => | ||||||||
Cypress.env("organisationId", organisationId); | ||||||||
export const getVersionId = () => Cypress.env("versionId"); | ||||||||
export const setVersionId = (versionId: string) => | ||||||||
Cypress.env("versionId", versionId); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually break this out as three separate tests: one to create a new version. One to release it via the checkbox, and one to copy the subscription URL. That way we should also be able to check that the user can release a new version within the "Create New Version" form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right @ibacher that's what @suruchee had but the last two scenarios were not passing probably because they needed a version to be created, she had a command for creating and getting a version the way the dictionary commands are but they were not working, so I told her that we first put those other two tests in the same scenario so that we see they pass, then we reach out to you about separating them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough... The version release process actually does some backend processing, so between the request to create the version returning and the version actually being created there's a bit of a delay... not much for a small dictionary, but not no time at all either.
Probably the simplest way to do this is to force Cypress to pause immediately after submitting the new version request, e.g., by using
cy.wait(500)
. A more complicated version of the same idea would be to have a shorter pause and at the end of each pause poll the backend until a longer period of time, e.g. 8 seconds or w/e had passed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a library to handle my "more complicated" version: https://github.com/NoriSte/cypress-wait-until. Basically looks like you can use that and wait until the backend returns that the version exists. Note that it's probably also necessary to force Cypress to reload the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @hadijahkyampeire and @ibacher, I will update with the delay suggestion.