mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-10 22:53:42 +00:00
62 lines
2.4 KiB
TypeScript
62 lines
2.4 KiB
TypeScript
import { apiAuth } from '../../support/api/apiauth';
|
|
import { ensureMachineUserExists, ensureUserDoesntExist } from '../../support/api/users';
|
|
import { login, User, username } from '../../support/login/users';
|
|
|
|
describe('machines', () => {
|
|
const machinesPath = `${Cypress.env('baseUrl')}/ui/console/users?type=machine`;
|
|
const testMachineUserNameAdd = 'e2emachineusernameadd';
|
|
const testMachineUserNameRemove = 'e2emachineusernameremove';
|
|
|
|
[User.OrgOwner].forEach((user) => {
|
|
describe(`as user "${user}"`, () => {
|
|
beforeEach(() => {
|
|
login(user);
|
|
cy.visit(machinesPath);
|
|
cy.get('[data-e2e=timestamp]');
|
|
});
|
|
|
|
describe('add', () => {
|
|
before(`ensure it doesn't exist already`, () => {
|
|
apiAuth().then((apiCallProperties) => {
|
|
ensureUserDoesntExist(apiCallProperties, testMachineUserNameAdd);
|
|
});
|
|
});
|
|
|
|
it('should add a machine', () => {
|
|
cy.get('[data-e2e="action-key-add"]').parents('[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, { force: true });
|
|
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.wait(200);
|
|
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
|
});
|
|
});
|
|
|
|
describe('remove', () => {
|
|
before('ensure it exists', () => {
|
|
apiAuth().then((api) => {
|
|
ensureMachineUserExists(api, testMachineUserNameRemove);
|
|
});
|
|
});
|
|
|
|
it('should delete a machine', () => {
|
|
cy.contains('tr', testMachineUserNameRemove, { timeout: 1000 })
|
|
// doesn't work, need to force click.
|
|
// .trigger('mouseover')
|
|
.find('[e2e-data="enabled-delete-button"]')
|
|
.click({force: true});
|
|
cy.get('[e2e-data="confirm-dialog-input"]').click().type(username(testMachineUserNameRemove, Cypress.env('org')));
|
|
cy.get('[e2e-data="confirm-dialog-button"]').click();
|
|
cy.get('.data-e2e-success');
|
|
cy.wait(200);
|
|
cy.get('.data-e2e-failure', { timeout: 0 }).should('not.exist');
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|