Skip to content

Commit 09e2d46

Browse files
siggerzzBen Siggery
andauthored
ci(pie-monorepo): DSW-000 optimise unit-tests job by removing duplicate 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]>
1 parent df8ddf7 commit 09e2d46

File tree

29 files changed

+81
-57
lines changed

29 files changed

+81
-57
lines changed

.changeset/moody-bobcats-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@justeattakeaway/generator-pie-component": minor
3+
---
4+
5+
[Removed] - Unused `test` script

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ jobs:
166166
with:
167167
node-version: 20
168168
os: ubuntu-latest
169-
# Restore Packages from Cache
170-
- name: Build Packages
171-
uses: ./.github/actions/run-script
172-
with:
173-
script-name: "build"
174169
# Run Unit Tests
175170
- name: Unit Tests
176171
uses: ./.github/actions/run-script

apps/pie-storybook/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"build:testing": "BROWSER_TESTING=true storybook build --output-dir dist && cp -R ./static ./dist",
1111
"lint:scripts": "run -T eslint .",
1212
"lint:scripts:fix": "run -T eslint . --fix",
13-
"test": "run -T vitest run test"
13+
"test": "run -T vitest run test",
14+
"test:ci": "yarn test"
1415
},
1516
"author": "Just Eat Takeaway.com - Design System Team",
1617
"license": "Apache-2.0",

apps/pie-storybook/test/utilities/index.test.ts

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';
22
import { html, render, type TemplateResult } from 'lit';
33
import { createStory, createVariantStory } from '../../utilities/index';
44
import { type StoryOptions } from '../../types/StoryOptions';
5+
import CUSTOM_BACKGROUNDS from '../../.storybook/backgrounds';
56

67
type ComponentProps = {
78
size: string;
@@ -86,10 +87,79 @@ describe('createVariantStory', () => {
8687

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

89-
// Check if the parameters include the background color
90-
expect(story.parameters.backgrounds.default).toBe('background-subtle');
91-
9290
// Check if argTypes are applied
9391
expect(story.argTypes).toEqual(storyOpts.argTypes);
9492
});
93+
94+
it('should apply custom background color from CUSTOM_BACKGROUNDS', () => {
95+
const propOptions = {
96+
size: ['small'],
97+
variant: ['primary'],
98+
};
99+
100+
const story = createVariantStory(template, propOptions, { bgColor: 'background-subtle' });
101+
const renderResult = story.render();
102+
103+
const container = document.createElement('div');
104+
render(renderResult, container);
105+
106+
const templateContainer = container.querySelector('.template-container');
107+
if (!templateContainer) {
108+
throw new Error('Template container not found');
109+
}
110+
const computedStyle = window.getComputedStyle(templateContainer);
111+
112+
const backgroundColor = computedStyle.getPropertyValue('--background-color');
113+
expect(backgroundColor).toBeTruthy();
114+
expect(backgroundColor).not.toBe('#ffffff');
115+
116+
const matchingBackground = CUSTOM_BACKGROUNDS.values.find((bg) => bg.name === 'background-subtle');
117+
expect(backgroundColor).toBe(matchingBackground?.value);
118+
});
119+
120+
it('should fallback to default white background when invalid bgColor is provided', () => {
121+
const propOptions = {
122+
size: ['small'],
123+
variant: ['primary'],
124+
};
125+
126+
// @ts-expect-error - Testing invalid background color
127+
const story = createVariantStory(template, propOptions, { bgColor: 'background-invalid' });
128+
const renderResult = story.render();
129+
130+
const container = document.createElement('div');
131+
render(renderResult, container);
132+
133+
const templateContainer = container.querySelector('.template-container');
134+
if (!templateContainer) {
135+
throw new Error('Template container not found');
136+
}
137+
const computedStyle = window.getComputedStyle(templateContainer);
138+
139+
// Should fallback to default white background
140+
const backgroundColor = computedStyle.getPropertyValue('--background-color');
141+
expect(backgroundColor).toBe('#ffffff');
142+
});
143+
144+
it('should use default white background when bgColor is undefined', () => {
145+
const propOptions = {
146+
size: ['small'],
147+
variant: ['primary'],
148+
};
149+
150+
const story = createVariantStory(template, propOptions);
151+
const renderResult = story.render();
152+
153+
const container = document.createElement('div');
154+
render(renderResult, container);
155+
156+
const templateContainer = container.querySelector('.template-container');
157+
if (!templateContainer) {
158+
throw new Error('Template container not found');
159+
}
160+
const computedStyle = window.getComputedStyle(templateContainer);
161+
162+
const backgroundColor = computedStyle.getPropertyValue('--background-color');
163+
expect(backgroundColor).toBe('#ffffff');
164+
});
95165
});

packages/components/pie-assistive-text/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
2525
"lint:style:fix": "yarn lint:style --fix",
2626
"watch": "run -T vite build --watch",
27-
"test": "echo \"Error: no test specified\" && exit 0",
28-
"test:ci": "yarn test",
2927
"test:browsers-setup": "npx playwright-lit-setup",
3028
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
3129
"test:browsers:ci": "yarn test:browsers",

packages/components/pie-button/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
2525
"lint:style:fix": "yarn lint:style --fix",
2626
"watch": "run -T vite build --watch",
27-
"test": "echo \"Error: no test specified\" && exit 0",
28-
"test:ci": "yarn test",
2927
"test:browsers-setup": "npx playwright-lit-setup",
3028
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
3129
"test:browsers:ci": "yarn test:browsers",

packages/components/pie-card/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
2525
"lint:style:fix": "yarn lint:style --fix",
2626
"watch": "run -T vite build --watch",
27-
"test": "echo \"Error: no test specified\" && exit 0",
28-
"test:ci": "yarn test",
2927
"test:browsers-setup": "npx playwright-lit-setup",
3028
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
3129
"test:browsers:ci": "yarn test:browsers",

packages/components/pie-checkbox-group/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
2525
"lint:style:fix": "yarn lint:style --fix",
2626
"watch": "run -T vite build --watch",
27-
"test": "echo \"Error: no test specified\" && exit 0",
28-
"test:ci": "yarn test",
2927
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
3028
"test:browsers:ci": "yarn test:browsers",
3129
"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",

packages/components/pie-checkbox/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
2525
"lint:style:fix": "yarn lint:style --fix",
2626
"watch": "run -T vite build --watch",
27-
"test": "echo \"Error: no test specified\" && exit 0",
28-
"test:ci": "yarn test",
2927
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
3028
"test:browsers:ci": "yarn test:browsers",
3129
"test:browsers-setup": "npx playwright-lit-setup",

packages/components/pie-chip/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
2525
"lint:style:fix": "yarn lint:style --fix",
2626
"watch": "run -T vite build --watch",
27-
"test": "echo \"Error: no test specified\" && exit 0",
28-
"test:ci": "yarn test",
2927
"test:browsers-setup": "npx playwright-lit-setup",
3028
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
3129
"test:browsers:ci": "yarn test:browsers",

0 commit comments

Comments
 (0)