Skip to content

Commit 93b6f4f

Browse files
committed
fix(e2e): match typeless org cards in Cypress selectors
The onboarding "unified org" work made organizations typeless — the org adapter now returns an undefined `type` for them, so the card renders `data-e2e="organization-card"` instead of `-personal`/`-standard`. The shared `getPersonalOrgId` command (the smoke-suite cascade root) plus a few specs still keyed off the legacy `organization-card-personal` hook and timed out waiting for an element that no longer renders, failing E2E Smoke across PRs. Completes the migration the team already started in regression/organisations.cy.ts and support/e2e.ts:737: - getPersonalOrgId / smoke render test: identify the personal org by its stable `personal-org-…` resource name (via cy.contains on the id badge), independent of the removed type attribute. - createStandardOrg / auth regression: wait for any card variant using the prefix selector `[data-e2e^="organization-card"]`. Does not touch app code or dependency updates.
1 parent 9c801cc commit 93b6f4f

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

cypress/e2e/regression/auth.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ describe('Authentication — regression', () => {
2222
// After reload the session cookie is re-validated server-side.
2323
// The page must still render the authenticated view.
2424
cy.url().should('include', paths.account.organizations.root);
25-
cy.get('[data-e2e="organization-card-personal"]').should('be.visible');
25+
// Org cards are typeless for unified orgs — match any card variant.
26+
cy.get('[data-e2e^="organization-card"]').first().should('be.visible');
2627
});
2728

2829
it('should block unauthenticated access to protected routes', () => {

cypress/e2e/smoke/organisations.cy.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ describe('Load org list', () => {
4343

4444
it('should render a list of the users orgs and store personal org ID', () => {
4545
cy.visit(paths.account.organizations.root);
46-
cy.get('[data-e2e="organization-card-personal"]').should('be.visible');
47-
cy.get('[data-e2e="organization-card-standard"]').should('be.visible');
48-
49-
// Extract the personal org ID from the BadgeCopy component
50-
// Find the personal org card, then find the badge with the org ID
51-
cy.get('[data-e2e="organization-card-personal"]')
52-
.find('[data-e2e="organization-card-id-copy"]')
53-
.first()
46+
// Org cards render regardless of type (unified orgs are typeless), so match
47+
// any card variant with the prefix selector.
48+
cy.get('[data-e2e^="organization-card"]').first().should('be.visible');
49+
50+
// Extract the personal org ID from its BadgeCopy. The personal org is
51+
// identified by its stable `personal-org-…` resource name, not its type.
52+
cy.contains('[data-e2e="organization-card-id-copy"]', /personal-org-[a-z0-9]+/)
5453
.invoke('text')
5554
.then((orgId) => {
5655
const trimmedId = orgId.trim();

cypress/support/e2e.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,21 @@ Cypress.Commands.add('getPersonalOrgId', (): Cypress.Chainable<string> => {
240240
return cy.wrap(storedId, { log: false });
241241
}
242242

243-
// If not in env, fetch it from the page
243+
// If not in env, fetch it from the page.
244+
// Orgs are now typeless (unified orgs omit `type`), so the legacy
245+
// `organization-card-personal` hook is unreliable. Identify the personal org
246+
// by its stable resource name (`personal-org-…`) via its id badge instead.
244247
cy.visit(paths.account.organizations.root);
245248
return cy
246-
.get('[data-e2e="organization-card-personal"]', { timeout: 10000 })
247-
.should('be.visible')
248-
.find('[data-e2e="organization-card-id-copy"]')
249+
.contains('[data-e2e="organization-card-id-copy"]', /personal-org-[a-z0-9]+/, {
250+
timeout: 10000,
251+
})
249252
.should('be.visible')
250-
.first()
251253
.invoke('text')
252254
.then((orgId: string) => {
253255
const trimmedId = orgId.trim();
254-
if (!trimmedId) {
255-
throw new Error('Failed to extract personal org ID from page');
256+
if (!/^personal-org-[a-z0-9]+$/.test(trimmedId)) {
257+
throw new Error(`Failed to extract personal org ID from page (got: "${trimmedId}")`);
256258
}
257259
Cypress.env('personalOrgId', trimmedId);
258260
return trimmedId;
@@ -326,7 +328,9 @@ Cypress.Commands.add('logout', () => {
326328
*/
327329
Cypress.Commands.add('createStandardOrg', (displayName: string): Cypress.Chainable<string> => {
328330
cy.visit(paths.account.organizations.root);
329-
cy.get('[data-e2e="organization-card-personal"]', { timeout: 10_000 }).should('be.visible');
331+
// Wait for the org list to render. Cards are typeless for unified orgs, so
332+
// match any card variant with the prefix selector.
333+
cy.get('[data-e2e^="organization-card"]', { timeout: 10_000 }).first().should('be.visible');
330334
cy.get('[data-e2e="create-organization-button"]').should('be.visible').click();
331335

332336
cy.contains('Create organization', { timeout: 10_000 }).should('be.visible');

0 commit comments

Comments
 (0)