Skip to content

Commit e655822

Browse files
Merge pull request #30 from forrestmurray-db/refactor/verification-skills
Refactor/verification skills
2 parents 25e0e95 + a1d301c commit e655822

3 files changed

Lines changed: 37 additions & 24 deletions

File tree

client/src/components/ui/select.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,15 @@ SelectLabel.displayName = SelectPrimitive.Label.displayName
111111
const SelectItem = React.forwardRef<
112112
React.ElementRef<typeof SelectPrimitive.Item>,
113113
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
114-
>(({ className, children, ...props }, ref) => (
114+
>(({ className, children, value, ...props }, ref) => (
115115
<SelectPrimitive.Item
116116
ref={ref}
117117
className={cn(
118118
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
119119
className
120120
)}
121+
value={value}
122+
data-value={value}
121123
{...props}
122124
>
123125
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">

client/tests/lib/actions/auth.ts

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,32 @@ async function selectWorkshopFromDropdown(page: Page, workshopId: string): Promi
2424
await page.waitForSelector('[role="listbox"]', { timeout: 3000 }).catch(() => {});
2525
await page.waitForTimeout(200);
2626

27-
// Try multiple selector patterns for Radix Select item with specific value
28-
// Radix uses data-radix-collection-item and the value is in data-value
29-
const selectors = [
30-
`[role="option"][data-value="${workshopId}"]`,
31-
`[data-radix-collection-item][data-value="${workshopId}"]`,
32-
`div[role="option"]:has-text("${workshopId.substring(0, 8)}")`, // partial ID match
33-
];
34-
35-
let clicked = false;
36-
for (const selector of selectors) {
37-
const workshopOption = page.locator(selector);
38-
if (await workshopOption.isVisible({ timeout: 500 }).catch(() => false)) {
39-
await workshopOption.click();
40-
clicked = true;
41-
break;
42-
}
43-
}
27+
// Radix Select stores the value in data-value attribute on the option element
28+
// Try the data-value selector first (most reliable)
29+
const dataValueSelector = `[role="option"][data-value="${workshopId}"]`;
30+
const workshopOption = page.locator(dataValueSelector);
4431

45-
// Fallback: click first option if nothing else worked
46-
if (!clicked) {
47-
const firstOption = page.locator('[role="option"]').first();
48-
if (await firstOption.isVisible({ timeout: 500 }).catch(() => false)) {
49-
await firstOption.click();
50-
}
32+
if (await workshopOption.isVisible({ timeout: 1000 }).catch(() => false)) {
33+
await workshopOption.click();
34+
} else {
35+
// If data-value selector didn't work, log and fail explicitly
36+
// Don't fall back to first option as this causes wrong workshop selection
37+
const availableOptions = await page.locator('[role="option"]').all();
38+
const optionValues = await Promise.all(
39+
availableOptions.map(async (opt) => {
40+
const value = await opt.getAttribute('data-value');
41+
const text = await opt.textContent();
42+
return `${value}: ${text}`;
43+
})
44+
);
45+
console.error(
46+
`[selectWorkshopFromDropdown] Could not find workshop ${workshopId}. ` +
47+
`Available options: ${optionValues.join(', ')}`
48+
);
49+
throw new Error(
50+
`Workshop ${workshopId} not found in dropdown. ` +
51+
`Available: ${optionValues.join(', ')}`
52+
);
5153
}
5254
}
5355
}

client/tests/lib/scenario-builder.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,15 @@ export class TestScenario {
431431

432432
const createdWorkshop = (await workshopResponse.json()) as Workshop;
433433
store.workshop.id = createdWorkshop.id;
434+
435+
// Update facilitator's workshop_id with the real workshop ID
436+
const facilitatorIndex = store.users.findIndex((u) => u.role === 'facilitator');
437+
if (facilitatorIndex !== -1) {
438+
store.users[facilitatorIndex] = {
439+
...store.users[facilitatorIndex],
440+
workshop_id: createdWorkshop.id,
441+
};
442+
}
434443
}
435444

436445
/**

0 commit comments

Comments
 (0)