Skip to content

Commit

Permalink
fix(cypress): remove async from userAccess test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Oct 28, 2021
1 parent 3efaf3b commit aea68cc
Showing 1 changed file with 42 additions and 40 deletions.
82 changes: 42 additions & 40 deletions cypress/integration/admin/security/user/userAccess.spec.js
@@ -1,56 +1,58 @@
import uniqid from "uniqid";

context("Security Users", () => {
it('should verify user access for a "full-access" user', async () => {
it('should verify user access for a "full-access" user', () => {
let fullAccessGroupUser;
let password = "12345678";
// Create a user with `full-access` group

// eslint-disable-next-line jest/valid-expect-in-promise
cy.securityReadGroup({ slug: "full-access" }).then(group => {
return cy.securityCreateUser({
data: {
email: uniqid("", "@gmail.com"),
firstName: uniqid("first name-"),
lastName: uniqid("last name-"),
password,
group: group.id
}
}).then(user => {
fullAccessGroupUser = user;
// Login with new user
cy.login({ username: fullAccessGroupUser.email, password });
cy.visit("/");
// Verify the access
cy.findByText(`Hi ${user.firstName} ${user.lastName}!`).should("be.visible");
cy.findByText(/To get started - pick one of the actions below:/i).should(
"be.visible"
);
return cy
.securityCreateUser({
data: {
email: uniqid("", "@gmail.com"),
firstName: uniqid("first name-"),
lastName: uniqid("last name-"),
password,
group: group.id
}
})
.then(user => {
fullAccessGroupUser = user;
// Login with new user
cy.login({ username: fullAccessGroupUser.email, password });
cy.visit("/");
// Verify the access
cy.findByText(`Hi ${user.firstName} ${user.lastName}!`).should("be.visible");
cy.findByText(/To get started - pick one of the actions below:/i).should(
"be.visible"
);

// Should have Page Builder card
cy.findByTestId("admin-welcome-screen-widget-page-builder").within(() => {
cy.findByText("Page Builder").should("be.visible");
cy.findByText(/Build a new Page/i).should("be.visible");
});
// Should have Page Builder card
cy.findByTestId("admin-welcome-screen-widget-page-builder").within(() => {
cy.findByText("Page Builder").should("be.visible");
cy.findByText(/Build a new Page/i).should("be.visible");
});

// Should have Form Builder card
cy.findByTestId("admin-welcome-screen-widget-form-builder").within(() => {
cy.findByText("Form Builder").should("be.visible");
cy.findByText(/Create a new Form/i).should("be.visible");
});
// Should have Form Builder card
cy.findByTestId("admin-welcome-screen-widget-form-builder").within(() => {
cy.findByText("Form Builder").should("be.visible");
cy.findByText(/Create a new Form/i).should("be.visible");
});

// Should have Headless CMS card
cy.findByTestId("admin-welcome-screen-widget-headless-cms").within(() => {
cy.findByText("Headless CMS").should("be.visible");
cy.findByText(/New content model/i).should("be.visible");
});
// Should have Headless CMS card
cy.findByTestId("admin-welcome-screen-widget-headless-cms").within(() => {
cy.findByText("Headless CMS").should("be.visible");
cy.findByText(/New content model/i).should("be.visible");
});

// Delete user
// eslint-disable-next-line jest/valid-expect-in-promise
cy.securityDeleteUser({
id: fullAccessGroupUser.id
}).then(data => assert.isTrue(data));
});
// Delete user
// eslint-disable-next-line jest/valid-expect-in-promise
cy.securityDeleteUser({
id: fullAccessGroupUser.id
}).then(data => assert.isTrue(data));
});
});
});

Expand Down

0 comments on commit aea68cc

Please sign in to comment.