Skip to content

Commit c5a514d

Browse files
Zaimwa9khvn26
andauthored
fix(e2e): Incorrect project selected in RBAC E2E on staging (#5433)
Co-authored-by: Kim Gustyr <kim.gustyr@flagsmith.com>
1 parent 0031301 commit c5a514d

4 files changed

Lines changed: 21 additions & 14 deletions

File tree

api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ exclude_also = [
6363
]
6464

6565
[tool.coverage.run]
66-
omit = ["scripts/*", "manage.py"]
66+
omit = ["scripts/*", "manage.py", "e2etests/*"]
6767

6868
[tool.pytest.ini_options]
6969
addopts = [

frontend/common/utils/utils.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ const Utils = Object.assign({}, require('./base/_utils'), {
7878
total += variation
7979
? variation.percentage_allocation
8080
: typeof v.default_percentage_allocation === 'number'
81-
? v.default_percentage_allocation
82-
: (v as any).percentage_allocation
81+
? v.default_percentage_allocation
82+
: (v as any).percentage_allocation
8383
return null
8484
})
8585
return 100 - total
@@ -190,10 +190,10 @@ const Utils = Object.assign({}, require('./base/_utils'), {
190190
) {
191191
const findAppended = `${value}`.includes(':')
192192
? (conditions || []).find((v) => {
193-
const split = value.split(':')
194-
const targetKey = `:${split[split.length - 1]}`
195-
return v.value === operator + targetKey
196-
})
193+
const split = value.split(':')
194+
const targetKey = `:${split[split.length - 1]}`
195+
return v.value === operator + targetKey
196+
})
197197
: false
198198
if (findAppended) return findAppended
199199

@@ -678,6 +678,12 @@ const Utils = Object.assign({}, require('./base/_utils'), {
678678
return true
679679
}
680680
},
681+
682+
toKebabCase: (string: string) => string
683+
.replace(/([a-z])([A-Z])/g, "$1-$2")
684+
.replace(/[\s_]+/g, '-')
685+
.toLowerCase(),
686+
681687
validateRule(rule: SegmentCondition) {
682688
if (!rule) return false
683689
if (rule.delete) {

frontend/e2e/tests/roles-test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import {
1919
import { t } from 'testcafe'
2020

2121
export default async function () {
22+
const rolesProject = 'project-my-test-project-7-role'
2223
log('Login')
2324
await login(E2E_USER, PASSWORD)
24-
await click('#project-select-6')
25+
await click(byId(rolesProject))
2526
await createFeature(0, 'test_feature', false)
2627
log('Go to Roles')
2728
await click(byId('organisation-link'))
@@ -51,7 +52,7 @@ export default async function () {
5152
await t.eval(() => location.reload());
5253
await t.wait(2000);
5354
await login(E2E_NON_ADMIN_USER_WITH_A_ROLE, PASSWORD)
54-
await click('#project-select-0')
55+
await click(byId(rolesProject))
5556
log('User with permissions can Handle the Features')
5657
const flagName = 'test_feature'
5758
await deleteFeature(0, flagName)

frontend/web/components/ProjectManageWidget.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ const ProjectManageWidget: FC<SegmentsPageType> = ({
150150
<Link
151151
key={id}
152152
id={`project-select-${i}`}
153-
to={`/project/${id}/environment/${
154-
environments && environments[0]
155-
? `${environments[0].api_key}/features`
156-
: 'create'
157-
}`}
153+
data-test={`project-${Utils.toKebabCase(name)}`}
154+
to={`/project/${id}/environment/${environments && environments[0]
155+
? `${environments[0].api_key}/features`
156+
: 'create'
157+
}`}
158158
className='clickable col-md-6 col-xl-3'
159159
style={{ minWidth: '190px' }}
160160
>

0 commit comments

Comments
 (0)