Skip to content

Commit

Permalink
test: first test draft
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaDellaValle committed Jul 19, 2023
1 parent 7242543 commit 23afa97
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
18 changes: 18 additions & 0 deletions test/e2e/ui/test/create-user.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from '@playwright/test';

test('Create user and save kubeconfig YAML to disk', async ({ page }) => {
/* SETUP */
const templateName = "developer";
const username = `test-user-${templateName}-${Date.now()}`;

await page.goto('/');
const createButton = await page.getByTestId('create-user');
await createButton.click();

await page.waitForURL('https://permission-manager.dev/create-new-user');
expect(page).toHaveURL(/.*create-new-user/);

const submitButton = await page.getByTestId('submit');

expect(submitButton).toBeVisible();
});
6 changes: 3 additions & 3 deletions web-client/src/views/CreateUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ const CreateUser = () => {

// Call to define Cluster Resources Access
clusterAccess !== 'none' && createClusterRoleBindings.mutate({
roleName: `template-cluster-resources___${clusterAccessOptions.find((c: clusterAccessOption) => c.id === clusterAccess).backendvalue}`,
roleName: `template-cluster-resources___${clusterAccessOptions.find((c: clusterAccessOption) => c.id === clusterAccess)?.backendvalue}`,
subjects: [{kind: 'ServiceAccount', name: username, namespace: 'permission-manager'}],
clusterRolebindingName: `${username}___template-cluster-resources___${clusterAccessOptions.find((c: clusterAccessOption) => c.id === clusterAccess).backendvalue}`,
clusterRolebindingName: `${username}___template-cluster-resources___${clusterAccessOptions.find((c: clusterAccessOption) => c.id === clusterAccess)?.backendvalue}`,
})
]).then(res => {
console.log('calls done', res);
Expand Down Expand Up @@ -249,7 +249,7 @@ const CreateUser = () => {
<EuiFlexItem>
<EuiFlexGroup direction='row' justifyContent='spaceBetween'>
<EuiFlexItem grow={false}><EuiTitle><h3>User data</h3></EuiTitle></EuiFlexItem>
<EuiFlexItem grow={false}><EuiButton fill isDisabled={!formIsFilled} onClick={handleSubmit}>CREATE</EuiButton></EuiFlexItem>
<EuiFlexItem grow={false}><EuiButton fill isDisabled={!formIsFilled} onClick={handleSubmit} data-test-subj='submit'>CREATE</EuiButton></EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>

Expand Down
12 changes: 11 additions & 1 deletion web-client/src/views/UsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ const UsersList = () => {
iconType='users'
title={<h5>No users defined yet</h5>}
titleSize='s'
actions={<EuiButtonEmpty color="success" href='/create-new-user' iconSide='right' iconType="plus">Create New User</EuiButtonEmpty>}
actions={
<EuiButtonEmpty
color="success"
iconType="plus"
iconSide="right"
href='/create-new-user'
data-test-subj="create-user"
>
Create New User
</EuiButtonEmpty>
}
/>
}
</EuiPageTemplate.Section>
Expand Down

0 comments on commit 23afa97

Please sign in to comment.