Skip to content

Commit

Permalink
Merge pull request #530 from PrestaShopCorp/add-chromatic
Browse files Browse the repository at this point in the history
Add chromatic
  • Loading branch information
Quetzacoalt91 authored Jan 10, 2024
2 parents 404482d + b28644f commit e83b81d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 17 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# based on .github/workflows/chromatic.yml

# Workflow name
name: 'Chromatic'
# Event for the workflow
on:
pull_request:
types: [opened,edited,reopened,synchronize,labeled]
paths:
- '_dev/**'
push:
branches:
- master

env:
NODE_VERSION: 20

# List of jobs
jobs:
chromatic-deployment:
# Operating System
runs-on: ubuntu-latest
if: github.event_name == 'push' || (contains(github.event.pull_request.labels.*.name, 'waiting for UX') && github.event.pull_request.head.repo.full_name == 'PrestaShopCorp/ps_facebook')
# Job steps
steps:
# 👇 Version 2 of the action
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # 👈 Required to retrieve git history

- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
cache-dependency-path: '_dev/package-lock.json'

- name: Install dependencies
working-directory: ./_dev
run: npm install

# 👇 Adds Chromatic as a step in the workflow
- name: Publish to Chromatic
uses: chromaui/action@v10
# Chromatic GitHub Action options
with:
workingDir: ./_dev
token: ${{ secrets.GITHUB_TOKEN }}
# 👇 Chromatic projectToken
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
6 changes: 5 additions & 1 deletion _dev/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ export const parameters = {
value: '#000000'
},
],
}
},
chromatic: {
delay: 500,
diffThreshold: 0.15, // Test to see if we have less false positive
},
}

export const globalTypes = {
Expand Down
12 changes: 12 additions & 0 deletions _dev/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions _dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint": "eslint --no-fix -c .eslintrc.js src/",
"lint-fix": "eslint --fix -c .eslintrc.js src/",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
"build-storybook": "storybook build",
"chromatic": "chromatic --exit-zero-on-changes"
},
"dependencies": {
"@prestashopcorp/billing-cdc": "0.0.48",
Expand Down Expand Up @@ -44,6 +45,7 @@
"@vitejs/plugin-vue2": "^2.0.3",
"@vue/eslint-config-airbnb": "^5.3.0",
"@vue/eslint-config-typescript": "^12.0.0",
"chromatic": "^10.2.0",
"eslint": "^7.0.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prestashop": "^0.2.1",
Expand All @@ -63,5 +65,8 @@
"vite-plugin-vue2": "^2.0.3",
"vue-loader": "^15.10",
"vue-template-compiler": "^2.7.14"
}
},
"version": "",
"readme": "ERROR: No README data found!",
"_id": "dev@"
}
20 changes: 10 additions & 10 deletions _dev/stories/105-configuration-fb-connected.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const contextPsFacebook = {
facebookBusinessManager: {
name: 'La Fanchonette',
email: '[email protected]',
createdAt: Date.now(),
createdAt: '2024-01-10T14:29:09+0100',
id: '12345689',
},
pixel: {
name: 'La Fanchonette Test Pixel',
id: '1234567890',
lastActive: Date.now(),
lastActive: '2024-01-10T14:29:09+0100',
isActive: true,
},
page: {
Expand All @@ -25,7 +25,7 @@ const contextPsFacebook = {
},
ads: {
name: 'La Fanchonette',
createdAt: Date.now(),
createdAt: '2024-01-10T14:29:09+0100',
},
};

Expand All @@ -36,12 +36,12 @@ const contextPsFacebookOverflows = {
facebookBusinessManager: {
name: 'La Fanchonette qui s\'étend sur la longueur',
email: 'fanchonette.a.very.long.email.should.not.be.a.problem.even.if.its.too.long@ps.com',
createdAt: Date.now(),
createdAt: '2024-01-10T14:29:09+0100',
},
pixel: {
name: 'La Fanchonette qui s\'étend sur la longueur Test Pixel',
id: '123456789012345678901234567890',
lastActive: Date.now(),
lastActive: '2024-01-10T14:29:09+0100',
isActive: true,
},
page: {
Expand All @@ -51,7 +51,7 @@ const contextPsFacebookOverflows = {
},
ads: {
name: 'La Fanchonette qui s\'étend sur la longueur',
createdAt: Date.now(),
createdAt: '2024-01-10T14:29:09+0100',
},
};

Expand All @@ -62,13 +62,13 @@ const contextPsFacebookMissingPermissions = {
facebookBusinessManager: {
name: 'La Fanchonette',
email: '[email protected]',
createdAt: Date.now(),
createdAt: '2024-01-10T14:29:09+0100',
id: '12345689',
},
pixel: {
name: 'La Fanchonette Test Pixel',
id: '1234567890',
lastActive: Date.now(),
lastActive: '2024-01-10T14:29:09+0100',
isActive: true,
},
page: {
Expand All @@ -78,7 +78,7 @@ const contextPsFacebookMissingPermissions = {
},
ads: {
name: 'La Fanchonette',
createdAt: Date.now(),
createdAt: '2024-01-10T14:29:09+0100',
},
};

Expand All @@ -90,7 +90,7 @@ export default {
const Template = (args: any, {argTypes}: any) => ({
props: Object.keys(argTypes),
components: {FacebookConnected},
template: '<facebook-connected :contextPsFacebook="contextPsFacebook" :psFacebookAppId="psFacebookAppId" :externalBusinessId="externalBusinessId" @onEditClick="onEditClick" @onUninstallClick="onUninstallClick" @onPixelActivation="onPixelActivation" />',
template: '<facebook-connected :contextPsFacebook="contextPsFacebook" :psFacebookAppId="psFacebookAppId" :externalBusinessId="externalBusinessId" @onEditClick="onEditClick" @onPixelActivation="onPixelActivation" />',
});
export const Default:any = Template.bind({});
Default.args = {
Expand Down
4 changes: 1 addition & 3 deletions _dev/stories/110-configuration-completed-modal.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const Template = (args: any, { argTypes }: any) => ({
props: Object.keys(argTypes),
components: { ModalConfigurationCompleted },
template: `
<modal-configuration-completed
@onHide="onHide"
/>
<modal-configuration-completed />
`,
});
export const ConfigurationCompleted: any = Template.bind({});
Expand Down
2 changes: 1 addition & 1 deletion _dev/stories/800-debug.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
const Template = (args: any, {argTypes}: any) => ({
props: Object.keys(argTypes),
components: {DebugPage},
template: '<debug-page :locale="locale" />',
template: '<debug-page />',
});

export const Debug: any = Template.bind({});
Expand Down

0 comments on commit e83b81d

Please sign in to comment.