aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/tutorials/test-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/components/tutorials/test-utils.ts')
-rw-r--r--server/sonar-web/src/main/js/components/tutorials/test-utils.ts26
1 files changed, 24 insertions, 2 deletions
diff --git a/server/sonar-web/src/main/js/components/tutorials/test-utils.ts b/server/sonar-web/src/main/js/components/tutorials/test-utils.ts
index c2f727cd252..2aff448489b 100644
--- a/server/sonar-web/src/main/js/components/tutorials/test-utils.ts
+++ b/server/sonar-web/src/main/js/components/tutorials/test-utils.ts
@@ -27,8 +27,30 @@ const CI_TRANSLATE_MAP: Partial<Record<TutorialModes, string>> = {
[TutorialModes.GitLabCI]: 'gitlab_ci',
};
-export function getCopyToClipboardValue(i = 0, name = 'copy_to_clipboard') {
- return screen.getAllByRole('button', { name })[i].getAttribute('data-clipboard-text');
+interface GetCopyToClipboardValueArgs {
+ i?: number;
+ inlineSnippet?: boolean;
+ name?: string;
+}
+
+export function getCopyToClipboardValue({
+ i = 0,
+ inlineSnippet = false,
+ name = 'copy_to_clipboard',
+}: GetCopyToClipboardValueArgs = {}) {
+ const button = screen.getAllByRole('button', { name })[i];
+
+ return inlineSnippet
+ ? button.previousSibling?.firstChild?.textContent
+ : button.nextSibling?.firstChild?.textContent;
+}
+
+export function getCopyToClipboardHostURLValue({
+ i = 0,
+ name = 'copy_to_clipboard',
+}: Omit<GetCopyToClipboardValueArgs, 'inlineSnippet'> = {}) {
+ return screen.getAllByRole('button', { name })[i].nextSibling?.nextSibling?.firstChild
+ ?.textContent;
}
export function getCommonNodes(ci: TutorialModes) {