Skip to content

Commit

Permalink
Merge ef8421b into 266b6ee
Browse files Browse the repository at this point in the history
  • Loading branch information
suruchee committed Aug 10, 2021
2 parents 266b6ee + ef8421b commit 013db68
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
20 changes: 20 additions & 0 deletions cypress/integration/organisation/edit.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Feature: Editing a organisation
Background:
Given the user is logged in

@organisation
Scenario: The user should be able to make a public organization private
Given a public organization exists
And the user is on the edit organization page
When the user selects "None" Public Access
And the user submits the form
Then the organization should not be publicly visible

@organisation
Scenario: The user should be able to make a private organization public
Given a private organization exists
And the user is on the edit organization page
When the user selects "View" Public Access
And the user submits the form
Then the organization should be publicly visible

16 changes: 15 additions & 1 deletion cypress/support/step_definitions/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { After, Before, Given } from "cypress-cucumber-preprocessor/steps";
import { customAlphabet } from "nanoid";
import {
getDictionaryId,
getUser, getVersionId,
getOrganisationId,
getUser,
getVersionId,
isLoggedIn,
setConceptId,
setDictionaryId,
setOrganisationId,
setVersionId
} from "../../utils";

Expand Down Expand Up @@ -48,6 +51,9 @@ Before({ tags: "@version" }, () => {
setVersionId(`Ver-${nanoid()}`);
});

Before({ tags: "@organisation" }, () => {
setOrganisationId(`Org-${nanoid()}`);
});
After({ tags: "@dictionary" }, () => {
isLoggedIn().then(loggedIn => {
if (loggedIn) {
Expand All @@ -58,3 +64,11 @@ After({ tags: "@dictionary" }, () => {
}
});
});
After({ tags: "@organisation" }, () => {
isLoggedIn().then(loggedIn => {
if (loggedIn) {
const organisationId = getOrganisationId();
cy.deleteOrganisation(organisationId, true);
}
});
});
43 changes: 43 additions & 0 deletions cypress/support/step_definitions/organisation/edit/edit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Given, Then, When } from "cypress-cucumber-preprocessor/steps";
import { getOrganisationId } from "../../../utils";

Given(/a (public|private) organization exists/, type => {
const organisationId = getOrganisationId();
cy.createOrganisation(organisationId, type === "public");
});

Given("the user is on the edit organization page", () =>
cy.visit(`/orgs/${getOrganisationId()}/edit/`)
);

When(/the user selects "(.+)" Public Access/, public_access => {
switch (public_access) {
case "View":
cy.get("#public_access").type("{uparrow}{uparrow}{enter}");
break;
case "None":
cy.get("#public_access").type("{downarrow}{downarrow}{enter}");
break;
default:
throw `Unknown Public Access ${public_access}. I only know how to handle "View" and "None".`;
}
});

When("the user submits the form", () => {
cy.get("form").submit();
cy.url().should("not.contain", `/edit/`);
});

Then("the organization should not be publicly visible", () =>
cy
.getOrganisation(getOrganisationId())
.its("public_access")
.should("eq", "None")
);

Then("the organization should be publicly visible", () =>
cy
.getOrganisation(getOrganisationId())
.its("public_access")
.should("eq", "View")
);

0 comments on commit 013db68

Please sign in to comment.