Skip to content

Conversation

filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Jun 9, 2025

Description

Fix GitLab selectors for MRs and issues. Additionally, inherits new GitLab dark mode styles for a stylish night look

MR Issue Repo
image image image

Related Issue(s)

Fixes NEXT-4008

@filiptronicek filiptronicek self-assigned this Jun 9, 2025
@kylos101
Copy link

kylos101 commented Jun 9, 2025

@filiptronicek build is failing

@filiptronicek
Copy link
Member Author

Verified locally that all tests are passing:

filip@Filips-MacBook-Pro browser-extension % bun run test
$ cd test && pnpm test

> [email protected] test /Users/filip/Documents/GitHub/browser-extension/test
> cp ../src/button/button-contributions.ts ./src/button-contributions-copy.ts && tsc && mocha dist/**/*.spec.js



  Platform match tests
    ✔ should detect the platform for https://gitlab.com/svenefftinge/browser-extension-test (1240ms)
    ✔ should detect the platform for https://gitlab.com/svenefftinge/browser-extension-test/-/tree/my-branch (744ms)
    ✔ should detect the platform for https://gitlab.com/filiptronicek/empty (657ms)
    ✔ should detect the platform for https://gitlab.com/svenefftinge/browser-extension-test/-/merge_requests/1 (1025ms)
    ✔ should detect the platform for https://gitlab.com/svenefftinge/browser-extension-test/-/issues/1 (653ms)
    ✔ should detect the platform for https://github.com/svenefftinge/browser-extension-test (739ms)
    ✔ should detect the platform for https://github.com/svenefftinge/browser-extension-test/tree/my-branch (589ms)
    ✔ should detect the platform for https://github.com/svenefftinge/browser-extension-test/commit/82d701a9ac26ea25da9b24c5b3722b7a89e43b16 (712ms)
    ✔ should detect the platform for https://github.com/svenefftinge/browser-extension-test/issues/1 (679ms)
    ✔ should detect the platform for https://github.com/svenefftinge/browser-extension-test/issues/1 (173ms)
    ✔ should detect the platform for https://github.com/svenefftinge/browser-extension-test/pull/2 (559ms)
    ✔ should detect the platform for https://github.com/svenefftinge/browser-extension-test/blob/my-branch/README.md (512ms)
    ✔ should detect the platform for https://bitbucket.gitpod-dev.com/users/svenefftinge/repos/browser-extension-test/browse (344ms)
    ✔ should detect the platform for https://bitbucket.gitpod-dev.com/users/svenefftinge/repos/browser-extension-test/browse?at=refs%2Fheads%2Fmy-branch (200ms)
    ✔ should detect the platform for https://bitbucket.org/efftinge/browser-extension-test/commits/ (1559ms)

  Query Selector Tests
    ✔ url (https://gitlab.com/svenefftinge/browser-extension-test) should only match 'gl-repo' (1160ms)
    ✔ url (https://gitlab.com/svenefftinge/browser-extension-test/-/tree/my-branch) should only match 'gl-repo' (779ms)
    ✔ url (https://gitlab.com/filiptronicek/empty) should only match 'gl-repo-empty' (592ms)
    ✔ url (https://gitlab.com/svenefftinge/browser-extension-test/-/merge_requests/1) should only match 'gl-merge-request' (960ms)
    ✔ url (https://gitlab.com/svenefftinge/browser-extension-test/-/issues/1) should only match 'gl-issue' (677ms)
    ✔ url (https://github.com/svenefftinge/browser-extension-test) should only match 'gh-repo' (370ms)
    ✔ url (https://github.com/svenefftinge/browser-extension-test/tree/my-branch) should only match 'gh-repo' (169ms)
    ✔ url (https://github.com/svenefftinge/browser-extension-test/commit/82d701a9ac26ea25da9b24c5b3722b7a89e43b16) should only match 'gh-commit' (240ms)
    ✔ url (https://github.com/svenefftinge/browser-extension-test/issues/1) should only match 'gh-issue' (251ms)
    ✔ url (https://github.com/svenefftinge/browser-extension-test/issues/1) should only match 'gh-issue-new' (166ms)
    ✔ url (https://github.com/svenefftinge/browser-extension-test/pull/2) should only match 'gh-pull' (119ms)
    ✔ url (https://github.com/svenefftinge/browser-extension-test/blob/my-branch/README.md) should only match 'gh-file' (158ms)
    ✔ url (https://bitbucket.gitpod-dev.com/users/svenefftinge/repos/browser-extension-test/browse) should only match 'bbs-repo' (317ms)
    ✔ url (https://bitbucket.gitpod-dev.com/users/svenefftinge/repos/browser-extension-test/browse?at=refs%2Fheads%2Fmy-branch) should only match 'bbs-repo' (166ms)
    ✔ url (https://bitbucket.org/efftinge/browser-extension-test/commits/) should only match 'bb-commits' (2095ms)


  30 passing (20s)

match: /\/issues\//,
selector:
"#content-body > div.issue-details.issuable-details.js-issue-details > div.detail-page-description.content-block.js-detail-page-description.gl-pt-3.gl-pb-0.gl-border-none > div:nth-child(1) > div > div.gl-flex.gl-items-start.gl-flex-col.md\\:gl-flex-row.gl-gap-3.gl-pt-3 > div",
selector: "xpath://*[@id='content-body']/div[2]/div/section/section/div[2]/div[1]/div[2]",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L252 applies to existing issues, not newly created issues.

Perhaps we can make a duplicate entry, but with a slightly different selector?

Ref: https://linear.app/gitpod/issue/NEXT-4008/browser-extension-open-button-missing-on-pull-request-page-for#comment-05536ac1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kylos101 in the end, I found a selector that works for both, utilizing their data-testid attributes on elements. Let's cross our fingers that GitLab keeps those stable 🤞

@corneliusludmann
Copy link
Contributor

Verified locally that all tests are passing:

Do you use a different Node version locally? In the Gitpod workspace and the CI build, we use Node 20.x and the test fails.

$ node --version
v20.17.0
$ cd test && pnpm test

> [email protected] test /workspace/browser-extension/test
> cp ../src/button/button-contributions.ts ./src/button-contributions-copy.ts && tsc && mocha dist/**/*.spec.js

src/button-contributions.spec.ts:13:13 - error TS2322: Type '"new"' is not assignable to type 'boolean | "shell" | undefined'.

13             headless: "new",
               ~~~~~~~~

src/button-contributions.spec.ts:68:13 - error TS2322: Type '"new"' is not assignable to type 'boolean | "shell" | undefined'.

68             headless: "new",
               ~~~~~~~~

src/button-contributions.spec.ts:79:32 - error TS2339: Property '$x' does not exist on type 'Page'.

79             return (await page.$x(selector.slice(6)))[0] || null;
                                  ~~


Found 3 errors in the same file, starting at: src/button-contributions.spec.ts:13

 ELIFECYCLE  Test failed. See above for more details.
 WARN   Local package.json exists, but node_modules missing, did you mean to install?

Copy link
Contributor

@corneliusludmann corneliusludmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised. ✔️

@filiptronicek
Copy link
Member Author

Do you use a different Node version locally? In the Gitpod workspace and the CI build, we use Node 20.x and the test fails.

I use Node 20. Will take a look why this might be happening, but will do so outside of this PR.

@filiptronicek filiptronicek merged commit 45c6f0d into main Jun 10, 2025
1 of 2 checks passed
@filiptronicek filiptronicek deleted the ft/fix-gitlab branch June 10, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants