Skip to content

Commit

Permalink
wip 😕
Browse files Browse the repository at this point in the history
  • Loading branch information
leafty committed Sep 30, 2024
1 parent 3dd6655 commit e9f6262
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 81 deletions.
166 changes: 86 additions & 80 deletions tests/cypress/e2e/projectV2Session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe("launch sessions with cloud storage", () => {
cy.url().should("match", /\/projects\/.*\/sessions\/.*\/start$/);
});

it("launch session with data source, saving credentials", () => {
it.only("launch session with data source, saving credentials", () => {

Check failure on line 187 in tests/cypress/e2e/projectV2Session.spec.ts

View workflow job for this annotation

GitHub Actions / lint-e2e

it.only not permitted
fixtures
.testCloudStorage()
.cloudStorage({
Expand Down Expand Up @@ -224,15 +224,15 @@ describe("launch sessions with cloud storage", () => {
// The following two lines are for when the credentials are not in the config, but
// this causes problems, allow them to be there for now
// See also projectCloudStorage.utils.ts:storageDefinitionAfterSavingCredentialsFromConfig
// expect(storage.configuration).to.not.have.property("access_key_id");
// expect(storage.configuration).to.not.have.property("secret_access_key");
expect(storage.configuration).to.not.have.property("access_key_id");
expect(storage.configuration).to.not.have.property("secret_access_key");

expect(storage.configuration).to.have.property("access_key_id");
expect(storage.configuration).to.have.property("secret_access_key");
expect(storage.configuration["access_key_id"]).to.equal("access key");
expect(storage.configuration["secret_access_key"]).to.equal(
"secret key"
);
// expect(storage.configuration).to.have.property("access_key_id");
// expect(storage.configuration).to.have.property("secret_access_key");
// expect(storage.configuration["access_key_id"]).to.equal("access key");
// expect(storage.configuration["secret_access_key"]).to.equal(
// "secret key"
// );
req.reply({ body: sessions[0] });
}).as("createSession");
});
Expand Down Expand Up @@ -269,7 +269,13 @@ describe("launch sessions with cloud storage", () => {
.click();
cy.wait("@testCloudStorage");
cy.contains("Saving credentials...").should("be.visible");
cy.wait("@postCloudStorageSecrets");
cy.wait("@postCloudStorageSecrets").then(() => {
fixtures.cloudStorage({
isV2: true,
fixture: "cloudStorage/cloud-storage-with-secrets-values-full.json",
name: "getCloudStorageV2WithSecrets",
});
});
cy.wait("@createSession");
cy.url().should("match", /\/projects\/.*\/sessions\/.*\/start$/);
});
Expand Down Expand Up @@ -391,76 +397,76 @@ describe("launch sessions with cloud storage", () => {
cy.url().should("match", /\/projects\/.*\/sessions\/.*\/start$/);
});

it("launch session with incomplete saved credentials", () => {
fixtures
.testCloudStorage()
.cloudStorage({
isV2: true,
fixture: "cloudStorage/cloud-storage-with-secrets-values-partial.json",
name: "getCloudStorageV2",
})
.cloudStorageSecrets({
fixture: "cloudStorage/cloud-storage-secrets-partial.json",
});

cy.visit("/v2/projects/user1-uuid/test-2-v2-project");
cy.wait("@readProjectV2");
cy.wait("@getSessionServers");
cy.wait("@sessionLaunchers");

// start session
fixtures.postCloudStorageSecrets({
content: [
{
name: "access_key_id",
value: "access key",
},
{
name: "secret_access_key",
value: "secret key",
},
],
});

cy.fixture("sessions/sessionsV2.json").then((sessions) => {
// eslint-disable-next-line max-nested-callbacks
cy.intercept("POST", "/ui-server/api/notebooks/v2/servers", (req) => {
const csConfig = req.body.cloudstorage;
expect(csConfig.length).equal(1);
const storage = csConfig[0];
expect(storage.storage_id).to.equal("2");
expect(storage.configuration).to.have.property("access_key_id");
expect(storage.configuration).to.have.property("secret_access_key");
expect(storage.configuration["access_key_id"]).to.equal("access key");
expect(storage.configuration["secret_access_key"]).to.equal(
"secret key"
);
req.reply({ body: sessions[0] });
}).as("createSession");
});

fixtures.getSessions({ fixture: "sessions/sessionsV2.json" });
cy.getDataCy("session-launcher-item")
.first()
.within(() => {
cy.getDataCy("start-session-button").click();
});
cy.getDataCy("session-cloud-storage-credentials-modal")
.find("#access_key_id")
.type("access key");
cy.getDataCy("session-cloud-storage-credentials-modal")
.contains("Secret Access Key (password)")
.should("be.visible");
cy.getDataCy("session-cloud-storage-credentials-modal")
.find("#secret_access_key")
.type("secret key");
cy.getDataCy("session-cloud-storage-credentials-modal")
.contains("Continue")
.click();
cy.wait("@testCloudStorage");
cy.wait("@createSession");
cy.url().should("match", /\/projects\/.*\/sessions\/.*\/start$/);
});
// it("launch session with incomplete saved credentials", () => {
// fixtures
// .testCloudStorage()
// .cloudStorage({
// isV2: true,
// fixture: "cloudStorage/cloud-storage-with-secrets-values-partial.json",
// name: "getCloudStorageV2",
// })
// .cloudStorageSecrets({
// fixture: "cloudStorage/cloud-storage-secrets-partial.json",
// });

// cy.visit("/v2/projects/user1-uuid/test-2-v2-project");
// cy.wait("@readProjectV2");
// cy.wait("@getSessionServers");
// cy.wait("@sessionLaunchers");

// // start session
// fixtures.postCloudStorageSecrets({
// content: [
// {
// name: "access_key_id",
// value: "access key",
// },
// {
// name: "secret_access_key",
// value: "secret key",
// },
// ],
// });

// cy.fixture("sessions/sessionsV2.json").then((sessions) => {
// // eslint-disable-next-line max-nested-callbacks
// cy.intercept("POST", "/ui-server/api/notebooks/v2/servers", (req) => {
// const csConfig = req.body.cloudstorage;
// expect(csConfig.length).equal(1);
// const storage = csConfig[0];
// expect(storage.storage_id).to.equal("2");
// expect(storage.configuration).to.have.property("access_key_id");
// expect(storage.configuration).to.have.property("secret_access_key");
// expect(storage.configuration["access_key_id"]).to.equal("access key");
// expect(storage.configuration["secret_access_key"]).to.equal(
// "secret key"
// );
// req.reply({ body: sessions[0] });
// }).as("createSession");
// });

// fixtures.getSessions({ fixture: "sessions/sessionsV2.json" });
// cy.getDataCy("session-launcher-item")
// .first()
// .within(() => {
// cy.getDataCy("start-session-button").click();
// });
// cy.getDataCy("session-cloud-storage-credentials-modal")
// .find("#access_key_id")
// .type("access key");
// cy.getDataCy("session-cloud-storage-credentials-modal")
// .contains("Secret Access Key (password)")
// .should("be.visible");
// cy.getDataCy("session-cloud-storage-credentials-modal")
// .find("#secret_access_key")
// .type("secret key");
// cy.getDataCy("session-cloud-storage-credentials-modal")
// .contains("Continue")
// .click();
// cy.wait("@testCloudStorage");
// cy.wait("@createSession");
// cy.url().should("match", /\/projects\/.*\/sessions\/.*\/start$/);
// });

it("launch session with data source requiring multiple credentials", () => {
fixtures.cloudStorage({
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/support/renkulab-fixtures/cloudStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function CloudStorage<T extends FixturesConstructor>(Parent: T) {
if (shouldNotBeCalled)
throw new Error("No call to post secrets expected");
const newSecrets = req.body;
expect(newSecrets.length).equal(content.length);
expect(newSecrets).to.have.length(content.length);
newSecrets.forEach((secret, index) => {
expect(secret.name).equal(content[index].name);
expect(secret.value).equal(content[index].value);
Expand Down

0 comments on commit e9f6262

Please sign in to comment.