Skip to content

Commit

Permalink
test: unskip previously skipped tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bapmrl committed Oct 30, 2023
1 parent cdb396d commit dd90c9e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 37 deletions.
19 changes: 7 additions & 12 deletions cypress/e2e/slices/00-create.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,24 @@ describe("Create Slices", () => {
cy.clearProject();
});

it.skip("A user can create and rename a slice", () => {
it("A user can create and rename a slice", () => {
cy.createSlice(lib, sliceId, sliceName);

sliceBuilder.addNewWidgetField("Title", "Key Text");
sliceBuilder.addNewWidgetField("Description", "Rich Text");

cy.contains("Save").click();

// remove widget
cy.get('[data-cy="slice-menu-button"]').first().click();
cy.contains("Delete field").click();
cy.get('[data-cy="builder-save-button"]').should("not.be.disabled");

// add a variation

cy.contains("button", "Add a new variation").click();

cy.getInputByLabel("Variation name*").type("foo");
cy.getInputByLabel("Variation ID*").clear();
cy.getInputByLabel("Variation ID*").type("bar");

cy.get("#variation-add").submit();

// remove widget
cy.get('[data-cy="slice-menu-button"]').first().click();
cy.contains("Delete field").click();
cy.get('[data-cy="builder-save-button"]').should("not.be.disabled");

cy.contains("button", "Simulate").should("have.attr", "disabled");
cy.contains("button", "Simulate").realHover();
cy.get("#simulator-button-tooltip").should("be.visible");
Expand Down Expand Up @@ -144,7 +139,7 @@ describe("Create Slices", () => {
});

// See: #791
it.skip("A user cannot rename a slice with a name starting with a number", () => {
it("A user cannot rename a slice with a name starting with a number", () => {
const sliceName = "SliceName";

cy.createSlice(lib, sliceId, sliceName);
Expand Down
18 changes: 10 additions & 8 deletions cypress/e2e/user-flows/scenario_custom_screenshots.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ describe("I am an existing SM user and I want to upload screenshots on variation
sliceBuilder.goTo(slice.library, slice.name);
});

it.skip("Upload and replace custom screenshots", () => {
it("Upload and replace custom screenshots", () => {
// Upload custom screenshot on default variation
sliceBuilder.imagePreview.should("not.exist");
sliceBuilder.openScreenshotModal();
let sliceCard = new SliceCard(slice.name);
sliceCard.imagePreview.should("not.exist");
sliceCard.openScreenshotModal();

screenshotModal
.verifyImageIsEmpty()
Expand All @@ -38,22 +39,23 @@ describe("I am an existing SM user and I want to upload screenshots on variation
.dragAndDropImage(defaultScreenshot)
.verifyImageIs(defaultScreenshot)
.close();
sliceBuilder.imagePreview.isSameImageAs(defaultScreenshot);
sliceCard.imagePreview.isSameImageAs(defaultScreenshot);

// Upload screenshot on variation from the Changes Page
const missingScreenshotVariation = "Missing screenshot";
sliceBuilder.addVariation(missingScreenshotVariation);

sliceBuilder.imagePreview.should("not.exist");
sliceCard = new SliceCard(slice.name, missingScreenshotVariation);
sliceCard.imagePreview.should("not.exist");
sliceBuilder.save();

menu.navigateTo("Slices");
const sliceCard = new SliceCard(slice.name);
sliceCard = new SliceCard(slice.name);
sliceCard.imagePreview.isSameImageAs(defaultScreenshot);

menu.navigateTo("Changes");
changesPage.screenshotsButton.should("be.visible");
sliceCard.content.should("include.text", "1/2 screenshots missing");
sliceCard.content.should("include.text", "Missing screenshot");
sliceCard.imagePreview.isSameImageAs(defaultScreenshot);

sliceCard.openScreenshotModal();
Expand All @@ -64,7 +66,7 @@ describe("I am an existing SM user and I want to upload screenshots on variation
.dragAndDropImage(variationScreenshot)
.verifyImageIs(variationScreenshot)
.close();
sliceCard.content.should("not.include.text", "screenshots missing");
sliceCard.content.should("not.include.text", "Missing screenshot");
sliceCard.imagePreview.isSameImageAs(defaultScreenshot);

changesPage.pushChanges().isUpToDate();
Expand Down
10 changes: 0 additions & 10 deletions cypress/pages/slices/sliceBuilder.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { BaseBuilder } from "../BaseBuilder";

class SliceBuilder extends BaseBuilder {
get imagePreview() {
return cy.get("[alt='Preview image']");
}

get imagePreviewSrc() {
this.imagePreview.then(($img) => {
return $img.attr("src");
});
}

get renameButton() {
return cy.get('[data-cy="edit-slice-name"]');
}
Expand Down
10 changes: 8 additions & 2 deletions cypress/pages/slices/sliceCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ export class SliceCard {
}

openScreenshotModal() {
cy.get(this.root).find('[aria-haspopup="menu"]').click();
cy.contains("Update screenshot").click();
cy.get(this.root).then(($root) => {
if ($root.find('[aria-haspopup="menu"]').length > 0) {
cy.wrap($root).find('[aria-haspopup="menu"]').click();
cy.find('[role="menu"]').contains("Update screenshot").click();
} else {
cy.wrap($root).realHover().contains("Update screenshot").click();
}
});
return this;
}
}
2 changes: 1 addition & 1 deletion cypress/pages/slices/slicesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SlicesList {
}

getSliceCard(sliceName) {
return cy.get(`[aria-label="${sliceName} slice card"]`);
return cy.get(`[aria-label^="${sliceName}"][aria-label$="slice card"]`);
}

get optionDopDownMenu() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const SharedSliceCard: FC<SharedSliceCardProps> = (props) => {
>
{src !== undefined ? (
<CardMedia
alt="Preview image"
overlay={
canUpdateScreenshot && !disableOverlay ? (
<Box alignItems="center" justifyContent="center">
Expand Down Expand Up @@ -156,9 +157,12 @@ export const SharedSliceCard: FC<SharedSliceCardProps> = (props) => {
) : action.type === "menu" ? (
<DropdownMenu modal>
<DropdownMenuTrigger disabled={disabled}>
<IconButton icon="moreVert" />
<IconButton data-cy="slice-action-icon" icon="moreVert" />
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuContent
align="end"
data-cy="slice-action-icon-dropdown"
>
{action.onRename ? (
<DropdownMenuItem
onSelect={action.onRename}
Expand Down
4 changes: 2 additions & 2 deletions packages/slice-machine/test/pages/slices.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("slices", () => {
mockRouter.setCurrentUrl("/slices");
});

test.skip("When user creates a slice it should send a tracking event", async (ctx) => {
test("When user creates a slice it should send a tracking event", async (ctx) => {
const adapter = createTestPlugin({
setup: ({ hook }) => {
hook("slice:create", () => void 0);
Expand Down Expand Up @@ -206,7 +206,7 @@ describe("slices", () => {
);
});

test.skip("if creation fails it sohuld not send the tracking event", async (ctx) => {
test("if creation fails it sohuld not send the tracking event", async (ctx) => {
const adapter = createTestPlugin({
setup: ({ hook }) => {
hook("slice:create", () => {
Expand Down

0 comments on commit dd90c9e

Please sign in to comment.