Skip to content

Commit

Permalink
ci: run unit and memory tests separately (#4422)
Browse files Browse the repository at this point in the history
* ci: run unit and memory tests separately

* chore: fixed swatch mem test

* chore: fixed color slider memory test

* chore: fixed color area memory test

* chore: reverted swatch property definition

* chore: updated hue to set via styleMap

* chore: added stylemap to color slider

* chore: updated swatch style

* chore: reverted opacity checkboard style in color handle

* chore: ignored color packages from ci memory test

* chore: ignored color packages from ci memory test

* test: checkout memory tooling with concurrency of 2

---------

Co-authored-by: Rajdeep Chandra <rajdeepchandra@rajdeeps-mbp-2.macromedia.com>
Co-authored-by: Rajdeep Chandra <rajdeepchandra@Rajdeeps-MacBook-Pro-2.local>
  • Loading branch information
3 people authored May 10, 2024
1 parent db193e8 commit 841ac23
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 15 deletions.
16 changes: 14 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,24 @@ jobs:
steps:
- downstream
- run:
name: Run tests
command: yarn test:ci --config web-test-runner.config.ci-chromium.js --group unit --coverage
name: Run unit tests
command: yarn test:ci --config web-test-runner.config.ci-chromium.js --group no-memory-ci --coverage
- store_test_results:
path: /root/project/results/
- store_artifacts:
path: coverage

test-chromium-memory:
executor: node

steps:
- downstream
- run:
name: Run memory tests
command: yarn test:ci --config web-test-runner.config.ci-chromium.js --group memory-ci
- store_test_results:
path: /root/project/results/

test-firefox:
executor: node
parallelism: 5
Expand Down Expand Up @@ -306,6 +317,7 @@ workflows:
build:
jobs:
- test-chromium
- test-chromium-memory
- test-firefox
- test-webkit
- lint
Expand Down
15 changes: 9 additions & 6 deletions packages/color-area/src/ColorArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
SpectrumElement,
TemplateResult,
} from '@spectrum-web-components/base';
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
import {
ifDefined,
styleMap,
} from '@spectrum-web-components/base/src/directives.js';
import {
property,
query,
Expand Down Expand Up @@ -445,15 +448,15 @@ export class ColorArea extends SpectrumElement {
}
).format(this.y);

const style = {
background: `linear-gradient(to top, black 0%, hsla(${this.hue}, 100%, 0.01%, 0) 100%),linear-gradient(to right, white 0%, hsla(${this.hue}, 100%, 0.01%, 0) 100%), hsl(${this.hue}, 100%, 50%);`,
};

return html`
<div
@pointerdown=${this.handleAreaPointerdown}
class="gradient"
style="background:
linear-gradient(to top, black 0%, hsla(${this
.hue}, 100%, 0.01%, 0) 100%),
linear-gradient(to right, white 0%, hsla(${this
.hue}, 100%, 0.01%, 0) 100%), hsl(${this.hue}, 100%, 50%);"
style=${styleMap(style)}
>
<slot name="gradient"></slot>
</div>
Expand Down
17 changes: 13 additions & 4 deletions packages/color-slider/src/ColorSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import {
PropertyValues,
TemplateResult,
} from '@spectrum-web-components/base';
import { ifDefined } from '@spectrum-web-components/base/src/directives.js';
import {
ifDefined,
StyleInfo,
styleMap,
} from '@spectrum-web-components/base/src/directives.js';
import {
property,
query,
Expand Down Expand Up @@ -301,6 +305,13 @@ export class ColorSlider extends Focusable {
}%`;
}

private get getColorSliderStyle(): StyleInfo {
const orientation = this.vertical ? 'top' : 'right';
return {
background: `linear-gradient(to ${orientation}, var(--sp-color-slider-gradient, var(--sp-color-slider-gradient-fallback)))`,
};
}

protected override render(): TemplateResult {
return html`
<div
Expand All @@ -311,9 +322,7 @@ export class ColorSlider extends Focusable {
<div
class="gradient"
role="presentation"
style="background: linear-gradient(to ${this.vertical
? 'top'
: 'right'}, var(--sp-color-slider-gradient, var(--sp-color-slider-gradient-fallback)));"
style=${styleMap(this.getColorSliderStyle)}
>
<slot name="gradient"></slot>
</div>
Expand Down
11 changes: 9 additions & 2 deletions packages/swatch/src/Swatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
TemplateResult,
} from '@spectrum-web-components/base';
import { property } from '@spectrum-web-components/base/src/decorators.js';
import { when } from '@spectrum-web-components/base/src/directives.js';
import {
ifDefined,
when,
} from '@spectrum-web-components/base/src/directives.js';
import { Focusable } from '@spectrum-web-components/shared/src/focusable.js';
import opacityCheckerboardStyles from '@spectrum-web-components/opacity-checkerboard/src/opacity-checkerboard.css.js';
import '@spectrum-web-components/icons-ui/icons/sp-icon-dash75.js';
Expand Down Expand Up @@ -201,7 +204,11 @@ export class Swatch extends SizedMixin(Focusable, {
return html`
<div
class="opacity-checkerboard fill"
style="--spectrum-picked-color: ${this.color}"
style=${ifDefined(
this.color
? `--spectrum-picked-color: ${this.color}`
: undefined
)}
>
<slot name="image"></slot>
${when(this.disabled, this.renderDisabled)}
Expand Down
18 changes: 18 additions & 0 deletions web-test-runner.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { sendMousePlugin } from './test/plugins/send-mouse-plugin.js';
import {
chromium,
chromiumWithMemoryTooling,
chromiumWithMemoryToolingCI,
configuredVisualRegressionPlugin,
firefox,
packages,
Expand Down Expand Up @@ -144,9 +145,26 @@ export default {
files: ['{packages,tools}/**/*-memory.test.js'],
browsers: [chromiumWithMemoryTooling],
},
{
name: 'memory-ci',
files: [
'{packages,tools}/**/*-memory.test.js',
'!packages/color-area/test/*-memory.test.js',
'!packages/color-wheel/test/*-memory.test.js',
'!packages/color-slider/test/*-memory.test.js',
],
browsers: [chromiumWithMemoryToolingCI],
},
{
name: 'unit-ci',
},
{
name: 'no-memory-ci',
files: [
'{packages,tools}/**/*.test.js',
'!{packages,tools}/**/*-memory.test.js',
],
},
],
group: 'unit',
browsers: [firefox, chromiumWithMemoryTooling, webkit],
Expand Down
24 changes: 23 additions & 1 deletion web-test-runner.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import fg from 'fast-glob';

export const chromium = playwrightLauncher({
product: 'chromium',
concurrency: 1,
createBrowserContext: ({ browser }) =>
browser.newContext({
ignoreHTTPSErrors: true,
Expand Down Expand Up @@ -47,6 +46,29 @@ export const chromiumWithMemoryTooling = playwrightLauncher({
},
});

export const chromiumWithMemoryToolingCI = playwrightLauncher({
product: 'chromium',
concurrency: 2,
createBrowserContext: ({ browser }) =>
browser.newContext({
ignoreHTTPSErrors: true,
permissions: ['clipboard-read', 'clipboard-write'],
}),
launchOptions: {
headless: false,
args: [
'--js-flags=--expose-gc',
'--headless=new',
/**
* Cause `measureUserAgentSpecificMemory()` to GC immediately,
* instead of up to 20s later:
* https://web.dev/articles/monitor-total-page-memory-usage#local_testing
**/
'--enable-blink-features=ForceEagerMeasureMemory',
],
},
});

export const chromiumWithFlags = playwrightLauncher({
product: 'chromium',
launchOptions: {
Expand Down

0 comments on commit 841ac23

Please sign in to comment.