Skip to content

Commit

Permalink
feat(ci): add linting for cypress tests (#10424)
Browse files Browse the repository at this point in the history
Co-authored-by: Harshal Sheth <[email protected]>
Co-authored-by: gaurav2733 <[email protected]>
  • Loading branch information
3 people authored May 7, 2024
1 parent 28e97dd commit 71759f9
Show file tree
Hide file tree
Showing 54 changed files with 7,573 additions and 5,807 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/docker-unified.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ jobs:
if: ${{ steps.ci-optimize.outputs.smoke-test-change == 'true' }}
run: |
python ./.github/scripts/check_python_package.py
./gradlew :smoke-test:lint
./gradlew :smoke-test:pythonLint
./gradlew :smoke-test:cypressLint
gms_build:
name: Build and Push DataHub GMS Docker Image
Expand Down
9 changes: 7 additions & 2 deletions smoke-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ task yarnInstall(type: YarnTask) {
environment = ['NODE_OPTIONS': '--openssl-legacy-provider']
args = ['install', '--cwd', "${project.rootDir}/smoke-test/tests/cypress"]
}
task cypressLint(type: YarnTask, dependsOn: yarnInstall) {
environment = ['NODE_OPTIONS': '--openssl-legacy-provider']
// TODO: Run a full lint instead of just format.
args = ['--cwd', "${project.rootDir}/smoke-test/tests/cypress", 'run', 'format']
}

task installDev(type: Exec) {
inputs.file file('pyproject.toml')
Expand All @@ -58,15 +63,15 @@ task installDev(type: Exec) {
"touch ${venv_name}/.build_install_dev_sentinel"
}

task lint(type: Exec, dependsOn: installDev) {
task pythonLint(type: Exec, dependsOn: installDev) {
commandLine 'bash', '-c',
"source ${venv_name}/bin/activate && set -x && " +
"black --check --diff tests/ && " +
"isort --check --diff tests/ && " +
"ruff --statistics tests/ && " +
"mypy tests/"
}
task lintFix(type: Exec, dependsOn: installDev) {
task pythonLintFix(type: Exec, dependsOn: installDev) {
commandLine 'bash', '-c',
"source ${venv_name}/bin/activate && set -x && " +
"black tests/ && " +
Expand Down
31 changes: 31 additions & 0 deletions smoke-test/tests/cypress/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
env: {
es2021: true,
node: true,
},
plugins: ["cypress"],
extends: ["airbnb-base", "plugin:cypress/recommended", "prettier"],
overrides: [
{
env: {
node: true,
},
files: [".eslintrc.{js,cjs}"],
parserOptions: {
sourceType: "script",
},
},
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
rules: {
camelcase: "off",
"import/prefer-default-export": "off",
// TODO: These should be upgraded to warnings and fixed.
"cypress/no-unnecessary-waiting": "off",
"cypress/unsafe-to-chain-command": "off",
"no-unused-vars": "off",
},
};
14 changes: 8 additions & 6 deletions smoke-test/tests/cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { defineConfig } = require('cypress')
// eslint-disable-next-line global-require
const { defineConfig } = require("cypress");

module.exports = defineConfig({
chromeWebSecurity: false,
viewportHeight: 960,
viewportWidth: 1536,
projectId: 'hkrxk5',
projectId: "hkrxk5",
defaultCommandTimeout: 10000,
retries: {
runMode: 2,
Expand All @@ -15,10 +16,11 @@ module.exports = defineConfig({
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
// eslint-disable-next-line global-require
return require("./cypress/plugins/index")(on, config);
},
baseUrl: 'http://localhost:9002/',
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
baseUrl: "http://localhost:9002/",
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
experimentalStudio: true,
},
})
});
10 changes: 5 additions & 5 deletions smoke-test/tests/cypress/cypress/e2e/analytics/analytics.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('analytics', () => {
it('can go to a chart and see analytics in tab views', () => {
describe("analytics", () => {
it("can go to a chart and see analytics in tab views", () => {
cy.login();

cy.goToChart("urn:li:chart:(looker,cypress_baz1)");
Expand All @@ -9,8 +9,8 @@ describe('analytics', () => {

cy.goToAnalytics();
cy.contains("Tab Views By Entity Type (Past Week)").scrollIntoView({
ensureScrollable: false
})
ensureScrollable: false,
});
cy.waitTextPresent("dashboards");
});
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("auto-complete", () => {
cy.get('[data-testid^="auto-complete-option"]').first().click();
cy.url().should(
"include",
"dataset/urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)"
"dataset/urn:li:dataset:(urn:li:dataPlatform:hive,SampleCypressHiveDataset,PROD)",
);
cy.wait(2000);
});
Expand All @@ -43,7 +43,7 @@ describe("auto-complete", () => {
cy.get('[data-testid="quick-filter-DASHBOARD"]').click();
cy.wait(2000);
cy.get('[data-testid="auto-complete-entity-name-Baz Chart 2').should(
"not.exist"
"not.exist",
);
cy.contains("Baz Dashboard");
cy.wait(1000);
Expand All @@ -58,7 +58,7 @@ describe("auto-complete", () => {
cy.focused().type("{enter}");
cy.url().should(
"include",
"?filter_platform___false___EQUAL___0=urn%3Ali%3AdataPlatform%3Abigquery"
"?filter_platform___false___EQUAL___0=urn%3Ali%3AdataPlatform%3Abigquery",
);
});
});
32 changes: 16 additions & 16 deletions smoke-test/tests/cypress/cypress/e2e/browse/browseV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,31 @@ describe("search", () => {
cy.url().should("include", "/browse/dataset");
cy.url().should(
"not.include",
"search?filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET"
"search?filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET",
);
});

it("should take you to the new browse experience when clicking on browse path from entity profile page when browse flag is on", () => {
setBrowseFeatureFlag(true);
cy.login();
cy.visit(
"/dataset/urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.customers,PROD)"
"/dataset/urn:li:dataset:(urn:li:dataPlatform:bigquery,cypress_project.jaffle_shop.customers,PROD)",
);
cy.get('[data-testid="browse-path-cypress_project"]').click({
force: true,
});
cy.url().should("not.include", "/browse/dataset");
cy.url().should(
"include",
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET"
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET",
);
cy.url().should(
"include",
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery"
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery",
);
cy.url().should(
"include",
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project"
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project",
);
});

Expand Down Expand Up @@ -135,7 +135,7 @@ describe("search", () => {
cy.url().should("not.include", "/browse/dataset");
cy.url().should(
"include",
"search?filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET"
"search?filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET",
);
cy.get("[data-testid=browse-platform-BigQuery]");
});
Expand All @@ -156,15 +156,15 @@ describe("search", () => {

cy.url().should(
"include",
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET"
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET",
);
cy.url().should(
"include",
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery"
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery",
);
cy.url().should(
"include",
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project%E2%90%9Fjaffle_shop"
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project%E2%90%9Fjaffle_shop",
);

// close each of the levels, ensuring its children aren't visible anymore
Expand All @@ -175,7 +175,7 @@ describe("search", () => {

cy.get("[data-testid=browse-platform-BigQuery]").click({ force: true });
cy.get("[data-testid=browse-node-expand-cypress_project]").should(
"not.be.visible"
"not.be.visible",
);

cy.get("[data-testid=browse-entity-Datasets]").click({ force: true });
Expand All @@ -197,30 +197,30 @@ describe("search", () => {

cy.url().should(
"include",
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET"
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET",
);
cy.url().should(
"include",
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery"
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery",
);
cy.url().should(
"include",
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project%E2%90%9Fjaffle_shop"
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project%E2%90%9Fjaffle_shop",
);

cy.get("[data-testid=browse-node-jaffle_shop]").click({ force: true });

cy.url().should(
"not.include",
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET"
"filter__entityType%E2%90%9EtypeNames___false___EQUAL___0=DATASET",
);
cy.url().should(
"not.include",
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery"
"filter_platform___false___EQUAL___1=urn%3Ali%3AdataPlatform%3Abigquery",
);
cy.url().should(
"not.include",
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project%E2%90%9Fjaffle_shop"
"filter_browsePathV2___false___EQUAL___2=%E2%90%9Fcypress_project%E2%90%9Fjaffle_shop",
);
});
});
Loading

0 comments on commit 71759f9

Please sign in to comment.