Skip to content

Commit

Permalink
Deployment Issues #4
Browse files Browse the repository at this point in the history
  • Loading branch information
david emioma committed May 7, 2024
1 parent aa8c744 commit 058c83a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,27 +334,29 @@ const ProductForm = ({ data }: Props) => {
/>
</div>

<FormField
control={form.control}
name="description"
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>

<FormControl>
<Textarea
{...field}
disabled={creating || updating || deletingItem}
placeholder="Product Description..."
data-cy="product-description-input"
rows={10}
/>
</FormControl>

<FormMessage data-cy="product-description-input-err" />
</FormItem>
)}
/>
<div className="w-full max-w-2xl grid grid-cols-1 sm:grid-cols-2">
<FormField
control={form.control}
name="description"
render={({ field }) => (
<FormItem className="col-span-2">
<FormLabel>Description</FormLabel>

<FormControl>
<Textarea
{...field}
disabled={creating || updating || deletingItem}
placeholder="Product Description..."
data-cy="product-description-input"
rows={10}
/>
</FormControl>

<FormMessage data-cy="product-description-input-err" />
</FormItem>
)}
/>
</div>
</div>

<div className="pt-16 lg:pt-10" />
Expand Down
30 changes: 15 additions & 15 deletions cypress/e2e/product.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Product for store", () => {

cy.wait(15000);

cy.get('[data-cy="go-to-store"]').should("be.visible");
cy.get('[data-cy="go-to-store"]').should("exist");

cy.visit(
`${Cypress.env("public_url")}/dashboard/${Cypress.env(
Expand All @@ -24,19 +24,19 @@ describe("Product for store", () => {
});

it("Display fail for invalid form", () => {
cy.get('[data-cy="new-product-btn"]').should("be.visible").click();
cy.get('[data-cy="new-product-btn"]').should("exist").click();

cy.wait(10000);

cy.get('[data-cy="product-form"]').should("exist");

cy.get('[data-cy="product-create-btn"]').should("be.visible").click();
cy.get('[data-cy="product-create-btn"]').should("exist").click();

cy.get('[data-cy="product-name-input-err"]').should("be.visible");
cy.get('[data-cy="product-name-input-err"]').should("exist");

cy.get('[data-cy="product-category-input-err"]').should("be.visible");
cy.get('[data-cy="product-category-input-err"]').should("exist");

cy.get('[data-cy="product-description-input-err"]').should("be.visible");
cy.get('[data-cy="product-description-input-err"]').should("exist");
});

it("Create a new product", () => {
Expand All @@ -47,7 +47,7 @@ describe("Product for store", () => {
cy.get('[data-cy="product-form"]').should("exist");

cy.get('[data-cy="product-name-input"]')
.should("be.visible")
.should("exist")
.type("Test product");

//Product Description
Expand All @@ -57,32 +57,30 @@ describe("Product for store", () => {

//Category
cy.get('[data-cy="product-category-select-trigger"]')
.should("be.visible")
.should("exist")
.click();

//Wait for category to be loaded
cy.wait(10000);

cy.get('[data-cy^="product-category-select-0"]')
.should("be.visible")
.should("exist")
.click({ force: true });

//Wait for category to be selected
cy.wait(10000);

//Add product item button
cy.get('[data-cy="add-product-item"]').should("be.visible").click();
cy.get('[data-cy="add-product-item"]').should("exist").click();

cy.wait(10000);

//Product Item Form
cy.get('[data-cy="product-item-form-0"]')
.should("be.visible")
.should("exist")
.within(() => {
//Image Upload
cy.get('[data-cy="product-item-form-0-upload-parent"]').should(
"be.visible"
);
cy.get('[data-cy="product-item-form-0-upload-parent"]').should("exist");

cy.fixture("images/test1.png").then((fileContent) => {
cy.get('[data-cy="product-item-form-0-upload"]').attachFile({
Expand Down Expand Up @@ -180,8 +178,10 @@ describe("Product for store", () => {
});

it("Update an existing product", () => {
cy.wait(10000);

cy.get(`[data-cy="product-${PRODUCT_INDEX}-trigger"]`)
.should("be.visible")
.should("exist")
.click();

cy.wait(10000);
Expand Down

0 comments on commit 058c83a

Please sign in to comment.