Skip to content

Commit

Permalink
Merge 5c73ffb into 72e2dfe
Browse files Browse the repository at this point in the history
  • Loading branch information
suruchee committed Jul 27, 2021
2 parents 72e2dfe + 5c73ffb commit 051bd55
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 3 deletions.
26 changes: 26 additions & 0 deletions cypress/integration/dictionary/createVersion.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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 clicks 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
14 changes: 12 additions & 2 deletions cypress/support/step_definitions/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -19,11 +26,14 @@ Given("a dictionary exists", () => {
Before({ tags: "@dictionary" }, () => {
setDictionaryId(`TD-${nanoid()}`);
});

Before({ tags: "@concept" }, () => {
setConceptId(`CT-${nanoid()}`);
});

Before({ tags: "@version" }, () => {
setVersionId(`Ver-${nanoid()}`);
});

After({ tags: "@dictionary" }, () => {
isLoggedIn().then(loggedIn => {
if (loggedIn) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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()
);
Then("the user should be on the create new version dialog box", () =>
cy.get("h2").contains("Create new version")
);

Given("the user clicks on the create new version dialog box", () => {
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.findByRole("button", { name: /Submit/i }).click()
);
Then("the new version should be created", () => {
cy.get("table").contains("td", "1");
cy.get('[type="checkbox"]').should("not.be.checked");
});

When("the user clicks release status switch", () =>
cy.get('[type="checkbox"]').check()
);
When("the release dialog opens", () =>
cy.get("#confirmation-dialog-title").should("be.visible")
);
When("the user clicks yes button", () => 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.window().then(win => {
win.navigator.clipboard.readText().then(text => {
assert.equal(
text,
`/users/${getUser()}/collections/${getDictionaryId()}/${getVersionId()}`
);
});
});
});
6 changes: 5 additions & 1 deletion cypress/support/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 051bd55

Please sign in to comment.