Skip to content

Commit 656f694

Browse files
authored
ci: add new job to run test-rit targets and fix exposed issues in libraries (microsoft#35178)
1 parent e0dec6d commit 656f694

File tree

5 files changed

+104
-6
lines changed

5 files changed

+104
-6
lines changed

.github/workflows/pr.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,54 @@ jobs:
8181
git status --porcelain
8282
git diff-index --quiet HEAD -- || exit 1
8383
84+
react_integration_tests_collocated:
85+
if: ${{ github.repository_owner == 'microsoft' }}
86+
runs-on: macos-14-xlarge
87+
steps:
88+
- uses: actions/checkout@v4
89+
with:
90+
fetch-depth: 0
91+
92+
- name: Derive appropriate SHAs for base and head for `nx affected` commands
93+
uses: nrwl/nx-set-shas@826660b82addbef3abff5fa871492ebad618c9e1 # v4.3.3
94+
with:
95+
main-branch-name: 'master'
96+
97+
- uses: actions/setup-node@v4
98+
with:
99+
cache: 'yarn'
100+
node-version: '20'
101+
102+
- run: echo number of CPUs "$(getconf _NPROCESSORS_ONLN)"
103+
104+
- run: |
105+
yarn install --frozen-lockfile
106+
yarn rit --react 17 --install-deps
107+
yarn rit --react 19 --install-deps
108+
109+
- name: Verify Cypress installs from RIT temp workspaces (React 17 -> v13, React 19 -> v14)
110+
run: |
111+
"$GITHUB_WORKSPACE"/tmp/rit/react-17/node_modules/.bin/cypress verify
112+
"$GITHUB_WORKSPACE"/tmp/rit/react-19/node_modules/.bin/cypress verify
113+
114+
- name: React Versions Integration Tests (17,19) - E2E
115+
id: e2e
116+
run: |
117+
yarn nx affected -t test-rit--17--e2e,test-rit--19--e2e
118+
119+
- name: Upload Cypress screenshots if exist
120+
uses: actions/upload-artifact@v4
121+
if: always() && steps.e2e.outcome == 'failure'
122+
with:
123+
name: cypress-screenshots-react-test-rit
124+
path: |
125+
tmp/rit/**/cypress/screenshots/**/*.png
126+
retention-days: 1
127+
128+
- name: React Versions Integration Tests (17,19) - Test,Type-check
129+
run: |
130+
FLUENT_JEST_WORKER=2 yarn nx affected -t test-rit--17--test,test-rit--17--type-check,test-rit--19--test,test-rit--19--type-check
131+
84132
react_integration_tests:
85133
if: ${{ github.repository_owner == 'microsoft' }}
86134
runs-on: ubuntu-latest

nx.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@
9898
"dependsOn": ["build"],
9999
"cache": true
100100
},
101+
"test-rit--*--prepare": {
102+
"dependsOn": ["^build"]
103+
},
101104
"@nx/jest:jest": {
102105
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"],
103106
"cache": true,
@@ -151,7 +154,8 @@
151154
"react-theme-sass",
152155
"babel-preset-global-context",
153156
"eslint-plugin-react-components",
154-
"react-migration-v0-v9"
157+
"react-migration-v0-v9",
158+
"react-migration-v0-v9-stories"
155159
]
156160
}
157161
},

packages/charts/react-charts/stories/src/DeclarativeChart/DeclarativeChartDefault.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const cachedFetch = (url: string) => {
173173

174174
export const DeclarativeChartBasicExample = (): JSXElement => {
175175
const declarativeChartRef = React.useRef<IDeclarativeChart>(null);
176-
const lastKnownValidLegends = React.useRef<string[]>(undefined);
176+
const lastKnownValidLegends = React.useRef<string[] | undefined>(undefined);
177177
const { targetDocument: doc } = useFluent();
178178
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
179179
const loadedSchemas = React.useRef<{ key: string; schema: any }[]>([]);

packages/react-components/react-motion/library/src/factories/createPresenceComponent.cy.tsx

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,39 @@ import { createPresenceComponent } from './createPresenceComponent';
44
import { MotionBehaviourProvider } from '../contexts/MotionBehaviourContext';
55

66
describe('createPresenceComponent', () => {
7+
const noop = () => {
8+
return;
9+
};
10+
// Ensure reduced-motion is disabled for deterministic animation behavior
11+
beforeEach(() => {
12+
cy.window().then(win => {
13+
const orig = win.matchMedia;
14+
// Redefine matchMedia so that prefers-reduced-motion never matches
15+
Object.defineProperty(win, 'matchMedia', {
16+
configurable: true,
17+
value: (query: string) => {
18+
if (query.includes('prefers-reduced-motion')) {
19+
return {
20+
matches: false,
21+
media: query,
22+
onchange: null,
23+
addListener: noop, // deprecated API still sometimes read
24+
removeListener: noop,
25+
addEventListener: noop,
26+
removeEventListener: noop,
27+
dispatchEvent: () => false,
28+
};
29+
}
30+
return orig.call(win, query);
31+
},
32+
});
33+
});
34+
});
35+
736
it('should call onMotionCancel', () => {
837
const TestMotion = createPresenceComponent({
9-
enter: { keyframes: [{ opacity: 0 }, { opacity: 1 }], duration: 1000 },
10-
exit: { keyframes: [{ opacity: 1 }, { opacity: 0 }], duration: 1000 },
38+
enter: { keyframes: [{ opacity: 0 }, { opacity: 1 }], duration: 4000 },
39+
exit: { keyframes: [{ opacity: 1 }, { opacity: 0 }], duration: 4000 },
1140
});
1241

1342
const TestComponent = () => {
@@ -35,7 +64,23 @@ describe('createPresenceComponent', () => {
3564

3665
mount(<TestComponent />);
3766

38-
cy.get('#toggle').click().wait(100).click().get('#cancel').should('have.text', '1');
67+
// First toggle: start exit motion
68+
cy.get('#toggle').click();
69+
70+
// Give React effect a couple of frames to start the animation rather than an arbitrary ms wait
71+
cy.window().then(
72+
win =>
73+
new Cypress.Promise<void>(resolve => {
74+
requestAnimationFrame(() => {
75+
win.requestAnimationFrame(() => resolve());
76+
});
77+
}),
78+
);
79+
80+
// Second toggle: should cancel the in-flight exit animation and trigger onMotionCancel
81+
cy.get('#toggle').click();
82+
83+
cy.get('#cancel').should('have.text', '1');
3984
});
4085

4186
it('should disable motion with motion disable provider', () => {

scripts/cypress/src/base.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ export const baseConfig = defineConfig({
9797
},
9898
supportFile: path.join(projectSupportDir, './component.js'),
9999
indexHtmlFile: path.join(projectSupportDir, './component-index.html'),
100+
defaultCommandTimeout: 8000,
100101
},
101102
retries: {
102-
runMode: 2,
103+
runMode: 4,
103104
openMode: 0,
104105
},
105106
// Screenshots go under <pkg>/cypress/screenshots and can be useful to look at after failures in

0 commit comments

Comments
 (0)