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

Fix cypress auth test and test debugging improvements #1728

Merged
merged 6 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 7 additions & 1 deletion .github/workflows/frontend_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x ]
node-version: [16.x]
defaults:
run:
working-directory: clients/admin-ui
Expand Down Expand Up @@ -73,6 +73,12 @@ jobs:
wait-on: "http://localhost:3000"
wait-on-timeout: 120

- uses: actions/upload-artifact@v3
ssangervasi marked this conversation as resolved.
Show resolved Hide resolved
if: failure()
with:
name: cypress-videos
path: /home/runner/work/fides/fides/clients/admin-ui/cypress/videos/*.mp4

Privacy-Center-Unit:
runs-on: ubuntu-latest
strategy:
Expand Down
3 changes: 3 additions & 0 deletions clients/admin-ui/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NEXT_PUBLIC_FIDESOPS_API=http://0.0.0.0:8080
NEXT_PUBLIC_FIDESCTL_API=/api/v1
NEXT_PUBLIC_FIDESCTL_API_SERVER=http://0.0.0.0:8080
12 changes: 6 additions & 6 deletions clients/admin-ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.local
# Only the dev, test, and prod defaults are tracked.
.env*
!.env.development
!.env.test
!.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down Expand Up @@ -108,5 +109,4 @@ dist
# msw web worker script
public/mockServiceWorker.js


out/
out/
4 changes: 4 additions & 0 deletions clients/admin-ui/cypress/e2e/auth.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ describe("User Authentication", () => {
cy.visit("/system");
cy.getByTestId("Systems");

cy.intercept("POST", "/api/v1/logout", {
statusCode: 204,
});

cy.getByTestId("header-menu-button").click();
cy.getByTestId("header-menu-sign-out").click();

Expand Down
9 changes: 3 additions & 6 deletions clients/admin-ui/cypress/e2e/datasets-classify.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ describe("Datasets with Fides Classify", () => {
cy.intercept("GET", "/api/v1/plus/classify", {
fixture: "classify/list.json",
}).as("getClassifyList");
cy.visit("/dataset/new");
cy.wait("@getPlusHealth");
});

describe("Creating datasets", () => {
it("Shows the classify switch", () => {
cy.visit("/dataset/new");
cy.getByTestId("connect-db-btn").click();

cy.getByTestId("input-classify").find("input").should("be.checked");
Expand All @@ -36,7 +37,6 @@ describe("Datasets with Fides Classify", () => {

it("Classifies the dataset after generating it", () => {
// Fill out the form.
cy.visit("/dataset/new");
cy.getByTestId("connect-db-btn").click();
cy.getByTestId("input-url").type(CONNECTION_STRING);
cy.getByTestId("create-dataset-btn").click();
Expand Down Expand Up @@ -192,10 +192,7 @@ describe("Datasets with Fides Classify", () => {
}
);

cy.getByTestId("approve-classification-btn")
.should("be.enabled")
.click()
.should("be.disabled");
cy.getByTestId("approve-classification-btn").should("be.enabled").click();

// The mutations should run.
cy.wait("@putDataset");
Expand Down
6 changes: 6 additions & 0 deletions clients/admin-ui/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const nextConfig = {
return config;
},
async rewrites() {
// The tests run without a server. Rewrites cause Next to continually try to connect,
// which spams the logs with "ECONNREFUSED".
if (process.env.NODE_ENV === "test") {
return [];
}
ssangervasi marked this conversation as resolved.
Show resolved Hide resolved

// these paths are unnecessarily complicated due to our backend being
// picky about trailing slashes https://github.com/ethyca/fides/issues/690
return [
Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"copy-export": "mkdir -p ../../src/fides/ui-build/static/admin/ && rsync -a --delete out/ ../../src/fides/ui-build/static/admin/",
"cy:open": "cypress open",
"cy:run": "cypress run",
"cy:start": "next build && NODE_ENV=test next start",
"cy:start": "NODE_ENV=test next build && NODE_ENV=test next start",
ssangervasi marked this conversation as resolved.
Show resolved Hide resolved
"dev": "next dev",
"dev:mock": "echo '🚨 Running with mock API'; NEXT_PUBLIC_MOCK_API=true next dev",
"export": "next build && next export",
Expand Down