mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
created GitHub Actions Workflow Config
This commit is contained in:
parent
436e2ed8df
commit
75d45bd14c
22
.github/workflows/main.yml
vendored
Normal file
22
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
name: E2E on Chrome
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
install:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Cypress run
|
||||||
|
uses: cypress-io/github-action@v2
|
||||||
|
with:
|
||||||
|
browser: chrome
|
||||||
|
build: npm run build
|
||||||
|
start: npm run start
|
||||||
|
wait-on: 'http://localhost:3000'
|
||||||
|
env:
|
||||||
|
COMMERCE_PROVIDER: ${{ secrets.COMMERCE_PROVIDER }}
|
||||||
|
NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN: ${{ secrets.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN }}
|
||||||
|
NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN: ${{ secrets.NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN }}
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"semi": false,
|
"semi": true,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false
|
"useTabs": false
|
||||||
|
@ -1,18 +1,27 @@
|
|||||||
describe('Header', () => {
|
describe('Header', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cy.visit('/')
|
cy.visit('/');
|
||||||
})
|
});
|
||||||
|
|
||||||
it('links to the correct pages', () => {
|
it('links to the correct pages', () => {
|
||||||
cy.getBySel('logo').click()
|
cy.getBySel('logo').click();
|
||||||
cy.location('pathname').should('eq', '/')
|
cy.location('pathname').should('eq', '/');
|
||||||
|
|
||||||
cy.getBySel('nav-link-search').click()
|
cy.getBySel('nav-link-search').click();
|
||||||
cy.location('pathname').should('eq', '/search')
|
cy.location('pathname').should('eq', '/search');
|
||||||
|
|
||||||
cy.getBySel('nav-link-home-page').click({ multiple: true })
|
cy.getBySel('nav-link-home-page').click({ multiple: true });
|
||||||
cy.location('pathname').should('eq', '/search/featured')
|
cy.location('pathname').should('eq', '/search/featured');
|
||||||
})
|
});
|
||||||
|
|
||||||
it('the search bar returns the correct search results', () => {})
|
it.only('the search bar returns the correct search results', () => {
|
||||||
})
|
cy.getBySel('search-input').eq(0).type('Linux{Enter}');
|
||||||
|
|
||||||
|
cy.getBySel('product-tag')
|
||||||
|
.eq(2)
|
||||||
|
.within(() => {
|
||||||
|
cy.getBySel('product-name').should('contain', 'Linux Shirt');
|
||||||
|
cy.getBySel('product-price').should('contain', '$35.00 USD');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -1,29 +1,26 @@
|
|||||||
describe('Home Page', () => {
|
describe('Home Page', () => {
|
||||||
it('displays all 3 products on the home page', () => {
|
it('displays all 3 products on the home page', () => {
|
||||||
cy.visit('/')
|
cy.visit('/');
|
||||||
|
|
||||||
cy.getBySel('product-tag')
|
cy.getBySel('product-tag')
|
||||||
.eq(0)
|
.eq(0)
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.getBySel('product-name').should(
|
cy.getBySel('product-name').should('contain', 'Code Shirt');
|
||||||
'contain',
|
cy.getBySel('product-price').should('contain', '$25.00 USD');
|
||||||
'New Short Sleeve T-Shirt'
|
});
|
||||||
)
|
|
||||||
cy.getBySel('product-price').should('contain', '$25.00 USD')
|
|
||||||
})
|
|
||||||
|
|
||||||
cy.getBySel('product-tag')
|
cy.getBySel('product-tag')
|
||||||
.eq(1)
|
.eq(1)
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.getBySel('product-name').should('contain', 'Lightweight Jacket')
|
cy.getBySel('product-name').should('contain', 'Dev Sticker Pack');
|
||||||
cy.getBySel('product-price').should('contain', '$249.99 USD')
|
cy.getBySel('product-price').should('contain', '$30.00 USD');
|
||||||
})
|
});
|
||||||
|
|
||||||
cy.getBySel('product-tag')
|
cy.getBySel('product-tag')
|
||||||
.eq(2)
|
.eq(2)
|
||||||
.within(() => {
|
.within(() => {
|
||||||
cy.getBySel('product-name').should('contain', 'Shirt')
|
cy.getBySel('product-name').should('contain', 'Linux Shirt');
|
||||||
cy.getBySel('product-price').should('contain', '$25.00 USD')
|
cy.getBySel('product-price').should('contain', '$35.00 USD');
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
7
cypress/integration/shopping-cart.spec.js
Normal file
7
cypress/integration/shopping-cart.spec.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
describe('Shopping Cart', () => {
|
||||||
|
it('users can add products to cart', () => {
|
||||||
|
cy.visit('/');
|
||||||
|
cy.getBySel('product-tag').eq(0).click();
|
||||||
|
cy.get('[aria-label="Add to Cart"]').click();
|
||||||
|
});
|
||||||
|
});
|
@ -19,4 +19,4 @@
|
|||||||
module.exports = (on, config) => {
|
module.exports = (on, config) => {
|
||||||
// `on` is used to hook into various events Cypress emits
|
// `on` is used to hook into various events Cypress emits
|
||||||
// `config` is the resolved Cypress config
|
// `config` is the resolved Cypress config
|
||||||
}
|
};
|
||||||
|
@ -25,5 +25,5 @@
|
|||||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||||
|
|
||||||
Cypress.Commands.add('getBySel', (selector, ...args) => {
|
Cypress.Commands.add('getBySel', (selector, ...args) => {
|
||||||
return cy.get(`[data-test=${selector}]`, ...args)
|
return cy.get(`[data-test=${selector}]`, ...args);
|
||||||
})
|
});
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
|
|
||||||
// Import commands.js using ES2015 syntax:
|
// Import commands.js using ES2015 syntax:
|
||||||
import './commands'
|
import './commands';
|
||||||
|
|
||||||
// Alternatively you can use CommonJS syntax:
|
// Alternatively you can use CommonJS syntax:
|
||||||
// require('./commands')
|
// require('./commands')
|
||||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -10,6 +10,9 @@
|
|||||||
"site",
|
"site",
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"classnames": "^2.3.1"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cypress": "^9.5.4",
|
"cypress": "^9.5.4",
|
||||||
"husky": "^7.0.4",
|
"husky": "^7.0.4",
|
||||||
@ -4669,6 +4672,11 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/classnames": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
|
||||||
|
},
|
||||||
"node_modules/clean-stack": {
|
"node_modules/clean-stack": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
|
||||||
@ -18368,6 +18376,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"classnames": {
|
||||||
|
"version": "2.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz",
|
||||||
|
"integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA=="
|
||||||
|
},
|
||||||
"clean-stack": {
|
"clean-stack": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
|
||||||
|
@ -26,5 +26,8 @@
|
|||||||
"pre-commit": "turbo run lint"
|
"pre-commit": "turbo run lint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"packageManager": "yarn@1.22.17"
|
"packageManager": "yarn@1.22.17",
|
||||||
|
"dependencies": {
|
||||||
|
"classnames": "^2.3.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
"features": {
|
"features": {
|
||||||
"cart": true,
|
"cart": true,
|
||||||
"search": true,
|
"search": true,
|
||||||
"wishlist": false,
|
"wishlist": true,
|
||||||
"customerAuth": false,
|
"customerAuth": true,
|
||||||
"customCheckout": false
|
"customCheckout": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { FC, memo, useEffect } from 'react';
|
import { FC, memo, useEffect } from 'react';
|
||||||
import cn from 'clsx';
|
import cn from 'classnames';
|
||||||
import s from './Searchbar.module.css';
|
import s from './Searchbar.module.css';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ const Searchbar: FC<Props> = ({ className, id = 'search' }) => {
|
|||||||
placeholder="Search for products..."
|
placeholder="Search for products..."
|
||||||
defaultValue={router.query.q}
|
defaultValue={router.query.q}
|
||||||
onKeyUp={handleKeyUp}
|
onKeyUp={handleKeyUp}
|
||||||
|
data-test="search-input"
|
||||||
/>
|
/>
|
||||||
<div className={s.iconContainer}>
|
<div className={s.iconContainer}>
|
||||||
<svg className={s.icon} fill="currentColor" viewBox="0 0 20 20">
|
<svg className={s.icon} fill="currentColor" viewBox="0 0 20 20">
|
||||||
|
@ -58,7 +58,7 @@ export default function CustomerMenuContent() {
|
|||||||
<a
|
<a
|
||||||
className={cn(s.link, 'justify-between')}
|
className={cn(s.link, 'justify-between')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setTheme(theme === 'dark' ? 'light' : 'dark');
|
setTheme(theme === 'dark' ? 'light' : 'light');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
|
@ -59,6 +59,7 @@ const ProductSidebar: FC<ProductSidebarProps> = ({ product, className }) => {
|
|||||||
{process.env.COMMERCE_CART_ENABLED && (
|
{process.env.COMMERCE_CART_ENABLED && (
|
||||||
<Button
|
<Button
|
||||||
aria-label="Add to Cart"
|
aria-label="Add to Cart"
|
||||||
|
data-test="add-to-cart"
|
||||||
type="button"
|
type="button"
|
||||||
className={s.button}
|
className={s.button}
|
||||||
onClick={addToCart}
|
onClick={addToCart}
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
"@components/*": ["components/*"],
|
"@components/*": ["components/*"],
|
||||||
"@commerce": ["../packages/commerce/src"],
|
"@commerce": ["../packages/commerce/src"],
|
||||||
"@commerce/*": ["../packages/commerce/src/*"],
|
"@commerce/*": ["../packages/commerce/src/*"],
|
||||||
"@framework": ["../packages/local/src"],
|
"@framework": ["../packages/shopify/src"],
|
||||||
"@framework/*": ["../packages/local/src/*"]
|
"@framework/*": ["../packages/shopify/src/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user