Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cypress config added #2

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# they will be requested for review when someone opens a pull request.
* @dinesh-aot @salabh-aot @jadmsaadaot @saravanpa-aot
* @dinesh-aot @jadmsaadaot @saravanpa-aot
21 changes: 21 additions & 0 deletions compliance-web/cypress.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable no-undef */

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { defineConfig } = require('cypress');

module.exports = defineConfig({
component: {
devServer: {
framework: "react",
bundler: "vite",
},
setupNodeEvents(on, config) {
require('@cypress/code-coverage/task')(on, config)
// include any other plugin code...

// It's IMPORTANT to return the config object
// with any changed environment variables
return config
},
},
});
46 changes: 46 additions & 0 deletions compliance-web/src/App.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { mount } from "cypress/react18"; // or `cypress/react18` if using React 18
import { ThemeProvider } from "@mui/material";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { AuthProvider } from "react-oidc-context";
import { OidcConfig } from "@/utils/config";
import { theme } from "@/styles/theme";
import { createRouter, RouterProvider } from "@tanstack/react-router";
import { routeTree } from "@/routeTree.gen";

const queryClient = new QueryClient();

const router = createRouter({
routeTree,
context: {
authentication: undefined!,
},
});

function TestApp({ authentication }) {
return (
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={theme}>
<AuthProvider {...OidcConfig}>
<RouterProvider router={router} context={{ authentication }} />
</AuthProvider>
</ThemeProvider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
}

describe("<App />", () => {
it("renders", () => {
const mockAuth = {
// mock the necessary properties and methods for useAuth context
isAuthenticated: true,
user: { profile: { name: "Test User" } },
signoutRedirect: cy.stub(),
signinRedirect: cy.stub(),
// add other necessary mocks here
};
mount(<TestApp authentication={mockAuth} />);
cy.contains("Users");
});
});
Loading