Skip to content

Commit 3bda864

Browse files
committed
refactor: use enhanced dropdown and update tests
1 parent 8e1d2aa commit 3bda864

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/components/snapshot/AuthDomain.test.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Test AuthDomain component', () => {
4040
it('Displays authorization domain section', () => {
4141
mountAuthDomain([]);
4242

43-
cy.get('label[for="authorization-domain"]')
43+
cy.get('label[for="select-authorization-domain-select"]')
4444
.should('contain.text', 'Authorization Domain')
4545
.should('contain.text', '(optional)');
4646
});
@@ -52,12 +52,12 @@ describe('Test AuthDomain component', () => {
5252
];
5353
mountAuthDomain(userGroups);
5454

55-
cy.get('#authorization-domain-select')
55+
cy.get('#select-authorization-domain-select')
5656
.should('exist')
5757
.should('not.be.disabled')
5858
.should('have.value', '');
5959

60-
cy.get('#authorization-domain-select').parent().click();
60+
cy.get('#select-authorization-domain-select').parent().click();
6161
cy.get('[data-cy^=menuItem]').should('have.length', userGroups.length);
6262
});
6363

@@ -68,19 +68,19 @@ describe('Test AuthDomain component', () => {
6868
];
6969
mountAuthDomain(userGroups);
7070

71-
cy.get('#authorization-domain-select').parent().click();
71+
cy.get('#select-authorization-domain-select').parent().click();
7272
cy.get('[data-cy=menuItem-group2]').click();
73-
cy.get('#authorization-domain-select').should('have.value', 'group2');
73+
cy.get('#select-authorization-domain-select').should('have.value', 'group2');
7474
});
7575

7676
it('Enables authorization domain dropdown when sufficient user groups', () => {
7777
const userGroups = [{ groupEmail: 'email1', groupName: 'group1', role: 'READER' }];
7878
mountAuthDomain(userGroups);
79-
cy.get('#authorization-domain-select').should('not.be.disabled');
79+
cy.get('#select-authorization-domain-select').should('not.be.disabled');
8080
});
8181

8282
it('Disables authorization domain dropdown when empty user groups', () => {
8383
mountAuthDomain([]);
84-
cy.get('#authorization-domain-select').should('be.disabled');
84+
cy.get('#select-authorization-domain-select').should('be.disabled');
8585
});
8686
});

src/components/snapshot/AuthDomain.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ function AuthDomain({ dispatch, userGroups, setParentAuthDomain }: Readonly<Auth
2626

2727
return (
2828
<>
29-
<FormLabel sx={{ fontWeight: 700, color: '#333f52' }} htmlFor="authorization-domain">
29+
<FormLabel
30+
sx={{ fontWeight: 700, color: '#333f52' }}
31+
htmlFor="select-authorization-domain-select"
32+
>
3033
Authorization Domain
3134
<span style={{ fontWeight: 400, fontStyle: 'italic' }}> - (optional)</span>
3235
</FormLabel>
@@ -51,13 +54,14 @@ function AuthDomain({ dispatch, userGroups, setParentAuthDomain }: Readonly<Auth
5154
sx={{ height: '2.5rem' }}
5255
disabled={userGroups ? userGroups.length < 1 : true}
5356
options={userGroups ? userGroups.map((group) => group.groupName) : []}
54-
name="authorization-domain"
57+
name="Select Authorization Domain"
5558
onSelectedItem={(event) => {
5659
const authDomain = event.target.value;
5760
setParentAuthDomain(authDomain);
5861
setSelectedAuthDomain(authDomain);
5962
}}
6063
value={selectedAuthDomain ?? ''}
64+
includeNoneOption={true}
6165
/>
6266
</>
6367
);

0 commit comments

Comments
 (0)