Files
threshold-ui/e2e-tests/desktop/tests/scope.spec.js
T
LaurenandZhihe Li 990e2d6b9d [Desktop][Bug fix]: Stop target sessions before unauthenticating user session (#2891)
* add stopAll invocation to ipc handler

* trigger modal on both signout btns

* refactor invalidateSession fn

* fix application controller tests

* fix failing tests settings-card/user

* add test to Acceptance | authentication

* migrate electron dialog.showMessageBoxSync to Hds

* rename channel and tracked prop, consolidate cancel fns

* combine modals, add willDestroy, refactor

* test signout and close sessions modal

* address feedback

* refactor window.electron in authentication-test

* address feedback

* refactor: 💡 Fix failing tests

---------

Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
2025-08-04 16:44:27 -04:00

100 lines
2.6 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { expect, test } from '../fixtures/baseTest.js';
import * as boundaryHttp from '../../helpers/boundary-http.js';
let orgA;
let projectA;
let targetA;
let orgB;
let projectB;
let targetB;
test.beforeEach(async ({ request, targetAddress, targetPort }) => {
// Group A resources
orgA = await boundaryHttp.createOrg(request);
projectA = await boundaryHttp.createProject(request, orgA.id);
targetA = await boundaryHttp.createTarget(request, {
scopeId: projectA.id,
type: 'tcp',
port: targetPort,
address: targetAddress,
});
// Group B resources
orgB = await boundaryHttp.createOrg(request);
projectB = await boundaryHttp.createProject(request, orgB.id);
targetB = await boundaryHttp.createTarget(request, {
scopeId: projectB.id,
type: 'tcp',
port: targetPort,
address: targetAddress,
});
});
test.afterEach(async ({ request }) => {
if (orgA) {
await boundaryHttp.deleteOrg(request, orgA.id);
}
if (orgB) {
await boundaryHttp.deleteOrg(request, orgB.id);
}
});
test.describe('Scope tests', () => {
test('Shows the filtered targets based on selected scope', async ({
authedPage,
}) => {
const headerNavLocator = authedPage.getByLabel('header-nav');
await expect(headerNavLocator).toBeVisible();
await expect(
headerNavLocator.locator('.hds-dropdown-toggle-button'),
).toHaveText('Global', { ignoreCase: true });
await expect(
authedPage.getByRole('link', { name: targetA.name }),
).toBeVisible();
await expect(
authedPage.getByRole('link', { name: targetB.name }),
).toBeVisible();
await headerNavLocator.click();
const orgAHeaderNavLink = authedPage.getByRole('link', {
name: orgA.name,
});
await orgAHeaderNavLink.click();
await expect(
headerNavLocator.locator('.hds-dropdown-toggle-button'),
).toHaveText(orgA.name);
await expect(
authedPage.getByRole('link', { name: targetA.name }),
).toBeVisible();
await expect(
authedPage.getByRole('link', { name: targetB.name }),
).toBeHidden();
const orgBHeaderNavLink = authedPage.getByRole('link', {
name: orgB.name,
});
await expect(orgBHeaderNavLink).toBeVisible();
await orgBHeaderNavLink.click();
await expect(
headerNavLocator.locator('.hds-dropdown-toggle-button'),
).toHaveText(orgB.name);
await expect(
authedPage.getByRole('link', { name: targetB.name }),
).toBeVisible();
await expect(
authedPage.getByRole('link', { name: targetA.name }),
).toBeHidden();
});
});