Skip to content

Commit

Permalink
Merge branch 'test/e2e-tests-2' into 'devel'
Browse files Browse the repository at this point in the history
e2e tests: sharing scenario

See merge request sds-dev/sd-connect/swift-browser-ui!123
  • Loading branch information
blankdots committed Aug 1, 2023
2 parents b5caf66 + c659142 commit 02eb977
Show file tree
Hide file tree
Showing 5 changed files with 417 additions and 81 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- (GL #999) Add three level sharing with view option
- (GL #947) Added cypress tests for login, adding and showing containers, uploading files
- (GL #1047) Added redis and vault monitoring to `/health` endpoint
- (GL #947) Added cypress tests for sharing folders

### Changed

Expand Down
40 changes: 38 additions & 2 deletions tests/cypress/integration/container.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,49 @@ describe("Several containers with different names are created and visible", () =

cy.addFolder(nameOne);
cy.wait(5000);

//check the folder 1 exists with search field
cy.searchFolder(nameOne);
cy.get(".media-content").contains(nameOne).should("exist"); //check the folder 1 exists with search field
cy.wait(5000);
cy.get(".media-content").contains(nameOne).should("exist");

cy.addFolder(nameTwo);
cy.wait(5000);

cy.reload();

//check the folder 2 exists with search field
cy.searchFolder(nameTwo);
cy.wait(5000);
cy.get(".media-content").contains(nameTwo).should("exist");

//check there are multiple folders in the project
cy.get("table")
.find("a.icon", { timeout: "5000" })
.should("have.length.greaterThan", 1);
});
});

//TODO separate test for folder deletion
describe("A container can be deleted", () => {
before(() => {
cy.visit(Cypress.config().baseUrl);
cy.login(Cypress.env("username"), Cypress.env("password"));
});

it("creates and deletes a container", function () {
//create a folder
cy.addFolder("000aaa");
cy.wait(5000);
cy.contains("000aaa").should("exist");

//check the folder exists, then delete
cy.deleteFolder("000aaa");
cy.contains("Folder was deleted").should("exist");
cy.wait(5000);

//check it was deleted
cy.reload();
cy.wait(10000);
cy.contains("000aaa").should("not.exist");
});
});
235 changes: 235 additions & 0 deletions tests/cypress/integration/sharing.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
describe("A folder is shared from project A to project B", function () {
beforeEach(() => {
cy.visit(Cypress.config().baseUrl);
cy.login(Cypress.env("username"), Cypress.env("password"));
});

it("copy share id, switch project, share folder, switch project, check if shared folder is visible", function () {
cy.wait(5000);
//take the ID appearing as the last part of url
cy.url().then((url) => {
const copyId = url.split("/")[5];
cy.log(copyId);
//switch project
cy.selectProject("service");
//add folder
const randomName = Math.random().toString(36).substring(2, 7);
cy.addFolder(randomName);
cy.wait(7000);
//access folder
cy.searchFolder(randomName);
cy.get(".media-content").contains(randomName).click({ force: true });
cy.wait(5000);
cy.contains("Edit sharing").click({ force: true });

//type in swift-project's shareID
cy.get(":nth-child(1) > .tags-list > input").type(copyId, {
force: true,
});

//choose permission
cy.get(":nth-child(4) > c-select.hydrated")
.click({ force: true })
.find("li")
.eq(0)
.click({ force: true });
//save sharing
cy.get(
"#share-card-modal-content > :nth-child(1) > :nth-child(4) > c-button.hydrated"
).click({ force: true });

cy.contains("Folder was shared successfully").should("exist");
cy.contains(copyId).should("exist");
});
});
});

describe("A folder cannot be shared without Share ID or if rights are not selected", function () {
beforeEach(() => {
cy.visit(Cypress.config().baseUrl);
cy.login(Cypress.env("username"), Cypress.env("password"));
});

it("switch project, try to share folder without share ID, fail", function () {
cy.wait(5000);
//take the ID appearing as the last part of url
cy.url().then((url) => {
const copyId = url.split("/")[5];
cy.log(copyId);
//switch project
cy.selectProject("service");
//add folder
const randomName = Math.random().toString(36).substring(2, 7);
cy.addFolder(randomName);
cy.wait(5000);
//access folder
cy.searchFolder(randomName);
cy.get(".media-content").contains(randomName).click({ force: true });
cy.wait(5000);
cy.contains("Edit sharing").click({ force: true });

//choose permission
cy.get(":nth-child(4) > c-select.hydrated")
.click({ force: true })
.find("li")
.eq(0)
.click({ force: true });
//save sharing
cy.get(
"#share-card-modal-content > :nth-child(1) > :nth-child(4) > c-button.hydrated"
).click({ force: true });

cy.contains("Please enter at least one Share ID").should("exist");
cy.contains(copyId).should("not.exist");
});
});

it("copy shareID, switch project, try to share folder without selecting rights, fail", function () {
cy.wait(5000);
//take the ID appearing as the last part of url
cy.url().then((url) => {
const copyId = url.split("/")[5];
cy.log(copyId);
//switch project
cy.selectProject("service");
//add folder
const randomName = Math.random().toString(36).substring(2, 7);
cy.addFolder(randomName);
cy.wait(5000);
//access folder
cy.searchFolder(randomName);
cy.get(".media-content").contains(randomName).click({ force: true });
cy.wait(5000);
cy.contains("Edit sharing").click({ force: true });

//type in swift-project's shareID
cy.get(":nth-child(1) > .tags-list > input").type(copyId, {
force: true,
});

//save sharing
cy.get(
"#share-card-modal-content > :nth-child(1) > :nth-child(4) > c-button.hydrated"
).click({ force: true });

cy.contains("Please select permissions to grant").should("exist");
});
});
});

describe("A folder cannot be shared with the same Share ID twice", function () {
beforeEach(() => {
cy.visit(Cypress.config().baseUrl);
cy.login(Cypress.env("username"), Cypress.env("password"));
});

it("switch project, try to share folder without the same ID twice, fail", function () {
cy.wait(5000);

//take the ID appearing as the last part of url
cy.url().then((url) => {
const copyId = url.split("/")[5];
cy.log(copyId);

//switch project
cy.selectProject("service");

//add folder
const randomName = Math.random().toString(36).substring(2, 7);
cy.addFolder(randomName);
cy.wait(5000);

//access folder
cy.searchFolder(randomName);
cy.get(".media-content").contains(randomName).click({ force: true });
cy.wait(5000);
cy.contains("Edit sharing").click({ force: true });

//type in swift-project's shareID
cy.get(":nth-child(1) > .tags-list > input").type(copyId, {
force: true,
});

//choose permission
cy.get(":nth-child(4) > c-select.hydrated")
.click({ force: true })
.find("li")
.eq(0)
.click({ force: true });

//save sharing
cy.get(
"#share-card-modal-content > :nth-child(1) > :nth-child(4) > c-button.hydrated"
).click({ force: true });

//repeat sharing with same ID
cy.wait(5000);
cy.contains("Edit sharing").click({ force: true });

//type in swift-project's shareID
cy.get(":nth-child(1) > .tags-list > input").type(copyId, {
force: true,
});

//choose permission
cy.get(":nth-child(4) > c-select.hydrated")
.click({ force: true })
.find("li")
.eq(0)
.click({ force: true });

//save sharing
cy.get(
"#share-card-modal-content > :nth-child(1) > :nth-child(4) > c-button.hydrated"
).click({ force: true });

// cy.contains("already has access").should("exist");
cy.contains("Folder was shared successfully").should("not.exist");
});
});
});

describe("A folder cannot be shared with the invalid ID", function () {
beforeEach(() => {
cy.visit(Cypress.config().baseUrl);
cy.login(Cypress.env("username"), Cypress.env("password"));
});

it("switch project, try to share folder with invalid share ID, fail", function () {
cy.wait(5000);

//switch project
cy.selectProject("service");

//add folder
const randomName = Math.random().toString(36).substring(2, 7);
cy.addFolder(randomName);
cy.wait(5000);

//access folder
cy.searchFolder(randomName);
cy.get(".media-content").contains(randomName).click({ force: true });
cy.wait(5000);
cy.contains("Edit sharing").click({ force: true });

//type in invalid shareID
const copyId = Math.random().toString(36).substring(2, 7);
cy.get(":nth-child(1) > .tags-list > input").type(copyId, {
force: true,
});
//choose permission
cy.get(":nth-child(4) > c-select.hydrated")
.click({ force: true })
.find("li")
.eq(0)
.click({ force: true });

//save sharing
cy.get(
"#share-card-modal-content > :nth-child(1) > :nth-child(4) > c-button.hydrated"
).click({ force: true });

// cy.contains("already has access").should("exist");
cy.contains("Folder was shared successfully").should("not.exist");
});
});
Loading

0 comments on commit 02eb977

Please sign in to comment.