Skip to content

Commit

Permalink
Implemented component test for AuthDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanaem committed Jul 12, 2024
1 parent 262d710 commit 4cf60bd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions cypress/component/AuthDialog.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { GoogleOAuthProvider } from '@react-oauth/google';
import AuthDialog from '../../src/components/AuthDialog';

const props = {
isLoggedIn: false,
onAuth: () => {},
};

describe('ContinuousField', () => {
it('Displays a MUI dialog with the title and "sing in with google" button', () => {
cy.mount(
<GoogleOAuthProvider clientId="mock-client-id">
{' '}
<AuthDialog isLoggedIn={props.isLoggedIn} onAuth={props.onAuth} />
</GoogleOAuthProvider>
);
cy.get('[data-cy="auth-dialog"]').should('be.visible');
cy.get('[data-cy="auth-dialog"]').should(
'contain',
'Please login using one of the following before proceeding'
);
cy.get('[data-cy="auth-dialog"]').within(() => {
cy.contains('Sign in with Google');
});
});
});
2 changes: 1 addition & 1 deletion src/components/AuthDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function AuthDialog({
const fullScreen = useMediaQuery(theme.breakpoints.down('md'));

return (
<Dialog fullScreen={fullScreen} open={!isLoggedIn} data-cy="get-data-dialog">
<Dialog fullScreen={fullScreen} open={!isLoggedIn} data-cy="auth-dialog">
<DialogTitle>Please login using one of the following before proceeding</DialogTitle>
<DialogContent>
<div className="flex flex-col items-center justify-center">
Expand Down

0 comments on commit 4cf60bd

Please sign in to comment.