Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix(cli): problems with init on windows (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
akrajna authored Jul 29, 2020
1 parent 996a9fb commit b23cf38
Show file tree
Hide file tree
Showing 24 changed files with 367 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"baseUrl": "https://shopware-pwa.storefrontcloud.io/",
"baseUrl": "http://localhost:3000/",
"integrationFolder":"packages\\default-theme\\__e2e__\\integration",
"fixturesFolder":"packages\\default-theme\\__e2e__\\fixtures",
"pluginsFile":"packages\\default-theme\\__e2e__\\plugins",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"scripts": {
"format": "prettier --write **/*.{js,ts,json}",
"lint": "tslint --config tslint.json -p . --fix",
"clean-build": "rm -rf ./build",
"clean-build": "node ./scripts/clean-build.js",
"compile": "tsc -p .",
"copy-templates": "cp -a ./src/templates ./build/",
"copy-templates": "node ./scripts/copy-templates.js",
"build": "yarn format && yarn lint && yarn clean-build && yarn compile && yarn copy-templates",
"test": "jest",
"watch": "jest --watch",
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/scripts/clean-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const jetpack = require("fs-jetpack");

function run() {
jetpack.remove("./build");
}
run();
9 changes: 9 additions & 0 deletions packages/cli/scripts/copy-templates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const jetpack = require("fs-jetpack");
const path = require("path");

function run() {
const sourceDir = path.join("src", "templates");
const destinationDir = path.join("build", "templates");
jetpack.copy(sourceDir, destinationDir);
}
run();
14 changes: 7 additions & 7 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GluegunToolbox } from "gluegun";
import { STAGES } from "../stages";

module.exports = {
name: "init",
Expand All @@ -18,12 +19,6 @@ module.exports = {
print: { info, warning, success, spin },
} = toolbox;

const STAGES = {
STABLE: "latest stable (recommended)",
CANARY: "canary (current master branch)",
LOCAL: "local contibution (to contribute locally in shopware-pwa)",
};

const inputParameters = toolbox.inputParameters;
// when --ci parameter is provided, then we skip questions for default values
const isCIrun = inputParameters.ci;
Expand Down Expand Up @@ -97,6 +92,11 @@ module.exports = {
);
break;
case STAGES.LOCAL:
await run(
`yarn add -D ${coreDevPackages
.map((dep) => `${dep}@canary`)
.join(" ")}`
);
await run(`npx yalc add -D ${coreDevPackages.join(" ")}`);
await run(`yarn link ${coreDevPackages.join(" ")}`);
break;
Expand All @@ -110,7 +110,7 @@ module.exports = {
break;
}

await toolbox.updateNuxtPackageJson(stage === STAGES.CANARY);
await toolbox.updateNuxtPackageJson(stage);
await toolbox.updateNuxtConfigFile();
updateConfigSpinner.succeed();

Expand Down
18 changes: 10 additions & 8 deletions packages/cli/src/extensions/nuxt-extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GluegunToolbox } from "gluegun";
import { STAGES } from "../stages";
const path = require("path");

module.exports = (toolbox: GluegunToolbox) => {
const {
Expand Down Expand Up @@ -50,9 +52,9 @@ module.exports = (toolbox: GluegunToolbox) => {
* TODO: check generated files and add here ones which are not necessary
*/
toolbox.removeDefaultNuxtFiles = async () => {
toolbox.filesystem.remove("pages/index.vue");
toolbox.filesystem.remove("components/Logo.vue");
toolbox.filesystem.remove("layouts/default.vue");
toolbox.filesystem.remove(path.join("pages", "index.vue"));
toolbox.filesystem.remove(path.join("components", "Logo.vue"));
toolbox.filesystem.remove(path.join("layouts", "default.vue"));
};

/**
Expand All @@ -61,9 +63,9 @@ module.exports = (toolbox: GluegunToolbox) => {
* - uncomment packages which are already published
* - dynamically get new versions from template
*/
toolbox.updateNuxtPackageJson = async (canary = false) => {
toolbox.updateNuxtPackageJson = async (stage) => {
const nuxtThemePackage = toolbox.filesystem.read(
`${toolbox.defaultThemeLocation}/package.json`,
path.join(toolbox.defaultThemeLocation, "package.json"),
"json"
);

Expand All @@ -75,7 +77,7 @@ module.exports = (toolbox: GluegunToolbox) => {
config.scripts.build = "shopware-pwa build";

// update versions to canary
if (canary) {
if (stage === STAGES.CANARY) {
Object.keys(config.dependencies).forEach((dependencyName) => {
if (dependencyName.includes("@shopware-pwa")) {
config.dependencies[dependencyName] = "canary";
Expand Down Expand Up @@ -220,7 +222,7 @@ module.exports = (toolbox: GluegunToolbox) => {
toolbox.copyThemeFolder = async (folderName, destination) => {
const dest = destination ? destination : folderName;
await toolbox.filesystem.copyAsync(
`${toolbox.defaultThemeLocation}/${folderName}`,
path.join(toolbox.defaultThemeLocation, folderName),
dest,
{ overwrite: true }
);
Expand All @@ -229,7 +231,7 @@ module.exports = (toolbox: GluegunToolbox) => {
toolbox.watchThemeFolder = (folderName) => {
const fs = require("fs");
fs.watch(
`${toolbox.defaultThemeLocation}/${folderName}`,
path.join(toolbox.defaultThemeLocation, folderName),
{ recursive: true },
async () => {
toolbox.print.info(`Reloading [${folderName}] files...`);
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/stages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const STAGES = {
STABLE: "latest stable (recommended)",
CANARY: "canary (current master branch)",
LOCAL: "local contibution (to contribute locally in shopware-pwa)",
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe("Test Checkout for guest, different billing address, paid in advance, desktop", () => {
beforeEach(() => {
cy.viewport(1280, 800)
})
it("checks if place my order button works", () => {
cy.addtocart()
cy.wait(1000)
cy.personal_detail_step()
cy.shipping_step()
cy.payment_step()
cy.rewiev_guest_pay_inadvance()
cy.get("[data-cy=place-my-order]").click({ force: true })
cy.wait(2000)
cy.url().should("contain", Cypress.config().baseUrl + "order?orderId=")
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe("Payment step with different address for billing and pay in advance method", () => {
beforeEach(() => {
cy.viewport(1280, 800)
cy.addtocart()
cy.wait(1000)
cy.personal_detail_step()
cy.shipping_step()
cy.payment_step()
})
it("check if there are radio buttons for payment methods", () => {
cy.get('[type="radio"]').should("exist")
cy.get(".sf-radio__label").should("not.be.empty")
})
it("check if go back to shipping button exist", () => {
cy.get("button").contains("Go back", { matchCase: false })
})
it("check if go back to shipping button work", () => {
cy.get("button")
.contains("Go back", { matchCase: false })
.click({ force: true })
cy.url().should("eq", Cypress.config().baseUrl + "checkout?step=SHIPPING")
cy.get("[data-cy=continue-to-payment]").click({ force: true })
})
it("check if there is checkobox for use different address for billing", () => {
cy.get('[type="checkbox"]').should("exist")
cy.get(".sf-checkbox__label").should("not.be.empty")
})

it("requires filling in all the fields", () => {
cy.get('[type="checkbox"]').check({ force: true })
cy.get("[data-cy=review-order]").click({ force: true })

cy.get("[data-cy=form] > [error-message]")
.should("have.length", 8)
.each(($el, index, $list) => {
expect($el).to.contain("This field is required")
})
})
it.only("contiunue to rewiev order after filling in address for billing", () => {
cy.get('[type="checkbox"]').check({ force: true })
cy.get("[data-cy=first-name]").last().clear().type("Bill")
cy.get("[data-cy=last-name]").last().clear().type("Bing")
cy.get("[data-cy=street-name]").last().clear().type("Billable")
cy.get("[data-cy=apartment]").last().clear().type("12")
cy.get("[data-cy=city]").last().clear().type("BillCity")
cy.get("[data-cy=state]").last().clear().type("BillState")
cy.get("[data-cy=zipcode]").last().clear().type("1112SC")
cy.get("[data-cy=phone]").last().clear().type("987654321")
cy.get("[data-cy=country]").click()
cy.get("li").contains("Poland").click({ force: true })
cy.get('[type="radio"]').eq(2).check({ force: true })
cy.get("[data-cy=review-order]").click({ force: true })
cy.url().should("eq", Cypress.config().baseUrl + "checkout?step=REVIEW")
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
describe("Test Personal detail step", () => {
beforeEach(() => {
cy.viewport(1280, 800)
cy.addtocart()
cy.wait(1000)
cy.personal_detail_step()
})
it("check if go back to shop button exist", () => {
cy.wait(2000)
cy.get("button").contains("Go Back to shop", { matchCase: false })
})
it("check if go back to shop button work", () => {
cy.wait(2000)
cy.get("[data-cy=go-back-to-shop-button").click({ force: true })
cy.url().should("eq", Cypress.config().baseUrl)
})
it("requires first name, last name and email", () => {
cy.get("[data-cy=cart-icon] > .sf-icon-path").click({ force: true })
cy.get("[data-cy=goToCheckout-button").click({ force: true })
cy.wait(2000)
cy.get("button").contains("Continue to shipping").click({ force: true })
cy.get('[label="First name"] > .sf-input__error-message > div').should(
"contain",
"First name is required"
)
cy.get("[data-cy=first-name]").should("contain", "First name is required")
cy.get("[data-cy=last-name").should("contain", "last name is required")
cy.get("[data-cy=proper-email").should(
"contain",
"Proper email is required"
)
})
it("requires vailid email", () => {
cy.get(".sf-input__wrapper > [data-cy=first-name]").type("Joe")
cy.get(".sf-input__wrapper > [data-cy=last-name]").type("Example")
cy.get(".sf-input__wrapper > [data-cy=proper-email]").type("invalid")
cy.get("[data-cy=continue-to-shipping-button]").click({ force: true })
cy.get("[data-cy=proper-email").should(
"contain",
"Proper email is required"
)
})
it("continue to shipping after giving vaild first name, last name and email", () => {
cy.get(".sf-input__wrapper > [data-cy=first-name]").type("Joe")
cy.get(".sf-input__wrapper > [data-cy=last-name]").type("Example")
cy.get(".sf-input__wrapper > [data-cy=proper-email]")
.clear()
.type("joe@example.com")
cy.get("[data-cy=proper-email]").should(
"not.contain",
"Proper email is required"
)
cy.get("[data-cy=continue-to-shipping-button]").click({ force: true })
cy.url().should("contain", "step=SHIPPING")
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe("shipping step", () => {
beforeEach(() => {
cy.viewport(1280, 800)
cy.addtocart()
cy.wait(1000)
cy.personal_detail_step()
cy.shipping_step()
})
it("requires filling in all the fields", () => {
cy.get("[data-cy=continue-to-payment]").click({ force: true })

cy.get("[data-cy=form] > [error-message]")
.should("have.length", 8)
.each(($el, index, $list) => {
expect($el).to.contain("This field is required", { matchCase: false })
})

cy.get("[data-cy=country]").should("contain", "This field is required")
})
it("check if go back to personal details button exist", () => {
cy.get("button").contains("Go Back", { matchCase: false }).should("exist")
})
it("check if go back to personal details button work", () => {
cy.get("button")
.contains("Go Back", { matchCase: false })
.click({ force: true })
cy.url().should(
"eq",
Cypress.config().baseUrl + "checkout?step=PERSONAL_DETAILS"
)
cy.get("[data-cy=continue-to-shipping-button]").click({ force: true })
})
it("shows message: Shipping methods", () => {
cy.contains("Shipping methods", { matchCase: false })
})
it("check if there are radio buttons for shipping methods", () => {
cy.get('[type="radio"]').should("exist")
cy.get(".sf-radio__label").should("not.be.empty")
})
it("continue to payment after filing in shipping details", () => {
cy.get("[data-cy=first-name]").last().clear().type("Joe")
cy.get("[data-cy=last-name]").last().clear().type("Example")
cy.get("[data-cy=street-name]").last().clear().type("TestStreet")
cy.get("[data-cy=apartment]").last().clear().type("1")
cy.get("[data-cy=city]").last().clear().type("TestCity")
cy.get("[data-cy=state]").last().clear().type("TestState")
cy.get("[data-cy=zipcode]").last().clear().type("11-11a")
cy.get("[data-cy=phone]").last().clear().type("123456789")
cy.get('[type="radio"]').last().check({ force: true })
cy.get("[data-cy=country]").click()
cy.get("li").contains("Poland").click({ force: true })
cy.get("[data-cy=continue-to-payment]").click({ force: true })
cy.url().should("eq", Cypress.config().baseUrl + "checkout?step=PAYMENT")
})
})
50 changes: 50 additions & 0 deletions packages/default-theme/__e2e__/integration/checkout_summary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { isTaggedTemplateExpression } = require("typescript")

describe("Test Checkout functionality for guest user Desktop view", () => {
beforeEach(() => {
cy.viewport(1280, 800)
cy.addtocart()
cy.wait(1000)
cy.personal_detail_step()
cy.shipping_step()
cy.payment_step()
cy.rewiev_guest_pay_inadvance()
})
it("check if go back to payment button exist", () => {
cy.get("button")
.contains("Go back to Payment", { matchCase: false })
.should("exist")
})
it("check if go back to payment button works", () => {
cy.get("[data-cy=go-back-to-payment]").click({ force: true })
cy.url().should("eq", Cypress.config().baseUrl + "checkout?step=PAYMENT")
})
it("check if product image is visible", () => {
cy.get("[data-cy=product-image]").should("be.visible")
})
it.skip("check quantity and amount", () => {
cy.get("[data-cy=quantity]").should("contain", 1)
})
it("check if personal details are correct", () => {
cy.get("[data-cy=name]")
.should("contain", "Joe Example", { matchCase: false })
.and("contain", "joe@example.com", { matchCase: false })
})
it("check if shipping details are correct", () => {
cy.get("[data-cy=shipping]")
.should("contain", "TestStreet 1, 11-11a", { matchCase: false })
.and("contain", "TestCity", { matchCase: false })
.and("contain", "123456789", { matchCase: false })
})
it("check if billing address is correct", () => {
cy.get("[data-cy=billing]")
.should("contain", "Billable 12, 1112SC", { matchCase: false })
.and("contain", "BillCity", { matchCase: false })
.and("contain", "987654321", { matchCase: false })
})
it.only("check if place my order button exist", () => {
cy.get("button")
.contains("Place my order", { matchCase: false })
.should("exist")
})
})
Loading

1 comment on commit b23cf38

@vercel
Copy link

@vercel vercel bot commented on b23cf38 Jul 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.