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

add tags to allow filter specs in cypress #15056

Merged
merged 11 commits into from
Feb 12, 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/e2eLabeler.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# E2E Labels when source files are changes
e2eLineage:
- 'openmetadata-ui/**/*lineage*'
- 'openmetadata-ui/**/*Lineage*'
- 'openmetadata-ui/**/*Lineage*'
3 changes: 2 additions & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
sync-labels: true

pr-e2e-labels:
# Job to assign e2e PR labels for cypress tags
name: pr-e2e-labels
Expand All @@ -33,4 +34,4 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/e2eLabeler.yml
sync-labels: true
sync-labels: true
2 changes: 2 additions & 0 deletions openmetadata-ui/src/main/resources/ui/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ overrides:
- off
jest/valid-expect:
- off
jest/valid-describe:
- off

# i18next rule is not required for js, jsx, json and test file
- files:
Expand Down
7 changes: 6 additions & 1 deletion openmetadata-ui/src/main/resources/ui/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ export default defineConfig({
experimentalStudio: true,
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.

setupNodeEvents(on, config) {
return plugins(on, config);
plugins(on, config);
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@cypress/grep/src/plugin')(config);

return config;
},
specPattern: ['cypress/e2e/**/*.{js,jsx,ts,tsx}'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const addColumnLineage = (fromNode, toNode) => {
);
};

describe('Lineage verification', () => {
describe('Lineage verification', { tags: 'Lineage' }, () => {
beforeEach(() => {
cy.login();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,21 @@ const checkSummaryListItemSorting = ({ termFQN, columnName }) => {
});
};

describe('Prerequisites', () => {
it('Create a user with data consumer role', () => {
const deleteUser = () => {
const token = localStorage.getItem('oidcIdToken');

cy.request({
method: 'DELETE',
url: `/api/v1/users/${createdUserId}?hardDelete=true&recursive=false`,
headers: { Authorization: `Bearer ${token}` },
}).then((response) => {
expect(response.status).to.eq(200);
});
};

describe('Glossary page should work properly', { tags: 'Glossary' }, () => {
before(() => {
// Prerequisites - Create a user with data consumer role
signupAndLogin(
CREDENTIALS.email,
CREDENTIALS.password,
Expand All @@ -696,9 +709,12 @@ describe('Prerequisites', () => {
createdUserId = id;
});
});
});

describe('Glossary page should work properly', () => {
after(() => {
cy.login();
deleteUser();
});

beforeEach(() => {
interceptURL('PATCH', '/api/v1/glossaryTerms/*', 'saveGlossaryTermData');
cy.login();
Expand Down Expand Up @@ -1206,28 +1222,8 @@ describe('Glossary page should work properly', () => {
termFQN: terms[0].fullyQualifiedName,
});
});
});

describe('Cleanup', () => {
beforeEach(() => {
Cypress.session.clearAllSavedSessions();
cy.login();
});

it('delete user', () => {
const token = localStorage.getItem('oidcIdToken');

cy.request({
method: 'DELETE',
url: `/api/v1/users/${createdUserId}?hardDelete=true&recursive=false`,
headers: { Authorization: `Bearer ${token}` },
}).then((response) => {
expect(response.status).to.eq(200);
});
});

it('Delete glossary term should work properly', () => {
goToGlossaryPage();
const terms = Object.values(NEW_GLOSSARY_TERMS);
selectActiveGlossary(NEW_GLOSSARY.name);
terms.forEach(deleteGlossaryTerm);
Expand All @@ -1238,7 +1234,6 @@ describe('Cleanup', () => {
});

it('Delete glossary should work properly', () => {
goToGlossaryPage();
verifyResponseStatusCode('@fetchGlossaries', 200);
[
NEW_GLOSSARY.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
// Import commands.js using ES2015 syntax:
import './commands';

import registerCypressGrep from '@cypress/grep';
import postgreSQL from 'cypress-postgresql';
postgreSQL.loadDBCommands();
registerCypressGrep();

// Alternatively you can use CommonJS syntax:
// require('./commands')
2 changes: 2 additions & 0 deletions openmetadata-ui/src/main/resources/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"js-antlr": "PWD=$(echo $PWD) antlr4 -Dlanguage=JavaScript -o src/generated/antlr \"$PWD\"/../../../../../openmetadata-spec/src/main/antlr4/org/openmetadata/schema/*.g4",
"cypress:open": "CYPRESS_BASE_URL=http://localhost:3000 cypress open --e2e",
"cypress:run": "CYPRESS_BASE_URL=http://localhost:8585 cypress run --config-file=cypress.config.ts",
"cypress:filter": "CYPRESS_BASE_URL=http://localhost:8585 cypress run --config-file=cypress.config.ts --env grepTags='Lineage',grepFilterSpecs=true",
"cypress:run:record": "cypress run --config-file=cypress.config.ts --record --parallel",
"i18n": "sync-i18n --files '**/locale/languages/*.json' --primary en-us --space 2 --fn",
"check-i18n": "npm run i18n -- --check"
Expand Down Expand Up @@ -147,6 +148,7 @@
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"@cypress/grep": "^4.0.1",
"@svgr/webpack": "^6.5.0",
"@testing-library/jest-dom": "^5.11.8",
"@testing-library/react": "^9.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ const mockLocation = {
};

const DummyChildrenComponent = () => {
const { loadChildNodesHandler, onEdgeClick, updateEntityType } =
useLineageProvider();
const {
loadChildNodesHandler,
onEdgeClick,
updateEntityType,
onLineageEditClick,
} = useLineageProvider();

const nodeData = {
name: 'table1',
Expand Down Expand Up @@ -74,6 +78,9 @@ const DummyChildrenComponent = () => {
<button data-testid="openConfirmationModal">
Close Confirmation Modal
</button>
<button data-testid="editLineage" onClick={onLineageEditClick}>
Edit Lineage
</button>
</div>
);
};
Expand All @@ -92,6 +99,12 @@ jest.mock('../Entity/EntityInfoDrawer/EdgeInfoDrawer.component', () => {
});
});

jest.mock('../Entity/EntityLineage/EntityLineageSidebar.component', () => {
return jest.fn().mockImplementation(() => {
return <p>Entity Lineage Sidebar</p>;
});
});

jest.mock('../../rest/lineageAPI', () => ({
getLineageDataByFQN: jest.fn(),
}));
Expand Down Expand Up @@ -128,6 +141,23 @@ describe('LineageProvider', () => {
expect(getLineageDataByFQN).toHaveBeenCalled();
});

it('should show sidebar when edit is clicked', async () => {
await act(async () => {
render(
<LineageProvider>
<DummyChildrenComponent />
</LineageProvider>
);
});

const loadButton = await screen.getByTestId('editLineage');
fireEvent.click(loadButton);

const edgeDrawer = screen.getByText('Entity Lineage Sidebar');

expect(edgeDrawer).toBeInTheDocument();
});

it('should show delete modal', async () => {
await act(async () => {
render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jest.mock('../rest/miscAPI', () => ({
addLineage: jest.fn(),
}));

// test
describe('Test EntityLineageUtils utility', () => {
it('getAllTracedNodes & isTracedEdge function should work properly', () => {
const { nodes, edges } = MOCK_NODES_AND_EDGES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import {
getPartialNameFromFQN,
getPartialNameFromTableFQN,
} from './CommonUtils';
import { getEntityName } from './EntityUtils';
import { getDecodedFqn } from './StringsUtils';
import { showErrorToast } from './ToastUtils';

Expand Down Expand Up @@ -562,7 +563,9 @@ export const createNodes = (
edgesData: EdgeDetails[],
entityFqn: string
) => {
const uniqueNodesData = removeDuplicateNodes(nodesData);
const uniqueNodesData = removeDuplicateNodes(nodesData).sort((a, b) =>
getEntityName(a).localeCompare(getEntityName(b))
);

// Create a new dagre graph
const graph = new dagre.graphlib.Graph();
Expand Down
47 changes: 45 additions & 2 deletions openmetadata-ui/src/main/resources/ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.19.0.tgz#4796bb14961521f0f8715990bee2fb6e51ce21bf"
integrity sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==

"@babel/helper-plugin-utils@^7.22.5":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz#dd7ee3735e8a313b9f7b05a773d892e88e6d7295"
integrity sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg==

"@babel/helper-remap-async-to-generator@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.14.5.tgz#51439c913612958f54a987a4ffc9ee587a2045d6"
Expand Down Expand Up @@ -1213,6 +1218,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"

"@babel/plugin-syntax-jsx@^7.22.5":
version "7.23.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz#8f2e4f8a9b5f9aa16067e142c1ac9cd9f810f473"
integrity sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg==
dependencies:
"@babel/helper-plugin-utils" "^7.22.5"

"@babel/plugin-syntax-logical-assignment-operators@^7.10.4", "@babel/plugin-syntax-logical-assignment-operators@^7.8.3":
version "7.10.4"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz#ca91ef46303530448b906652bac2e9fe9941f699"
Expand Down Expand Up @@ -2268,6 +2280,15 @@
resolved "https://registry.yarnpkg.com/@ctrl/tinycolor/-/tinycolor-3.4.1.tgz#75b4c27948c81e88ccd3a8902047bcd797f38d32"
integrity sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw==

"@cypress/grep@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@cypress/grep/-/grep-4.0.1.tgz#bce679f85da286c4979bb9ffc79b2782dc5b75c6"
integrity sha512-i3mWy4mG6nxF7m93W0nzsMZkl0PflGa4+SygA9P92tELayYYAaRKlr07I4fo5PnwoPk1H9IEbXoMFJkhfTMxtg==
dependencies:
debug "^4.3.4"
find-test-names "^1.19.0"
globby "^11.0.4"

"@cypress/request@2.88.12":
version "2.88.12"
resolved "https://registry.yarnpkg.com/@cypress/request/-/request-2.88.12.tgz#ba4911431738494a85e93fb04498cb38bc55d590"
Expand Down Expand Up @@ -4918,6 +4939,11 @@ acorn-walk@^8.0.0:
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.1.1.tgz#3ddab7f84e4a7e2313f6c414c5b7dac85f4e3ebc"
integrity sha512-FbJdceMlPHEAWJOILDk1fXD8lnTlEIWFkqtfk+MvmL5q/qlHfN7GEHcsFZWt/Tea9jRNPWUZG4G976nqAAmU9w==

acorn-walk@^8.2.0:
version "8.3.2"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa"
integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==

acorn@^7.1.1, acorn@^7.4.0, acorn@^7.4.1:
version "7.4.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
Expand Down Expand Up @@ -6827,7 +6853,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
dependencies:
ms "2.0.0"

debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2:
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1, debug@^4.3.3, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
Expand Down Expand Up @@ -8143,6 +8169,18 @@ find-cache-dir@^3.3.1:
make-dir "^3.0.2"
pkg-dir "^4.1.0"

find-test-names@^1.19.0:
version "1.28.18"
resolved "https://registry.yarnpkg.com/find-test-names/-/find-test-names-1.28.18.tgz#a10acba4ebd2e6db8e182e0fcc6f85d78fa29969"
integrity sha512-hhnGdkWK+qEA5Z02Tu0OqGQIUjFZNyOCE4WaJpbhW4hAF1+NZ7OCr0Bss9RCaj7BBtjoIjkU93utobQ8pg2iVg==
dependencies:
"@babel/parser" "^7.23.0"
"@babel/plugin-syntax-jsx" "^7.22.5"
acorn-walk "^8.2.0"
debug "^4.3.3"
globby "^11.0.4"
simple-bin-help "^1.8.0"

find-up@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
Expand Down Expand Up @@ -8520,7 +8558,7 @@ globby@^11.0.1:
merge2 "^1.3.0"
slash "^3.0.0"

globby@^11.0.3:
globby@^11.0.3, globby@^11.0.4:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
Expand Down Expand Up @@ -13722,6 +13760,11 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3:
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==

simple-bin-help@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/simple-bin-help/-/simple-bin-help-1.8.0.tgz#21bb82c6bccd9fa8678f9c0fadf2956b54e2160a"
integrity sha512-0LxHn+P1lF5r2WwVB/za3hLRIsYoLaNq1CXqjbrs3ZvLuvlWnRKrUjEWzV7umZL7hpQ7xULiQMV+0iXdRa5iFg==

simple-concat@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.1.tgz#f46976082ba35c2263f1c8ab5edfe26c41c9552f"
Expand Down
Loading