Skip to content

Commit

Permalink
Update test and text
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus committed Sep 18, 2024
1 parent 2bb3989 commit 953dc98
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 62 deletions.
2 changes: 1 addition & 1 deletion web/packages/teleport/src/Users/Users.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ const sample = {
onEmailPasswordResetClose: () => null,
EmailPasswordReset: null,
showMauInfo: false,
onDismissUsersMAUNotice: () => null,
onDismissUsersMauNotice: () => null,
};
96 changes: 46 additions & 50 deletions web/packages/teleport/src/Users/Users.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('invite collaborators integration', () => {
onEmailPasswordResetClose: () => undefined,
EmailPasswordReset: null,
showMauInfo: false,
onDismissUsersMAUNotice: () => null,
onDismissUsersMauNotice: () => null,
};
});

Expand Down Expand Up @@ -107,57 +107,53 @@ describe('invite collaborators integration', () => {
});
});

describe('Users not equal to MAU Notice', () => {
test('Users not equal to MAU Notice', async () => {
const ctx = createTeleportContext();
let props: State;

beforeEach(() => {
props = {
attempt: {
message: 'success',
isSuccess: true,
isProcessing: false,
isFailed: false,
},
users: [],
fetchRoles: async () => [],
operation: { type: 'invite-collaborators' },
onStartCreate: () => undefined,
onStartDelete: () => undefined,
onStartEdit: () => undefined,
onStartReset: () => undefined,
onStartInviteCollaborators: () => undefined,
onClose: () => undefined,
onDelete: () => undefined,
onCreate: () => undefined,
onUpdate: () => undefined,
onReset: () => undefined,
onInviteCollaboratorsClose: () => undefined,
InviteCollaborators: null,
inviteCollaboratorsOpen: false,
onEmailPasswordResetClose: () => undefined,
EmailPasswordReset: null,
showMauInfo: true,
onDismissUsersMAUNotice: jest.fn(),
};
});

test('displayed Users Not Equal MAU Notice and dismissal', async () => {
const user = userEvent.setup();

render(
<MemoryRouter>
<ContextProvider ctx={ctx}>
<Users {...props} />
</ContextProvider>
</MemoryRouter>
);

expect(screen.getByTestId('users-not-mau-alert')).toBeInTheDocument();
await user.click(screen.getByRole('button', { name: 'Dismiss' }));
expect(props.onDismissUsersMAUNotice).toHaveBeenCalled();
expect(screen.queryByTestId('users-not-mau-alert')).not.toBeInTheDocument();
});
props = {
attempt: {
message: 'success',
isSuccess: true,
isProcessing: false,
isFailed: false,
},
users: [],
fetchRoles: async () => [],
operation: { type: 'invite-collaborators' },
onStartCreate: () => undefined,
onStartDelete: () => undefined,
onStartEdit: () => undefined,
onStartReset: () => undefined,
onStartInviteCollaborators: () => undefined,
onClose: () => undefined,
onDelete: () => undefined,
onCreate: () => undefined,
onUpdate: () => undefined,
onReset: () => undefined,
onInviteCollaboratorsClose: () => undefined,
InviteCollaborators: null,
inviteCollaboratorsOpen: false,
onEmailPasswordResetClose: () => undefined,
EmailPasswordReset: null,
showMauInfo: true,
onDismissUsersMauNotice: jest.fn(),
};

const user = userEvent.setup();

render(
<MemoryRouter>
<ContextProvider ctx={ctx}>
<Users {...props} />
</ContextProvider>
</MemoryRouter>
);

expect(screen.getByTestId('users-not-mau-alert')).toBeInTheDocument();
await user.click(screen.getByRole('button', { name: 'Dismiss' }));
expect(props.onDismissUsersMauNotice).toHaveBeenCalled();
expect(screen.queryByTestId('users-not-mau-alert')).not.toBeInTheDocument();
});

describe('email password reset integration', () => {
Expand Down Expand Up @@ -195,7 +191,7 @@ describe('email password reset integration', () => {
onEmailPasswordResetClose: () => undefined,
EmailPasswordReset: null,
showMauInfo: false,
onDismissUsersMAUNotice: () => null,
onDismissUsersMauNotice: () => null,
};
});

Expand Down
14 changes: 7 additions & 7 deletions web/packages/teleport/src/Users/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function Users(props: State) {
onStartEdit,
onStartReset,
showMauInfo,
onDismissUsersMAUNotice,
onDismissUsersMauNotice,
onClose,
onCreate,
onUpdate,
Expand Down Expand Up @@ -104,19 +104,19 @@ export function Users(props: State) {
<Alert
data-testid="users-not-mau-alert"
dismissible
onDismiss={onDismissUsersMAUNotice}
onDismiss={onDismissUsersMauNotice}
kind="info"
css={`
a.external-link {
color: ${({ theme }) => theme.colors.buttons.link.default};
}
`}
>
Note: The users displayed here are not an accurate reflection of
Monthly Active Users (MAU). For example, users who log in through
Single Sign-On (SSO) providers such as Okta will only appear here
temporarily and disappear once their sessions expire. For more
information, read our documentation on{' '}
The users displayed here are not an accurate reflection of Monthly
Active Users (MAU). For example, users who log in through Single
Sign-On (SSO) providers such as Okta may only appear here temporarily
and disappear once their sessions expire. For more information, read
our documentation on{' '}
<Link
target="_blank"
href="https://goteleport.com/docs/usage-billing/#monthly-active-users"
Expand Down
6 changes: 3 additions & 3 deletions web/packages/teleport/src/Users/useUsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default function useUsers({
return items.map(r => r.name);
}

function onDismissUsersMAUNotice() {
function onDismissUsersMauNotice() {
storageService.setUsersMAUAcknowledged();
}

Expand All @@ -134,7 +134,7 @@ export default function useUsers({
const showMauInfo =
ctx.getFeatureFlags().billing &&
cfg.isUsageBasedBilling &&
!storageService.getUsersMAUAcknowledged();
!storageService.getUsersMauAcknowledged();

return {
attempt,
Expand All @@ -157,7 +157,7 @@ export default function useUsers({
onEmailPasswordResetClose,
EmailPasswordReset,
showMauInfo,
onDismissUsersMAUNotice,
onDismissUsersMauNotice,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const storageService = {
window.localStorage.setItem(KeysEnum.LICENSE_ACKNOWLEDGED, 'true');
},

getUsersMAUAcknowledged(): boolean {
getUsersMauAcknowledged(): boolean {
return (
window.localStorage.getItem(
KeysEnum.USERS_NOT_EQUAL_TO_MAU_ACKNOWLEDGED
Expand Down

0 comments on commit 953dc98

Please sign in to comment.