Skip to content

Commit

Permalink
chore: run format and lint existing code
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-cavazzi committed Jan 31, 2025
1 parent 39e52ff commit b85ea00
Show file tree
Hide file tree
Showing 19 changed files with 126 additions and 106 deletions.
8 changes: 4 additions & 4 deletions cypress-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Here is a list of the environment variable that you should set in the
`cypress.env.json` file:

| VARIABLE | USE |
|-----------------|-------------------------------------------------------|
| --------------- | ----------------------------------------------------- |
| BASE_URL | Full URL of the target environment. |
| TEST_EMAIL | The email used to register on Keycloak. |
| TEST_PASSWORD | Password. |
Expand All @@ -31,8 +31,8 @@ Here is a list of the environment variable that you should set in the
| TEST_USERNAME | Username. Usually, it's the email without the domain. |

> Tip: you might prefer not to save you password in plain text in the `cypress.env.json`
file. In that case, you can use the `TEST_PASSWORD` variable to the command line when
running the tests. For example `TEST_PASSWORD=mySecretPassword npm run e2e`.`
> file. In that case, you can use the `TEST_PASSWORD` variable to the command line when
> running the tests. For example `TEST_PASSWORD=mySecretPassword npm run e2e`.`
## Integration with CI pipeline

Expand All @@ -55,4 +55,4 @@ Re-running single tests would also fail when the deployment is deleted.
- Using the electron browser from Cypress will not work because a few features in
RenkuLab do not work with that (E.G: RStudio does not load at all).
- Tests currently do not run on Firefox. Please use [Chrome](https://www.google.com/chrome)
or [Chromium](https://www.chromium.org) instead.
or [Chromium](https://www.chromium.org) instead.
4 changes: 2 additions & 2 deletions cypress-tests/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export default defineConfig({
},
retries: {
runMode: 2,
openMode: null
openMode: null,
},
defaultCommandTimeout: TIMEOUTS.standard,
chromeWebSecurity: false,
viewportWidth: 1280,
viewportHeight: 960,
videoUploadOnPasses: false
videoUploadOnPasses: false,
});
4 changes: 2 additions & 2 deletions cypress-tests/cypress/e2e/checkWorkflows.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("Workflows pages", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
});

Expand All @@ -27,7 +27,7 @@ describe("Workflows pages", () => {
// Go the the workflows page and check the details of a workflow
cy.getProjectSection("Workflows").click();
cy.get("[data-cy=workflows-page]", { timeout: TIMEOUTS.long }).should(
"be.visible"
"be.visible",
);
cy.getDataCy("workflows-browser")
.should("be.visible")
Expand Down
10 changes: 7 additions & 3 deletions cypress-tests/cypress/e2e/privateProject.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Basic public project functionality", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
cy.createProjectIfMissing({
templateName: "Python",
Expand All @@ -55,7 +55,9 @@ describe("Basic public project functionality", () => {
cy.searchForProject(projectIdentifier, true);

// Check as an anonymous user
cy.session(["anonymous", getRandomString()], () => {});
cy.session(["anonymous", getRandomString()], () => {
cy.log("Anonyomous session setup");
});
cy.visit("/");
cy.get("#nav-hamburger").should("be.visible").click();
cy.searchForProject(projectIdentifier, false);
Expand Down Expand Up @@ -91,7 +93,9 @@ describe("Basic public project functionality", () => {
// Search the project as both logged in and logged out.
cy.searchForProject(projectIdentifier, true);
// Check as an anonymous user
cy.session(["anonymous", getRandomString()], () => {});
cy.session(["anonymous", getRandomString()], () => {
cy.log("Anonyomous session setup");
});
cy.visit("/");
cy.get("#nav-hamburger").should("be.visible").click();
cy.searchForProject(projectIdentifier, false);
Expand Down
12 changes: 7 additions & 5 deletions cypress-tests/cypress/e2e/publicProject.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Basic public project functionality", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
cy.createProjectIfMissing({ templateName: "Python", ...projectIdentifier });
cy.visitAndLoadProject(projectIdentifier);
Expand All @@ -49,7 +49,9 @@ describe("Basic public project functionality", () => {
cy.searchForProject(projectIdentifier);

// Check as an anonymous user
cy.session(["anonymous", getRandomString()], () => {});
cy.session(["anonymous", getRandomString()], () => {
cy.log("Anonyomous session setup");
});
cy.visit("/");
cy.get("#nav-hamburger").should("be.visible").click();
cy.searchForProject(projectIdentifier);
Expand Down Expand Up @@ -113,10 +115,10 @@ describe("Basic public project functionality", () => {
cy.get("div#tree-content").contains("metadata").should("exist").click();
cy.getProjectPageLink(
projectIdentifier,
"/files/blob/.renku/metadata/project"
"/files/blob/.renku/metadata/project",
).click();
cy.contains(
'"@renku_data_type": "renku.domain_model.project.Project"'
'"@renku_data_type": "renku.domain_model.project.Project"',
).should("exist");
cy.get("div#tree-content").contains("README.md").should("exist").click();
cy.contains("This is a Renku project")
Expand All @@ -127,7 +129,7 @@ describe("Basic public project functionality", () => {
it("Can view and modify sessions settings", () => {
cy.intercept("/ui-server/api/renku/*/config.set").as("configSet");
cy.intercept("/ui-server/api/renku/*/config.show?git_url=*").as(
"getConfig"
"getConfig",
);

// Make sure the renku.ini is in a pristine state
Expand Down
4 changes: 2 additions & 2 deletions cypress-tests/cypress/e2e/rstudioSession.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Basic rstudio functionality", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
cy.createProjectIfMissing({ templateName: "R (", ...projectIdentifier });
cy.stopAllSessionsForProject(projectIdentifier);
Expand Down Expand Up @@ -82,6 +82,6 @@ describe("Basic rstudio functionality", () => {
// Stops the session
cy.pauseSession();
cy.deleteSession();
}
},
);
});
6 changes: 3 additions & 3 deletions cypress-tests/cypress/e2e/testDatasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const sessionId = ["testDatasets", getRandomString()];
describe("Basic datasets functionality", () => {
before(() => {
// Intercept listing datasets
cy.intercept("/ui-server/api/renku/*/datasets.list?git_url=*", (req) => {
cy.intercept("/ui-server/api/renku/*/datasets.list?git_url=*", () => {
listDatasetsInvoked = true;
}).as("listDatasets");
});
Expand All @@ -40,7 +40,7 @@ describe("Basic datasets functionality", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
cy.createProjectIfMissing({ templateName: "Python", ...projectIdentifier });
cy.visitAndLoadProject(projectIdentifier);
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("Basic datasets functionality", () => {
cy.getDataCy("input-title").type(generatedDatasetName.name);

cy.getDataCy("input-keywords").type(
keywords.reduce((text, value) => `${text}${value}{enter}`, "")
keywords.reduce((text, value) => `${text}${value}{enter}`, ""),
);
cy.get("div.ck.ck-editor__main div.ck.ck-content")
.should("exist")
Expand Down
6 changes: 3 additions & 3 deletions cypress-tests/cypress/e2e/updateProjects.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("Fork and update old projects", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
});

Expand Down Expand Up @@ -125,9 +125,9 @@ describe("Fork and update old projects", () => {
let commitFetched = false;
cy.intercept(
"/ui-server/api/projects/*/repository/commits?ref_name=master&per_page=100&page=1",
(req) => {
() => {
commitFetched = true;
}
},
).as("getCommits");
cy.getDataCy("project-overview-nav")
.contains("a", "Commits")
Expand Down
23 changes: 13 additions & 10 deletions cypress-tests/cypress/e2e/useSession.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Basic public project functionality", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
cy.createProjectIfMissing({ templateName: "Python", ...projectIdentifier });
});
Expand All @@ -56,7 +56,7 @@ describe("Basic public project functionality", () => {

// Start a session with options
let serversInvoked = false;
cy.intercept("/ui-server/api/notebooks/servers*", (req) => {
cy.intercept("/ui-server/api/notebooks/servers*", () => {
serversInvoked = true;
}).as("getServers");
cy.getProjectSection("Sessions").click();
Expand Down Expand Up @@ -84,7 +84,7 @@ describe("Basic public project functionality", () => {
.contains("Starting Session")
.should("exist");
cy.get(".progress-box .progress-title", { timeout: TIMEOUTS.vlong }).should(
"not.exist"
"not.exist",
);

// Verify the "Connect" button works as well
Expand All @@ -101,7 +101,7 @@ describe("Basic public project functionality", () => {
cy.getIframe("iframe#session-iframe").within(() => {
// Open the terminal and check the repo is not ahead
cy.get(".jp-Launcher-content", { timeout: TIMEOUTS.long }).should(
"be.visible"
"be.visible",
);
cy.get(".jp-Launcher-section").should("be.visible");
cy.get('.jp-LauncherCard[title="Start a new terminal session"]')
Expand All @@ -112,7 +112,7 @@ describe("Basic public project functionality", () => {
cy.get(".xterm-helper-textarea")
.click()
.type(
`renku run --name ${workflow.name} echo "123" > ${workflow.output}{enter}`
`renku run --name ${workflow.name} echo "123" > ${workflow.output}{enter}`,
);
cy.get("#filebrowser")
.should("be.visible")
Expand Down Expand Up @@ -167,7 +167,9 @@ describe("Basic public project functionality", () => {

it("Start a new session as anonymous user.", () => {
// Do not re-use the logged-in session
cy.session(["anonymous", getRandomString()], () => {});
cy.session(["anonymous", getRandomString()], () => {
cy.log("Anonyomous session setup");
});

// Log out and go to the project again
cy.visit("/");
Expand Down Expand Up @@ -222,7 +224,7 @@ describe("Basic public project functionality", () => {
cy.request({ url: "ui-server/api/notebooks/version" }).then((resp) => {
if (!resp.body.versions[0].data.cloudstorageEnabled) {
cy.log(
"Skipping the test since the deployment doesn't support Cloud Storage"
"Skipping the test since the deployment doesn't support Cloud Storage",
);
return;
}
Expand All @@ -239,6 +241,7 @@ describe("Basic public project functionality", () => {
// Add a S3 storage configuration if it doesn't exist
cy.wait("@getProjectCloudStorage").then(({ response }) => {
const storages = response.body as { storage: { name: string } }[];
// eslint-disable-next-line max-nested-callbacks
if (storages.find(({ storage }) => storage.name === "data_s3")) {
return;
}
Expand Down Expand Up @@ -287,7 +290,7 @@ describe("Basic public project functionality", () => {
.click();

cy.getDataCy("cloud-storage-edit-body").contains(
"storage data_s3 has been successfully added"
"storage data_s3 has been successfully added",
);
cy.getDataCy("cloud-storage-edit-close-button")
.should("be.visible")
Expand Down Expand Up @@ -327,7 +330,7 @@ describe("Basic public project functionality", () => {
// Verify that the S3 data is mounted
cy.getIframe("iframe#session-iframe").within(() => {
cy.get(".jp-DirListing-content", { timeout: TIMEOUTS.long }).should(
"be.visible"
"be.visible",
);
cy.get(".jp-DirListing-item")
.contains("data_s3")
Expand All @@ -340,7 +343,7 @@ describe("Basic public project functionality", () => {
.dblclick();

cy.get(".jp-FileEditor", { timeout: TIMEOUTS.long }).should(
"be.visible"
"be.visible",
);
cy.get(".jp-FileEditor")
.contains("The GIAB s3 bucket and URLs")
Expand Down
8 changes: 4 additions & 4 deletions cypress-tests/cypress/e2e/v2/dashboardV2.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("Dashboard v2 - Authenticated user", () => {
() => {
cy.robustLogin();
},
validateLogin
validateLogin,
);
getUserNamespaceAPIV2().then((namespace) => {
if (namespace) {
Expand All @@ -67,7 +67,7 @@ describe("Dashboard v2 - Authenticated user", () => {
.find("a")
.should(
"contain.text",
`${prefixProjectTitle} ${projectIdentifier.slug}`
`${prefixProjectTitle} ${projectIdentifier.slug}`,
);
cy.getDataCy("dashboard-project-list")
.find("a")
Expand All @@ -80,7 +80,7 @@ describe("Dashboard v2 - Authenticated user", () => {
cy.getDataCy("search-card").should("have.length.at.least", 1);
cy.getDataCy("search-card").should(
"contain.text",
`${prefixProjectTitle} ${projectIdentifier.slug}`
`${prefixProjectTitle} ${projectIdentifier.slug}`,
);
});
});
Expand All @@ -91,7 +91,7 @@ describe("Dashboard v2 - Non-Authenticated user", () => {
cy.getDataCy("user-container").should("be.visible");
cy.getDataCy("user-container").should(
"contain.text",
"You are not logged in."
"You are not logged in.",
);
});
});
Empty file.
10 changes: 5 additions & 5 deletions cypress-tests/cypress/e2e/verifyInfrastructure.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ function retryRequest(
service: string,
limit = 10,
delaySeconds = 30,
retries = 1
retries = 1,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Cypress.Response<any> {
if (retries > limit) {
const minutes = Math.floor((limit * delaySeconds) / 60);
throw new Error(
`Backend service "${service}" not responding within ${minutes} minutes at URL ${url}.`
`Backend service "${service}" not responding within ${minutes} minutes at URL ${url}.`,
);
}

Expand All @@ -28,7 +28,7 @@ function retryRequest(
if (resp.status < 400 && !resp.body.error) return resp.body;

cy.wait(delaySeconds * 1000).then(() =>
retryRequest(url, service, limit, delaySeconds, retries + 1)
retryRequest(url, service, limit, delaySeconds, retries + 1),
);
});
return null;
Expand All @@ -44,7 +44,7 @@ describe("Verify the infrastructure is ready", () => {
retryRequest("api/auth/login", "Gateway");
retryRequest(
`ui-server/api/allows-iframe/${encodeURIComponent("https://google.com")}`,
"UI server"
"UI server",
);
retryRequest("config.json", "UI client");

Expand All @@ -60,7 +60,7 @@ describe("Verify the infrastructure is ready", () => {
const gitUrl =
"https://gitlab.dev.renku.ch/renku-ui-tests/renku-project-v10";
const coreUrl = `/ui-server/api/renku/config.show?git_url=${encodeURIComponent(
gitUrl
gitUrl,
)}`;
cy.request(coreUrl).then((resp) => {
if (resp.status >= 400 || !("result" in resp.body))
Expand Down
7 changes: 4 additions & 3 deletions cypress-tests/cypress/support/commands/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export const validateLogin = {
// If we send a request to the user endpoint on Gitlab too quickly after we log in then
// it sometimes randomly responds with 401 and sometimes with 200 (as expected). This wait period seems to
// allow Gitlab to "settle" after the login and properly recognize the token and respond with 200.
cy.wait(10000);
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(10_000);
// This returns 401 when not properly logged in
cy.request("ui-server/api/data/user").its("status").should("eq", 200);
// This is how the ui decides the user is logged in
Expand Down Expand Up @@ -35,8 +36,8 @@ function getDataCy(value: string, exist?: boolean) {
return cy.get(`[data-cy=${value}]`);
}

export function getRandomString(length: number=8) {
return Math.random().toString(20).substr(2, length)
export function getRandomString(length = 8) {
return Math.random().toString(20).substring(2, length);
}

export default function registerGeneralCommands() {
Expand Down
Loading

0 comments on commit b85ea00

Please sign in to comment.