Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #125

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: build-test

on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
env:
BUILD_PREFIX: true
IS_MAIN: ${{ github.ref == 'refs/heads/main' }}
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
SCREENER_API_KEY: ${{ secrets.SCREENER_API_KEY }}
steps:
- uses: actions/checkout@v2

- name: Build
uses: actions/setup-node@v2
with:
node-version: '14.x'

- name: Build site
env:
CI: false
run: |
ls
npm ci
npm run build

- name: Build storybook
env:
CI: false
run: |
ls
npm run build.storybook
6 changes: 5 additions & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ jobs:
with:
node-version: '14.x'

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Build site
env:
CI: false
run: |
ls
npm install
npm ci
npm run build

- name: Build storybook
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Inventory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Inventory = ({data}) => {
}
};
const isVisualFailure = isVisualUser();
const randomPrice = () => Math.round(Math.random() * 10000) / 100;

/* istanbul ignore next */
if (isPerformanceGlitchUser()) {
Expand Down Expand Up @@ -117,7 +118,7 @@ const Inventory = ({data}) => {
}
name={item.name}
desc={item.desc}
price={item.price}
price={isVisualFailure ? randomPrice() : item.price}
isTextAlignRight={isVisualFailure && i > 1 && i < 4}
missAlignButton={isVisualFailure && i === 5}
/>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/__tests__/Inventory.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ describe("Inventory", () => {
it("should render correctly for a visual user", () => {
const isVisualUserSpy = jest.spyOn(Credentials, "isVisualUser");
isVisualUserSpy.mockReturnValue(true);

const randomSpy = jest.spyOn(Math, "random");
randomSpy.mockReturnValue(0.5);

const wrapper = shallow(<Inventory.WrappedComponent data={InventoryData} />);

expect(wrapper).toMatchSnapshot();
Expand Down
12 changes: 6 additions & 6 deletions src/pages/__tests__/__snapshots__/Inventory.tests.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ exports[`Inventory should render correctly for a visual user 1`] = `
key="4"
missAlignButton={false}
name="Sauce Labs Backpack"
price={29.99}
price={50}
/>
<withRouter(InventoryListItem)
desc="A red light isn't the desired state in testing but it sure helps when riding your bike at night. Water-resistant with 3 lighting modes, 1 AAA battery included."
Expand All @@ -309,7 +309,7 @@ exports[`Inventory should render correctly for a visual user 1`] = `
key="0"
missAlignButton={false}
name="Sauce Labs Bike Light"
price={9.99}
price={50}
/>
<withRouter(InventoryListItem)
desc="Get your testing superhero on with the Sauce Labs bolt T-shirt. From American Apparel, 100% ringspun combed cotton, heather gray with red bolt."
Expand All @@ -319,7 +319,7 @@ exports[`Inventory should render correctly for a visual user 1`] = `
key="1"
missAlignButton={false}
name="Sauce Labs Bolt T-Shirt"
price={15.99}
price={50}
/>
<withRouter(InventoryListItem)
desc="It's not every day that you come across a midweight quarter-zip fleece jacket capable of handling everything from a relaxing day outdoors to a busy day at the office."
Expand All @@ -329,7 +329,7 @@ exports[`Inventory should render correctly for a visual user 1`] = `
key="5"
missAlignButton={false}
name="Sauce Labs Fleece Jacket"
price={49.99}
price={50}
/>
<withRouter(InventoryListItem)
desc="Rib snap infant onesie for the junior automation engineer in development. Reinforced 3-snap bottom closure, two-needle hemmed sleeved and bottom won't unravel."
Expand All @@ -339,7 +339,7 @@ exports[`Inventory should render correctly for a visual user 1`] = `
key="2"
missAlignButton={false}
name="Sauce Labs Onesie"
price={7.99}
price={50}
/>
<withRouter(InventoryListItem)
desc="This classic Sauce Labs t-shirt is perfect to wear when cozying up to your keyboard to automate a few tests. Super-soft and comfy ringspun combed cotton."
Expand All @@ -349,7 +349,7 @@ exports[`Inventory should render correctly for a visual user 1`] = `
key="3"
missAlignButton={true}
name="Test.allTheThings() T-Shirt (Red)"
price={15.99}
price={50}
/>
</div>
</div>
Expand Down
Loading