Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improved scopes selection auto-complete component(#743)
Closes #729
- Loading branch information
Showing
25 changed files
with
500 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
cypress/integration/admin/security/roles/createGroup.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import uniqid from "uniqid"; | ||
|
||
context("Groups Module", () => { | ||
beforeEach(() => cy.login()); | ||
|
||
it("should be able to create, edit, and immediately delete a group", () => { | ||
const id = uniqid(); | ||
cy.visit("/groups") | ||
.findByLabelText("Name") | ||
.type(`Test Group ${id}`) | ||
.findByText("Save group") | ||
.click() | ||
.findByText("Value is required.") | ||
.should("exist") | ||
.findByLabelText("Slug") | ||
.type(`test-group-${id}`) | ||
.findByLabelText("Description") | ||
.type("This is a test test.") | ||
.findByText("Save group") | ||
.click(); | ||
|
||
cy.wait(500) | ||
.findByText("Record saved successfully.") | ||
.should("exist"); | ||
|
||
cy.findByLabelText("Slug") | ||
.type("-edited") | ||
.findByLabelText("Description") | ||
.type(" Test test.") | ||
.findByText("Save group") | ||
.click(); | ||
|
||
cy.wait(500) | ||
.findByTestId("default-data-list") | ||
.within(() => { | ||
cy.get("div") | ||
.first() | ||
.within(() => { | ||
cy.findByText(`Test Group ${id}`) | ||
.should("exist") | ||
.findByText("This is a test test. Test test.") | ||
.should("exist"); | ||
cy.get("button").click({ force: true }); | ||
}); | ||
}); | ||
|
||
cy.get('[role="alertdialog"] :visible').within(() => { | ||
cy.contains("Are you sure you want to continue?") | ||
.next() | ||
.within(() => cy.findByText("Confirm").click()); | ||
}); | ||
|
||
cy.findByText("Record deleted successfully.").should("exist"); | ||
cy.findByTestId("default-data-list").within(() => { | ||
cy.findByText(`Test Group ${id}`).should("not.exist"); | ||
}); | ||
}); | ||
|
||
it("groups with the same slug should not be allowed - an error message must be shown", () => { | ||
const id = uniqid(); | ||
cy.visit("/groups") | ||
.findByLabelText("Name") | ||
.type(`Test Group ${id}`) | ||
.findByText("Save group") | ||
.findByLabelText("Slug") | ||
.type(`test-group-${id}`) | ||
.findByLabelText("Description") | ||
.type("This is a test test.") | ||
.findByText("Save group") | ||
.click() | ||
.wait(1500); | ||
|
||
cy.findByTestId("new-record-button") | ||
.click() | ||
.findByLabelText("Name") | ||
.type(`Test Group ${id}`) | ||
.findByText("Save group") | ||
.findByLabelText("Slug") | ||
.type(`test-group-${id}`) | ||
.findByLabelText("Description") | ||
.type("This is a test test.") | ||
.findByText("Save group") | ||
.click(); | ||
|
||
cy.wait(500) | ||
.get('[role="alertdialog"] :visible') | ||
.within(() => { | ||
cy.findByText(`Group with slug "test-group-${id}" already exists.`).should("exist"); | ||
}); | ||
}); | ||
}); |
132 changes: 132 additions & 0 deletions
132
cypress/integration/admin/security/roles/createRole.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import uniqid from "uniqid"; | ||
|
||
context("Roles Module", () => { | ||
beforeEach(() => cy.login()); | ||
|
||
it("should be able to create, edit, and immediately delete a role", () => { | ||
const id = uniqid(); | ||
cy.visit("/roles") | ||
.findByLabelText("Name") | ||
.type(`Test Role ${id}`) | ||
.findByText("Save role") | ||
.click() | ||
.findByText("Value is required.") | ||
.should("exist") | ||
.findByLabelText("Slug") | ||
.type(`test-role-${id}`) | ||
.findByLabelText("Description") | ||
.type("This is a test test.") | ||
.findByText("Save role") | ||
.click(); | ||
|
||
cy.wait(500) | ||
.findByText("Record saved successfully.") | ||
.should("exist"); | ||
|
||
cy.findByLabelText("Slug") | ||
.type("-edited") | ||
.findByLabelText("Description") | ||
.type(" Test test."); | ||
|
||
// Check if the scopes auto-complete is working. | ||
cy.findByLabelText("Scopes") | ||
.type(`revi`) | ||
.findByText("Publish form revisions") | ||
.click() | ||
.findByLabelText("Scopes") | ||
.type(`revi`) | ||
.findByText("Unpublish form revisions") | ||
.click(); | ||
|
||
cy.findByText("Save role").click(); | ||
|
||
cy.wait(500) | ||
.findByTestId("default-data-list") | ||
.within(() => { | ||
cy.get("div") | ||
.first() | ||
.within(() => { | ||
cy.findByText(`Test Role ${id}`) | ||
.should("exist") | ||
.findByText("This is a test test. Test test.") | ||
.should("exist"); | ||
cy.get("button").click({ force: true }); | ||
}); | ||
}); | ||
|
||
cy.get('[role="alertdialog"] :visible').within(() => { | ||
cy.contains("Are you sure you want to continue?") | ||
.next() | ||
.within(() => cy.findByText("Confirm").click()); | ||
}); | ||
|
||
cy.findByText("Record deleted successfully.").should("exist"); | ||
cy.findByTestId("default-data-list").within(() => { | ||
cy.findByText(`Test Role ${id}`).should("not.exist"); | ||
}); | ||
}); | ||
|
||
it("roles with the same slug should not be allowed - an error message must be shown", () => { | ||
const id = uniqid(); | ||
cy.visit("/roles") | ||
.findByLabelText("Name") | ||
.type(`Test Role ${id}`) | ||
.findByText("Save role") | ||
.findByLabelText("Slug") | ||
.type(`test-role-${id}`) | ||
.findByLabelText("Description") | ||
.type("This is a test test.") | ||
.findByText("Save role") | ||
.click() | ||
.wait(1500); | ||
|
||
cy.findByTestId("new-record-button") | ||
.click() | ||
.findByLabelText("Name") | ||
.type(`Test Role ${id}`) | ||
.findByText("Save role") | ||
.findByLabelText("Slug") | ||
.type(`test-role-${id}`) | ||
.findByLabelText("Description") | ||
.type("This is a test test.") | ||
.findByText("Save role") | ||
.click(); | ||
|
||
cy.wait(500) | ||
.get('[role="alertdialog"] :visible') | ||
.within(() => { | ||
cy.findByText(`Role with slug "test-role-${id}" already exists.`).should("exist"); | ||
}); | ||
}); | ||
|
||
it("should save scopes correctly", () => { | ||
const id = uniqid(); | ||
cy.visit("/roles") | ||
.findByLabelText("Name") | ||
.type(`Test Role ${id}`) | ||
.findByLabelText("Slug") | ||
.type(`test-role-${id}`) | ||
.findByLabelText("Description") | ||
.type("This is a test test.") | ||
.findByLabelText("Scopes") | ||
.type(`revi`) | ||
.findByText("Publish form revisions") | ||
.click() | ||
.findByLabelText("Scopes") | ||
.type(`revi`) | ||
.findByText("Unpublish form revisions") | ||
.click() | ||
.findByText("Save role") | ||
.click(); | ||
|
||
cy.wait(2500) | ||
.reload() | ||
.findByTestId("default-form") | ||
.within(() => { | ||
cy.findByText("forms:form:revision:publish") | ||
.should("exist") | ||
.findByText("forms:form:revision:unpublish") | ||
.should("exist"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { i18n } from "@webiny/app/i18n"; | ||
import { SecurityScopesListPlugin } from "@webiny/app-security/types"; | ||
|
||
const t = i18n.ns("app-form-builder/admin/scopesList"); | ||
|
||
export default [ | ||
{ | ||
name: "security-scopes-list-form-builder", | ||
type: "security-scopes-list", | ||
scopes: [ | ||
{ | ||
scope: "forms:form:crud", | ||
title: t`Forms CRUD`, | ||
description: t`Allows basic CRUD operations on all forms.` | ||
}, | ||
{ | ||
scope: "forms:settings", | ||
title: t`Form Builder Settings`, | ||
description: t`Allows updating Form Builder's settings.` | ||
}, | ||
{ | ||
scope: "forms:form:revision:publish", | ||
title: t`Publish form revisions`, | ||
description: t`Allows publishing form revision.` | ||
}, | ||
{ | ||
scope: "forms:form:revision:unpublish", | ||
title: t`Unpublish form revisions`, | ||
description: t`Allows unpublishing form revisions.` | ||
}, | ||
{ | ||
scope: "forms:form:submissions:export", | ||
title: t`Export form submissions`, | ||
description: t`Allows creating form submission exports.` | ||
} | ||
] | ||
} as SecurityScopesListPlugin | ||
]; |
Oops, something went wrong.