Wizard: Add remove user button in users step

this adds remove user button and add unit test as well.
This commit is contained in:
Michal Gold 2025-01-22 15:50:55 +02:00 committed by Lucas Garfield
parent 96d68583a3
commit 6e36232e1a
3 changed files with 51 additions and 2 deletions

View file

@ -62,6 +62,14 @@ const clickAddUser = async () => {
expect(addUser).toBeEnabled();
await waitFor(() => user.click(addUser));
};
const clickRemoveUser = async () => {
const user = userEvent.setup();
const addUser = await screen.findByRole('button', { name: /remove user/i });
expect(addUser).toBeEnabled();
await waitFor(() => user.click(addUser));
};
const addSshKey = async (sshKey: string) => {
const user = userEvent.setup();
const enterSshKey = await screen.findByRole('textbox', {
@ -70,6 +78,7 @@ const addSshKey = async (sshKey: string) => {
await waitFor(() => user.type(enterSshKey, sshKey));
await waitFor(() => expect(enterSshKey).toHaveValue(sshKey));
};
const addUserName = async (userName: string) => {
const user = userEvent.setup();
const enterUserName = screen.getByRole('textbox', {
@ -189,6 +198,27 @@ describe('User request generated correctly', () => {
expect(receivedRequest).toEqual(expectedRequest);
});
});
test('remove a user', async () => {
await renderCreateMode();
await goToRegistrationStep();
await clickRegisterLater();
await goToUsersStep();
await clickAddUser();
await addUserName('test');
await addSshKey('ssh-rsa');
await clickRemoveUser();
await waitFor(() => expect('add a user to your image'));
await goToReviewStep();
const receivedRequest = await interceptBlueprintRequest(CREATE_BLUEPRINT);
const expectedRequest = {
...blueprintRequest,
customizations: {},
};
await waitFor(() => {
expect(receivedRequest).toEqual(expectedRequest);
});
});
});
describe('Users edit mode', () => {