Skip to content

Commit

Permalink
tests: update project creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-cavazzi committed Nov 19, 2024
1 parent 7824e90 commit 96237fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ProjectVisibilityFormField<T extends FieldValues>({
<Label className="form-label" for="project-visibility">
Visibility
</Label>
<div>
<div data-cy="project-visibility-controller">
<Controller
aria-describedby="projectVisibilityHelp"
control={control}
Expand All @@ -45,7 +45,6 @@ export default function ProjectVisibilityFormField<T extends FieldValues>({
<Input
type="radio"
className="btn-check"
data-cy="project-visibility-public"
id="project-visibility-public"
value="public"
checked={field.value === "public"}
Expand All @@ -55,6 +54,7 @@ export default function ProjectVisibilityFormField<T extends FieldValues>({
/>
<Label
className={cx("btn", "btn-outline-primary", "mb-0")}
data-cy="project-visibility-public"
for="project-visibility-public"
>
<Globe className={cx("bi", "me-1")} />
Expand All @@ -63,7 +63,6 @@ export default function ProjectVisibilityFormField<T extends FieldValues>({
<Input
type="radio"
className="btn-check"
data-cy="project-visibility-private"
id="project-visibility-private"
value="private"
checked={field.value === "private"}
Expand All @@ -73,6 +72,7 @@ export default function ProjectVisibilityFormField<T extends FieldValues>({
/>
<Label
className={cx("btn", "btn-outline-primary", "mb-0")}
data-cy="project-visibility-private"
for="project-visibility-private"
>
<Lock className={cx("bi", "me-1")} />
Expand Down
7 changes: 4 additions & 3 deletions client/src/features/projectsV2/new/ProjectV2New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { NewProjectForm } from "./projectV2New.types";
export default function ProjectV2New() {
const user = useLegacySelector((state) => state.stateModel.user);
return (
<>
<div data-cy="create-new-project-page">
<h2>Create a new project</h2>
<p>
A Renku project groups together data, code, and compute resources for
Expand All @@ -55,7 +55,7 @@ export default function ProjectV2New() {
textPost="to create a new project."
/>
)}
</>
</div>
);
}

Expand Down Expand Up @@ -149,6 +149,7 @@ function ProjectV2CreationDetails() {
<div className="mb-3">
<button
className={cx("btn", "btn-link", "p-0", "text-decoration-none")}
data-cy="project-slug-toggle"
onClick={toggleCollapse}
type="button"
>
Expand Down Expand Up @@ -223,7 +224,7 @@ function ProjectV2CreationDetails() {
</div>
)}

<Button color="primary" type="submit">
<Button color="primary" data-cy="project-create-button" type="submit">
Create
</Button>
</FormGroup>
Expand Down
60 changes: 12 additions & 48 deletions tests/cypress/e2e/projectV2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,76 +30,40 @@ describe("Add new v2 project", () => {
});

it("create a new project", () => {
cy.contains("New Project").should("be.visible");
cy.contains("Create a new project").should("be.visible");
cy.getDataCy("project-name-input").clear().type(newProjectTitle);
cy.getDataCy("project-slug-input").should("have.value", slug);
cy.wait("@listNamespaceV2");
cy.findReactSelectOptions("project-namespace-input", "namespace-select")
.first()
.click(); // click on first option
cy.contains("Set visibility").click();
cy.contains("Add repositories").click();
cy.getDataCy("project-add-repository").click();
cy.getDataCy("project-repository-input-0")
.clear()
.type("https://domain.name/repo1.git");
cy.contains("button", "Review").click();
.click();
cy.contains("Visibility").click();
cy.contains("button", "Create").click();

cy.wait("@createProjectV2");
cy.location("pathname").should("eq", `/v2/projects/user1-uuid/${slug}`);
});

it("keeps namespace set after going back", () => {
cy.contains("New Project").should("be.visible");
cy.getDataCy("project-name-input").clear().type(newProjectTitle);
cy.getDataCy("project-slug-input").should("have.value", slug);
cy.wait("@listNamespaceV2");
cy.findReactSelectOptions("project-namespace-input", "namespace-select")
.first()
.click();
cy.contains("user1-uuid").should("exist");
cy.contains("Set visibility").click();
cy.get("button").contains("Back").click();
cy.contains("user1-uuid").should("exist");
});

it("prevents invalid input", () => {
cy.contains("button", "Set visibility").click();
cy.contains("Please provide a name").should("be.visible");
cy.contains("Name").should("be.visible");
cy.contains("Owner").should("be.visible");
cy.contains("Visibility").should("be.visible");
cy.contains("Description").should("be.visible");

cy.getDataCy("project-slug-toggle").click();
cy.getDataCy("project-name-input").clear().type(newProjectTitle);
cy.getDataCy("project-slug-input").clear().type(newProjectTitle);
cy.contains("button", "Set visibility").click();
cy.getDataCy("project-create-button").click();
cy.contains(
"Please provide a slug consisting of lowercase letters, numbers, and hyphens."
"You can customize the slug only with lowercase letters, numbers, and hyphens."
).should("be.visible");

cy.getDataCy("project-slug-input").clear().type(slug);
cy.wait("@listNamespaceV2");
cy.findReactSelectOptions("project-namespace-input", "namespace-select")
.first()
.click();
cy.contains("Set visibility").click();

cy.contains("Define access").should("be.visible");
cy.getDataCy("project-visibility-public").click();
cy.contains("button", "Add repositories").click();

cy.contains("button", "Review").click();
cy.contains("button", "Back").click();
cy.getDataCy("project-add-repository").click();
cy.contains("button", "Review").click();
cy.contains("Please provide a valid URL or remove the repository").should(
"be.visible"
);
cy.getDataCy("project-repository-input-0")
.clear()
.type("https://domain.name/repo1.git");

cy.contains("button", "Review").click();
cy.contains(newProjectTitle).should("be.visible");
cy.contains(slug).should("be.visible");
cy.contains("public").should("be.visible");
cy.contains("https://domain.name/repo1.git").should("be.visible");

cy.contains("button", "Create").click();
cy.wait("@createProjectV2");
Expand Down

0 comments on commit 96237fc

Please sign in to comment.