Skip to content

Commit c5a1172

Browse files
committed
simplify logic in template / tweak E2E tests
change assertion to isDisplayed() simplify logic in template - rename displayHeaderButtons back to displayShareButton - displayShareButton is only for share button, not for settings button - remove CSS app-settings-available and put logic directly in template ng-if fix flaky test This test asserts that the settingsMenuLink is not present, and the appropriate test should be `isPresent()` not `isDisplayed()`
1 parent 2d40d0a commit c5a1172

File tree

6 files changed

+12
-24
lines changed

6 files changed

+12
-24
lines changed

src/Site/views/languageforge/container/languageforge.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<breadcrumbs id="top" class="breadcrumbs d-none d-md-block"></breadcrumbs>
8282
</div>
8383
<ul class="nav navbar-nav">
84-
<li class="nav-item" ng-if="$ctrl.isLexiconProject" id="settings-dropdown-button" uib-dropdown data-ng-class="{'app-settings-available': $ctrl.header.settings.length > 0 && $ctrl.currentUserIsProjectManager}">
84+
<li class="nav-item" ng-if="$ctrl.isLexiconProject && $ctrl.currentUserIsProjectManager" id="settings-dropdown-button" uib-dropdown>
8585
<a id="settingsBtn" class="btn btn-primary my-auto" uib-dropdown-toggle title="Settings" href="#">
8686
<i class="fa fa-cog iconPadding"></i><span>Settings</span>
8787
</a>
@@ -95,7 +95,7 @@
9595
{% endverbatim %}
9696
</div>
9797
</li>
98-
<li class='nav-item' ng-if="$ctrl.isLexiconProject">
98+
<li class='nav-item' ng-if="$ctrl.isLexiconProject && $ctrl.displayShareButton">
9999
<a id="shareBtn" class="btn btn-primary my-auto" title="Share" href="#"
100100
ng-click="$ctrl.openShareWithOthersModal()">
101101
<i class="fa fa-share-alt iconPadding"></i><span>Share</span>

src/Site/views/languageforge/theme/default/sass/_global.scss

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,6 @@
264264
}
265265
}
266266

267-
#settings-dropdown-button:not(.app-settings-available) {
268-
.dropdown-toggle {
269-
visibility: hidden;
270-
}
271-
}
272-
273-
#settings-dropdown-button.app-settings-available {
274-
.dropdown-toggle {
275-
visibility: visible;
276-
}
277-
}
278-
279267
#settingsBtn {
280268
margin: 12px;
281269
margin-right: 6px;
@@ -287,7 +275,7 @@
287275
font-size: 1rem;
288276
}
289277
}
290-
278+
291279
#settingsBtn::after {
292280
display:none;
293281
}

src/angular-app/bellows/core/navbar.controller.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ export class NavbarController implements angular.IController {
2121
project: Project;
2222
interfaceConfig: InterfaceConfig;
2323
currentUserIsProjectManager: boolean;
24-
displayHeaderButtons: boolean;
24+
displayShareButton: boolean;
2525
projectTypeNames: ProjectTypeNames;
2626
siteName: string;
2727
isLexiconProject: boolean = false;
2828

2929
static $inject = [
3030
'$scope',
3131
'$uibModal',
32-
'projectService',
32+
'projectService',
3333
'sessionService',
3434
'offlineCacheUtils',
3535
'applicationHeaderService'];
@@ -75,7 +75,7 @@ export class NavbarController implements angular.IController {
7575
this.currentUserIsProjectManager =
7676
(session.data.userProjectRole === ProjectRoles.MANAGER.key) ||
7777
(session.data.userProjectRole === ProjectRoles.TECH_SUPPORT.key);
78-
this.displayHeaderButtons =
78+
this.displayShareButton =
7979
(this.currentUserIsProjectManager || (this.project.allowSharing && this.session.data.userIsProjectMember));
8080
}
8181

@@ -84,9 +84,9 @@ export class NavbarController implements angular.IController {
8484
this.siteName = session.baseSite();
8585
});
8686
this.$scope.$on('$locationChangeStart', (event, next, current) => {
87-
if (current.includes('/lexicon') && !current.includes('/new-project') && this.displayHeaderButtons) {
87+
if (current.includes('/lexicon') && !current.includes('/new-project')) {
8888
this.isLexiconProject = true;
89-
}else{
89+
} else {
9090
this.isLexiconProject = false;
9191
}
9292
});

test/app/bellows/project-settings.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('Bellows E2E Project Settings app', () => {
1515
await loginPage.loginAsMember();
1616
await projectsPage.get();
1717
await projectsPage.clickOnProject(constants.testProjectName);
18-
expect<string>(await settingsPage.settingsMenuLink.getAttribute('class')).not.toContain('app-settings-available');
18+
expect<boolean>(await settingsPage.settingsMenuLink.isPresent()).toBe(false);
1919
});
2020

2121
it('System Admin can manage project', async () => {

test/app/languageforge/lexicon/settings/config-fields.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Lexicon E2E Configuration Fields', () => {
4040
});
4141

4242
it('can go to Configuration and select unified Fields tab', async () => {
43-
expect<any>(await configPage.settingsMenuLink.isDisplayed()).toBe(true);
43+
expect<any>(await configPage.settingsMenuLink.isPresent()).toBe(true);
4444
await configPage.get();
4545
expect<any>(await configPage.applyButton.isDisplayed()).toBe(true);
4646
expect<any>(await configPage.applyButton.isEnabled()).toBe(false);

test/app/languageforge/lexicon/settings/config-input-systems.e2e-spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ describe('Lexicon E2E Configuration Input Systems', () => {
1717
await loginPage.loginAsUser();
1818
await projectsPage.get();
1919
await projectsPage.clickOnProject(constants.testProjectName);
20-
expect<any>(await configPage.settingsMenuLink.getAttribute('class')).not.toContain('app-settings-available');
20+
expect<boolean>(await configPage.settingsMenuLink.isPresent()).toBe(false);
2121
});
2222

2323
it('setup: login as manager, select test project, goto configuration', async () => {
2424
await loginPage.loginAsManager();
2525
await projectsPage.get();
2626
await projectsPage.clickOnProject(constants.testProjectName);
27-
expect<any>(await configPage.settingsMenuLink.isDisplayed()).toBe(true);
27+
expect<any>(await configPage.settingsMenuLink.isPresent()).toBe(true);
2828
await configPage.get();
2929
expect<any>(await configPage.applyButton.isDisplayed()).toBe(true);
3030
expect<any>(await configPage.applyButton.isEnabled()).toBe(false);

0 commit comments

Comments
 (0)