Skip to content

Commit

Permalink
ci(pie-monorepo): DSW-000 optimise unit-tests job by removing duplica…
Browse files Browse the repository at this point in the history
…te build step (#2197)

* ci(pie-monorepo): DSW-000 optimise unit-tests job by removing duplicate build step

* remove unused script and add missing test:ci script

* revert

* add new tests

* add new tests

---------

Co-authored-by: Ben Siggery <[email protected]>
  • Loading branch information
siggerzz and Ben Siggery authored Feb 12, 2025
1 parent df8ddf7 commit 09e2d46
Show file tree
Hide file tree
Showing 29 changed files with 81 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-bobcats-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@justeattakeaway/generator-pie-component": minor
---

[Removed] - Unused `test` script
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ jobs:
with:
node-version: 20
os: ubuntu-latest
# Restore Packages from Cache
- name: Build Packages
uses: ./.github/actions/run-script
with:
script-name: "build"
# Run Unit Tests
- name: Unit Tests
uses: ./.github/actions/run-script
Expand Down
3 changes: 2 additions & 1 deletion apps/pie-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"build:testing": "BROWSER_TESTING=true storybook build --output-dir dist && cp -R ./static ./dist",
"lint:scripts": "run -T eslint .",
"lint:scripts:fix": "run -T eslint . --fix",
"test": "run -T vitest run test"
"test": "run -T vitest run test",
"test:ci": "yarn test"
},
"author": "Just Eat Takeaway.com - Design System Team",
"license": "Apache-2.0",
Expand Down
76 changes: 73 additions & 3 deletions apps/pie-storybook/test/utilities/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';
import { html, render, type TemplateResult } from 'lit';
import { createStory, createVariantStory } from '../../utilities/index';
import { type StoryOptions } from '../../types/StoryOptions';
import CUSTOM_BACKGROUNDS from '../../.storybook/backgrounds';

type ComponentProps = {
size: string;
Expand Down Expand Up @@ -86,10 +87,79 @@ describe('createVariantStory', () => {

const story = createVariantStory(template, propOptions, storyOpts);

// Check if the parameters include the background color
expect(story.parameters.backgrounds.default).toBe('background-subtle');

// Check if argTypes are applied
expect(story.argTypes).toEqual(storyOpts.argTypes);
});

it('should apply custom background color from CUSTOM_BACKGROUNDS', () => {
const propOptions = {
size: ['small'],
variant: ['primary'],
};

const story = createVariantStory(template, propOptions, { bgColor: 'background-subtle' });
const renderResult = story.render();

const container = document.createElement('div');
render(renderResult, container);

const templateContainer = container.querySelector('.template-container');
if (!templateContainer) {
throw new Error('Template container not found');
}
const computedStyle = window.getComputedStyle(templateContainer);

const backgroundColor = computedStyle.getPropertyValue('--background-color');
expect(backgroundColor).toBeTruthy();
expect(backgroundColor).not.toBe('#ffffff');

const matchingBackground = CUSTOM_BACKGROUNDS.values.find((bg) => bg.name === 'background-subtle');
expect(backgroundColor).toBe(matchingBackground?.value);
});

it('should fallback to default white background when invalid bgColor is provided', () => {
const propOptions = {
size: ['small'],
variant: ['primary'],
};

// @ts-expect-error - Testing invalid background color
const story = createVariantStory(template, propOptions, { bgColor: 'background-invalid' });
const renderResult = story.render();

const container = document.createElement('div');
render(renderResult, container);

const templateContainer = container.querySelector('.template-container');
if (!templateContainer) {
throw new Error('Template container not found');
}
const computedStyle = window.getComputedStyle(templateContainer);

// Should fallback to default white background
const backgroundColor = computedStyle.getPropertyValue('--background-color');
expect(backgroundColor).toBe('#ffffff');
});

it('should use default white background when bgColor is undefined', () => {
const propOptions = {
size: ['small'],
variant: ['primary'],
};

const story = createVariantStory(template, propOptions);
const renderResult = story.render();

const container = document.createElement('div');
render(renderResult, container);

const templateContainer = container.querySelector('.template-container');
if (!templateContainer) {
throw new Error('Template container not found');
}
const computedStyle = window.getComputedStyle(templateContainer);

const backgroundColor = computedStyle.getPropertyValue('--background-color');
expect(backgroundColor).toBe('#ffffff');
});
});
2 changes: 0 additions & 2 deletions packages/components/pie-assistive-text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-card/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-checkbox-group/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_CHECKBOX_GROUP} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:browsers-setup": "npx playwright-lit-setup",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-chip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-divider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-form-label/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-icon-button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_ICON_BUTTON} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-lottie-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"lint:scripts": "run -T eslint .",
"lint:scripts:fix": "yarn lint:scripts --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_LOTTIE_PLAYER} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-modal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-notification/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-radio-group/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_RADIO_GROUP} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-radio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_RADIO} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-spinner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-switch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-tag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-text-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers-setup": "npx playwright-lit-setup",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-textarea/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_TEXTAREA} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-thumbnail/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_THUMBNAIL} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-toast-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_TOAST_PROVIDER} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
2 changes: 0 additions & 2 deletions packages/components/pie-toast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_TOAST} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
"lint:style:fix": "yarn lint:style --fix",
"watch": "run -T vite build --watch",
"test": "echo \"Error: no test specified\" && exit 0",
"test:ci": "yarn test",
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
"test:browsers:ci": "yarn test:browsers",
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_<%= percyComponentName %>} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/tools/pie-icons-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"lint:scripts:fix": "run -T eslint . --fix",
"prepublishOnly": "yarn lint:scripts && yarn build",
"test": "run -T vitest run",
"test:ci": "yarn test",
"test:update": "run -T vitest -u run",
"test:watch": "run -T vitest"
},
Expand Down

0 comments on commit 09e2d46

Please sign in to comment.