Skip to content

Commit

Permalink
Merge pull request #2 from dinesh-aot/EPICSYSTEM-155
Browse files Browse the repository at this point in the history
cypress config added
  • Loading branch information
dinesh-aot authored Jul 26, 2024
2 parents e596956 + c46be52 commit 52d727c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
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");
});
});

0 comments on commit 52d727c

Please sign in to comment.