@@ -100,6 +100,44 @@ function render(
|
||||
/>,
|
||||
);
|
||||
}
|
||||
test.each([true, false])(
|
||||
'parameter shortcuts target only sections present in the current environment (%s)',
|
||||
(ready) => {
|
||||
const html = render('parameters', {
|
||||
ready,
|
||||
expiryReady: ready,
|
||||
urgentReviewsReady: ready,
|
||||
});
|
||||
const navigation = html.match(
|
||||
/<nav aria-label="Áreas da parametrização"[\s\S]*?<\/nav>/,
|
||||
)?.[0];
|
||||
expect(navigation).toBeDefined();
|
||||
const targets = [...navigation!.matchAll(/href="#([^"]+)"/g)].map(
|
||||
(match) => match[1],
|
||||
);
|
||||
expect(new Set(targets).size).toBe(targets.length);
|
||||
for (const id of targets) {
|
||||
expect(html.split(`id="${id}"`)).toHaveLength(2);
|
||||
expect(html).toMatch(new RegExp(`id="${id}" tabindex="-1"`));
|
||||
}
|
||||
expect(targets).toContain('company-details');
|
||||
expect(targets).toContain('approval-levels');
|
||||
expect(targets.includes('company-comparison')).toBe(ready);
|
||||
expect(targets.includes('company-users')).toBe(ready);
|
||||
expect(targets).not.toContain('company-geography');
|
||||
expect(targets).not.toContain('company-ai-plan');
|
||||
expect(targets).not.toContain('company-work-contexts');
|
||||
expect(navigation!.includes('/administracao/prazos-aprovacao')).toBe(
|
||||
ready,
|
||||
);
|
||||
expect(navigation!.includes('/administracao/revisao-urgencias')).toBe(
|
||||
ready,
|
||||
);
|
||||
expect(html).toContain('lg:scroll-mt-72');
|
||||
expect(html.indexOf('<h1')).toBeLessThan(html.indexOf('<nav'));
|
||||
},
|
||||
);
|
||||
|
||||
test.each([
|
||||
['department', { name: 'DEPARTMENT-PREP-QA' }, 'DEPARTMENT-PREP-QA'],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user