chore(e2e): formatting with prettier (#4385)

* prettier in e2e

* format

* typescript as dev dependency

* ci all, check linting

* resolve liniting issues

* fix wait-on

* fix package-lock.json

Co-authored-by: Elio Bischof <eliobischof@gmail.com>
This commit is contained in:
Max Peintner
2022-09-19 19:49:46 +02:00
committed by GitHub
parent 8505eb4cc9
commit fc4f4096e0
22 changed files with 522 additions and 526 deletions

View File

@@ -1,31 +1,22 @@
import {
Apps,
ensureProjectExists,
ensureProjectResourceDoesntExist,
} from "../../support/api/projects";
import { apiAuth } from "../../support/api/apiauth";
import { Apps, ensureProjectExists, ensureProjectResourceDoesntExist } from '../../support/api/projects';
import { apiAuth } from '../../support/api/apiauth';
describe("applications", () => {
const testProjectName = "e2eprojectapplication";
const testAppName = "e2eappundertest";
describe('applications', () => {
const testProjectName = 'e2eprojectapplication';
const testAppName = 'e2eappundertest';
beforeEach(`ensure it doesn't exist already`, () => {
apiAuth().then((api) => {
ensureProjectExists(api, testProjectName).then((projectID) => {
ensureProjectResourceDoesntExist(
api,
projectID,
Apps,
testAppName
).then(() => {
ensureProjectResourceDoesntExist(api, projectID, Apps, testAppName).then(() => {
cy.visit(`/projects/${projectID}`);
});
});
});
});
it("add app", () => {
cy.get('[data-e2e="app-card-add"]').should("be.visible").click();
it('add app', () => {
cy.get('[data-e2e="app-card-add"]').should('be.visible').click();
// select webapp
cy.get('[formcontrolname="name"]').type(testAppName);
cy.get('[for="WEB"]').click();
@@ -34,17 +25,17 @@ describe("applications", () => {
cy.get('[for="PKCE"]').click();
cy.get('[data-e2e="continue-button-authmethod"]').click();
//enter URL
cy.get("cnsl-redirect-uris").eq(0).type("https://testurl.org");
cy.get("cnsl-redirect-uris").eq(1).type("https://testlogouturl.org");
cy.get('cnsl-redirect-uris').eq(0).type('https://testurl.org');
cy.get('cnsl-redirect-uris').eq(1).type('https://testlogouturl.org');
cy.get('[data-e2e="continue-button-redirecturis"]').click();
cy.get('[data-e2e="create-button"]')
.click()
.then(() => {
cy.get("[id*=overlay]").should("exist");
cy.get('[id*=overlay]').should('exist');
});
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
//TODO: check client ID/Secret
});
});

View File

@@ -1,50 +1,39 @@
import { apiAuth } from "../../support/api/apiauth";
import {
ensureHumanUserExists,
ensureUserDoesntExist,
} from "../../support/api/users";
import { loginname } from "../../support/login/users";
import { apiAuth } from '../../support/api/apiauth';
import { ensureHumanUserExists, ensureUserDoesntExist } from '../../support/api/users';
import { loginname } from '../../support/login/users';
describe("humans", () => {
describe('humans', () => {
const humansPath = `/users?type=human`;
const testHumanUserNameAdd = "e2ehumanusernameadd";
const testHumanUserNameRemove = "e2ehumanusernameremove";
const testHumanUserNameAdd = 'e2ehumanusernameadd';
const testHumanUserNameRemove = 'e2ehumanusernameremove';
describe("add", () => {
describe('add', () => {
before(`ensure it doesn't exist already`, () => {
apiAuth().then((apiCallProperties) => {
ensureUserDoesntExist(apiCallProperties, testHumanUserNameAdd).then(
() => {
cy.visit(humansPath);
}
);
ensureUserDoesntExist(apiCallProperties, testHumanUserNameAdd).then(() => {
cy.visit(humansPath);
});
});
});
it("should add a user", () => {
cy.get('[data-e2e="create-user-button"]')
.click();
cy.url().should("contain", "users/create");
cy.get('[formcontrolname="email"]')
.type(loginname("e2ehuman", Cypress.env("ORGANIZATION")));
it('should add a user', () => {
cy.get('[data-e2e="create-user-button"]').click();
cy.url().should('contain', 'users/create');
cy.get('[formcontrolname="email"]').type(loginname('e2ehuman', Cypress.env('ORGANIZATION')));
//force needed due to the prefilled username prefix
cy.get('[formcontrolname="userName"]')
.type(testHumanUserNameAdd);
cy.get('[formcontrolname="firstName"]')
.type("e2ehumanfirstname");
cy.get('[formcontrolname="lastName"]')
.type("e2ehumanlastname");
cy.get('[formcontrolname="phone"]')
.type("+41 123456789");
cy.get('[formcontrolname="userName"]').type(testHumanUserNameAdd);
cy.get('[formcontrolname="firstName"]').type('e2ehumanfirstname');
cy.get('[formcontrolname="lastName"]').type('e2ehumanlastname');
cy.get('[formcontrolname="phone"]').type('+41 123456789');
cy.get('[data-e2e="create-button"]').click();
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
describe("remove", () => {
before("ensure it exists", () => {
describe('remove', () => {
before('ensure it exists', () => {
apiAuth().then((api) => {
ensureHumanUserExists(api, testHumanUserNameRemove).then(() => {
cy.visit(humansPath);
@@ -52,19 +41,19 @@ describe("humans", () => {
});
});
it("should delete a human user", () => {
cy.contains("tr", testHumanUserNameRemove)
it('should delete a human user', () => {
cy.contains('tr', testHumanUserNameRemove)
// doesn't work, need to force click.
// .trigger('mouseover')
.find('[data-e2e="enabled-delete-button"]')
.click({force: true});
.click({ force: true });
cy.get('[data-e2e="confirm-dialog-input"]')
.focus()
.type(loginname(testHumanUserNameRemove, Cypress.env("ORGANIZATION")));
.type(loginname(testHumanUserNameRemove, Cypress.env('ORGANIZATION')));
cy.get('[data-e2e="confirm-dialog-button"]').click();
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
});

View File

@@ -1,46 +1,37 @@
import { apiAuth } from "../../support/api/apiauth";
import {
ensureMachineUserExists,
ensureUserDoesntExist,
} from "../../support/api/users";
import { loginname } from "../../support/login/users";
import { apiAuth } from '../../support/api/apiauth';
import { ensureMachineUserExists, ensureUserDoesntExist } from '../../support/api/users';
import { loginname } from '../../support/login/users';
describe("machines", () => {
describe('machines', () => {
const machinesPath = `/users?type=machine`;
const testMachineUserNameAdd = "e2emachineusernameadd";
const testMachineUserNameRemove = "e2emachineusernameremove";
const testMachineUserNameAdd = 'e2emachineusernameadd';
const testMachineUserNameRemove = 'e2emachineusernameremove';
describe("add", () => {
describe('add', () => {
before(`ensure it doesn't exist already`, () => {
apiAuth().then((apiCallProperties) => {
ensureUserDoesntExist(apiCallProperties, testMachineUserNameAdd).then(
() => {
cy.visit(machinesPath);
}
);
ensureUserDoesntExist(apiCallProperties, testMachineUserNameAdd).then(() => {
cy.visit(machinesPath);
});
});
});
it("should add a machine", () => {
cy.get('[data-e2e="create-user-button"]')
.click();
cy.url().should("contain", "users/create-machine");
it('should add a machine', () => {
cy.get('[data-e2e="create-user-button"]').click();
cy.url().should('contain', 'users/create-machine');
//force needed due to the prefilled username prefix
cy.get('[formcontrolname="userName"]')
.type(testMachineUserNameAdd);
cy.get('[formcontrolname="name"]')
.type("e2emachinename");
cy.get('[formcontrolname="description"]')
.type("e2emachinedescription");
cy.get('[formcontrolname="userName"]').type(testMachineUserNameAdd);
cy.get('[formcontrolname="name"]').type('e2emachinename');
cy.get('[formcontrolname="description"]').type('e2emachinedescription');
cy.get('[data-e2e="create-button"]').click();
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
describe("remove", () => {
before("ensure it exists", () => {
describe('remove', () => {
before('ensure it exists', () => {
apiAuth().then((api) => {
ensureMachineUserExists(api, testMachineUserNameRemove).then(() => {
cy.visit(machinesPath);
@@ -48,19 +39,19 @@ describe("machines", () => {
});
});
it("should delete a machine", () => {
cy.contains("tr", testMachineUserNameRemove)
it('should delete a machine', () => {
cy.contains('tr', testMachineUserNameRemove)
// doesn't work, need to force click.
// .trigger('mouseover')
.find('[data-e2e="enabled-delete-button"]')
.click({force: true});
.click({ force: true });
cy.get('[data-e2e="confirm-dialog-input"]')
.focus()
.type(loginname(testMachineUserNameRemove, Cypress.env("ORGANIZATION")));
.type(loginname(testMachineUserNameRemove, Cypress.env('ORGANIZATION')));
cy.get('[data-e2e="confirm-dialog-button"]').click();
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
});

View File

@@ -1,49 +1,44 @@
import { apiAuth } from "../../support/api/apiauth";
import { ensureProjectExists, ensureProjectResourceDoesntExist, Roles } from "../../support/api/projects";
import { apiAuth } from '../../support/api/apiauth';
import { ensureProjectExists, ensureProjectResourceDoesntExist, Roles } from '../../support/api/projects';
describe('permissions', () => {
const testProjectName = 'e2eprojectpermission';
const testAppName = 'e2eapppermission';
const testRoleName = 'e2eroleundertestname';
const testRoleDisplay = 'e2eroleundertestdisplay';
const testRoleGroup = 'e2eroleundertestgroup';
const testGrantName = 'e2egrantundertest';
const testProjectName = 'e2eprojectpermission'
const testAppName = 'e2eapppermission'
const testRoleName = 'e2eroleundertestname'
const testRoleDisplay = 'e2eroleundertestdisplay'
const testRoleGroup = 'e2eroleundertestgroup'
const testGrantName = 'e2egrantundertest'
var projectId: number;
var projectId: number
beforeEach(() => {
apiAuth().then((apiCalls) => {
ensureProjectExists(apiCalls, testProjectName).then((projId) => {
projectId = projId;
});
});
});
describe('add role', () => {
beforeEach(() => {
apiAuth().then(apiCalls => {
ensureProjectExists(apiCalls, testProjectName).then(projId => {
projectId = projId
})
})
})
apiAuth().then((api) => {
ensureProjectResourceDoesntExist(api, projectId, Roles, testRoleName);
cy.visit(`/projects/${projectId}?id=roles`);
});
});
describe('add role', () => {
beforeEach(()=> {
apiAuth().then((api)=> {
ensureProjectResourceDoesntExist(api, projectId, Roles, testRoleName)
cy.visit(`/projects/${projectId}?id=roles`)
})
})
it('should add a role', () => {
cy.get('[data-e2e="add-new-role"]').click()
cy.get('[formcontrolname="key"]')
.type(testRoleName)
cy.get('[formcontrolname="displayName"]')
.type(testRoleDisplay)
cy.get('[formcontrolname="group"]')
.type(testRoleGroup)
cy.get('[data-e2e="save-button"]')
.click()
cy.get('.data-e2e-success')
cy.wait(200)
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist')
})
})
})
it('should add a role', () => {
cy.get('[data-e2e="add-new-role"]').click();
cy.get('[formcontrolname="key"]').type(testRoleName);
cy.get('[formcontrolname="displayName"]').type(testRoleDisplay);
cy.get('[formcontrolname="group"]').type(testRoleGroup);
cy.get('[data-e2e="save-button"]').click();
cy.get('.data-e2e-success');
cy.wait(200);
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
});
/*
describe('permissions', () => {
@@ -112,4 +107,4 @@ describe('permissions', () => {
})
})
*/
*/

View File

@@ -1,15 +1,12 @@
import { apiAuth } from "../../support/api/apiauth";
import {
ensureProjectDoesntExist,
ensureProjectExists,
} from "../../support/api/projects";
import { apiAuth } from '../../support/api/apiauth';
import { ensureProjectDoesntExist, ensureProjectExists } from '../../support/api/projects';
describe("projects", () => {
const testProjectNameCreate = "e2eprojectcreate";
const testProjectNameDeleteList = "e2eprojectdeletelist";
const testProjectNameDeleteGrid = "e2eprojectdeletegrid";
describe('projects', () => {
const testProjectNameCreate = 'e2eprojectcreate';
const testProjectNameDeleteList = 'e2eprojectdeletelist';
const testProjectNameDeleteGrid = 'e2eprojectdeletegrid';
describe("add project", () => {
describe('add project', () => {
beforeEach(`ensure it doesn't exist already`, () => {
apiAuth().then((api) => {
ensureProjectDoesntExist(api, testProjectNameCreate);
@@ -17,60 +14,56 @@ describe("projects", () => {
cy.visit(`/projects`);
});
it("should add a project", () => {
cy.get(".add-project-button").click({ force: true });
cy.get("input").type(testProjectNameCreate);
it('should add a project', () => {
cy.get('.add-project-button').click({ force: true });
cy.get('input').type(testProjectNameCreate);
cy.get('[data-e2e="continue-button"]').click();
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
describe("remove project", () => {
describe("list view", () => {
beforeEach("ensure it exists", () => {
describe('remove project', () => {
describe('list view', () => {
beforeEach('ensure it exists', () => {
apiAuth().then((api) => {
ensureProjectExists(api, testProjectNameDeleteList);
});
cy.visit(`/projects`);
});
it("removes the project", () => {
it('removes the project', () => {
cy.get('[data-e2e="toggle-grid"]').click();
cy.get('[data-e2e="timestamp"]');
cy.contains("tr", testProjectNameDeleteList, { timeout: 1000 })
cy.contains('tr', testProjectNameDeleteList, { timeout: 1000 })
.find('[data-e2e="delete-project-button"]')
.click({ force: true });
cy.get('[data-e2e="confirm-dialog-input"]')
.focus()
.type(testProjectNameDeleteList);
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDeleteList);
cy.get('[data-e2e="confirm-dialog-button"]').click();
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
describe("grid view", () => {
beforeEach("ensure it exists", () => {
describe('grid view', () => {
beforeEach('ensure it exists', () => {
apiAuth().then((api) => {
ensureProjectExists(api, testProjectNameDeleteGrid);
});
cy.visit(`/projects`);
});
it("removes the project", () => {
it('removes the project', () => {
cy.contains('[data-e2e="grid-card"]', testProjectNameDeleteGrid)
.find('[data-e2e="delete-project-button"]')
.click({force: true});
cy.get('[data-e2e="confirm-dialog-input"]')
.focus()
.type(testProjectNameDeleteGrid);
.click({ force: true });
cy.get('[data-e2e="confirm-dialog-input"]').focus().type(testProjectNameDeleteGrid);
cy.get('[data-e2e="confirm-dialog-button"]').click();
cy.get(".data-e2e-success");
cy.get('.data-e2e-success');
cy.wait(200);
cy.get(".data-e2e-failure", { timeout: 0 }).should("not.exist");
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
});
});
});

View File

@@ -1,45 +1,38 @@
import { apiAuth } from "../../support/api/apiauth";
import { ensureHumanUserExists } from "../../support/api/users";
import { login, User } from "../../support/login/users";
import { apiAuth } from '../../support/api/apiauth';
import { ensureHumanUserExists } from '../../support/api/users';
import { login, User } from '../../support/login/users';
describe("login policy", ()=> {
describe('login policy', () => {
const orgPath = `/org`;
const orgPath = `/org`
;[User.OrgOwner].forEach(user => {
describe(`as user "${user}"`, () => {
beforeEach(()=> {
login(user)
cy.visit(orgPath)
// TODO: Why force?
cy.contains('[data-e2e="policy-card"]', 'Login Policy').contains('button', 'Modify').click({force: true}) // TODO: select data-e2e
apiAuth().then(api => {
ensureHumanUserExists(api, User.LoginPolicyUser)
})
})
// TODO: verify email
it.skip(`username and password disallowed`, () => {
login(User.LoginPolicyUser, "123abcABC?&*")
})
it(`registering is allowed`)
it(`registering is disallowed`)
it(`login by an external IDP is allowed`)
it(`login by an external IDP is disallowed`)
it(`MFA is forced`)
it(`MFA is not forced`)
it(`the password reset option is hidden`)
it(`the password reset option is shown`)
it(`passwordless login is allowed`)
it(`passwordless login is disallowed`)
describe('identity providers', () => {
})
})
})
})
[User.OrgOwner].forEach((user) => {
describe(`as user "${user}"`, () => {
beforeEach(() => {
login(user);
cy.visit(orgPath);
// TODO: Why force?
cy.contains('[data-e2e="policy-card"]', 'Login Policy').contains('button', 'Modify').click({ force: true }); // TODO: select data-e2e
apiAuth().then((api) => {
ensureHumanUserExists(api, User.LoginPolicyUser);
});
});
// TODO: verify email
it.skip(`username and password disallowed`, () => {
login(User.LoginPolicyUser, '123abcABC?&*');
});
it(`registering is allowed`);
it(`registering is disallowed`);
it(`login by an external IDP is allowed`);
it(`login by an external IDP is disallowed`);
it(`MFA is forced`);
it(`MFA is not forced`);
it(`the password reset option is hidden`);
it(`the password reset option is shown`);
it(`passwordless login is allowed`);
it(`passwordless login is disallowed`);
describe('identity providers', () => {});
});
});
});

View File

@@ -1,34 +1,29 @@
import { login, User } from "../../support/login/users";
import { login, User } from '../../support/login/users';
describe("password complexity", ()=> {
describe('password complexity', () => {
const orgPath = `/org`;
const testProjectName = 'e2eproject';
const orgPath = `/org`
const testProjectName = 'e2eproject'
;[User.OrgOwner].forEach(user => {
describe(`as user "${user}"`, () => {
beforeEach(()=> {
login(user)
cy.visit(orgPath)
// TODO: Why force?
cy.contains('[data-e2e="policy-card"]', 'Password Complexity').contains('button', 'Modify').click({force: true}) // TODO: select data-e2e
})
// TODO: fix saving password complexity policy bug
it(`should restrict passwords that don't have the minimal length`)
it(`should require passwords to contain a number if option is switched on`)
it(`should not require passwords to contain a number if option is switched off`)
it(`should require passwords to contain a symbol if option is switched on`)
it(`should not require passwords to contain a symbol if option is switched off`)
it(`should require passwords to contain a lowercase letter if option is switched on`)
it(`should not require passwords to contain a lowercase letter if option is switched off`)
it(`should require passwords to contain an uppercase letter if option is switched on`)
it(`should not require passwords to contain an uppercase letter if option is switched off`)
})
})
})
[User.OrgOwner].forEach((user) => {
describe(`as user "${user}"`, () => {
beforeEach(() => {
login(user);
cy.visit(orgPath);
// TODO: Why force?
cy.contains('[data-e2e="policy-card"]', 'Password Complexity').contains('button', 'Modify').click({ force: true }); // TODO: select data-e2e
});
// TODO: fix saving password complexity policy bug
it(`should restrict passwords that don't have the minimal length`);
it(`should require passwords to contain a number if option is switched on`);
it(`should not require passwords to contain a number if option is switched off`);
it(`should require passwords to contain a symbol if option is switched on`);
it(`should not require passwords to contain a symbol if option is switched off`);
it(`should require passwords to contain a lowercase letter if option is switched on`);
it(`should not require passwords to contain a lowercase letter if option is switched off`);
it(`should require passwords to contain an uppercase letter if option is switched on`);
it(`should not require passwords to contain an uppercase letter if option is switched off`);
});
});
});