fix(ui): correct “modified” indicator state across collection, folder, request, and presets/auth tabs (#3386) (#8027)

* fix: 3296 Folder-level No Auth inheritance is ignored; requests still use Collection Auth
This commit is contained in:
sharan-bruno
2026-06-08 16:57:18 +05:30
committed by GitHub
parent b9d8bdf2ec
commit 2d4d4e4037
41 changed files with 1182 additions and 356 deletions

View File

@@ -0,0 +1,113 @@
import { test, expect } from '../../../playwright';
import { buildCommonLocators, closeAllCollections, createCollection, createFolder, selectAuthMode } from '../../utils/page';
import { AUTH_MODE_LABELS } from '../../utils/constants';
test.describe('Effective auth mode resolution', () => {
test.afterEach(async ({ page }) => {
await closeAllCollections(page);
});
test('Nested folder with Inherit should pick up its immediate parent folder, not a grandparent', async ({ page, createTmpDir }) => {
const collectionName = 'effective-auth-mode-collection';
const locators = buildCommonLocators(page);
await test.step('Create a collection', async () => {
await createCollection(page, collectionName, await createTmpDir());
});
await test.step('Create folder-1 inside the collection and set auth type for folder-1 as Bearer Token', async () => {
await createFolder(page, 'folder-1', collectionName, true);
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BEARER);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Create folder-2 inside folder-1 and set auth type for folder-2 as Basic Auth', async () => {
await createFolder(page, 'folder-2', 'folder-1', false);
await locators.sidebar.folder('folder-2').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BASIC);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Create folder-3 inside folder-2 and set auth type for folder-3 as Inherit', async () => {
await createFolder(page, 'folder-3', 'folder-2', false);
await locators.sidebar.folder('folder-3').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.INHERIT);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Verify folder-3 should inherit auth from folder-2', async () => {
await expect(page.getByText('Auth inherited from folder-2:')).toBeVisible();
await expect(locators.auth.inheritedMode()).toHaveText(AUTH_MODE_LABELS.BASIC);
});
});
test('Child folder with Inherit should pick up parent folder set to No Auth (not fall through to collection)', async ({ page, createTmpDir }) => {
const collectionName = 'no-auth-inherit-collection';
const locators = buildCommonLocators(page);
await test.step('Create a collection', async () => {
await createCollection(page, collectionName, await createTmpDir());
});
await test.step('Set auth type for the collection as Basic Auth', async () => {
await locators.paneTabs.collectionSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BASIC);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Create folder-1 inside the collection and set auth type for folder-1 as No Auth', async () => {
await createFolder(page, 'folder-1', collectionName, true);
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.NONE);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Create folder-2 inside folder-1 and set auth type for folder-2 as Inherit', async () => {
await createFolder(page, 'folder-2', 'folder-1', false);
await locators.sidebar.folder('folder-2').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.INHERIT);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Verify folder-2 should inherit No Auth from folder-1 (not fall through to the collection)', async () => {
await expect(page.getByText('Auth inherited from folder-1:')).toBeVisible();
await expect(locators.auth.inheritedMode()).toHaveText(AUTH_MODE_LABELS.NONE);
});
});
test('Auth dropdown shows No Auth as the selected option after picking it', async ({ page, createTmpDir }) => {
const collectionName = 'no-auth-dropdown-collection';
const locators = buildCommonLocators(page);
await test.step('Create a collection', async () => {
await createCollection(page, collectionName, await createTmpDir());
});
await test.step('Create folder-1 inside the collection and set auth type for folder-1 as No Auth', async () => {
await createFolder(page, 'folder-1', collectionName, true);
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.NONE);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Verify the auth mode selector shows No Auth as the current mode', async () => {
await expect(locators.auth.modeSelector()).toContainText(AUTH_MODE_LABELS.NONE);
});
await test.step('Reopen the dropdown and verify No Auth is highlighted as the selected option', async () => {
await page.locator('.auth-mode-label').first().click();
// Bruno marks the selected dropdown item with the `dropdown-item-active` class.
const noAuthItem = locators.auth.dropdownItem('none');
await expect(noAuthItem).toBeVisible();
await expect(noAuthItem).toHaveClass(/dropdown-item-active/);
await expect(noAuthItem).toContainText(AUTH_MODE_LABELS.NONE);
});
});
});

View File

@@ -0,0 +1,95 @@
import { test, expect } from '../../../playwright';
import {
buildCommonLocators,
closeAllCollections,
createCollection,
createFolder,
createRequest,
openRequest,
saveRequest,
selectAuthMode,
selectRequestPaneTab,
selectResponsePaneTab,
sendRequest,
typeIntoField
} from '../../utils/page';
import { AUTH_MODE_LABELS } from '../../utils/constants';
test.afterEach(async ({ page }) => {
await closeAllCollections(page);
});
test('Request inherits No Auth from the folder — collection Bearer Token is overridden', async ({ page, createTmpDir }) => {
const collectionName = 'folder-no-auth-inheritance';
const locators = buildCommonLocators(page);
await test.step('Create a collection', async () => {
await createCollection(page, collectionName, await createTmpDir());
});
await test.step('Set auth type for the collection as Bearer Token', async () => {
await locators.paneTabs.collectionSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BEARER);
await typeIntoField(page, 'Token', 'your_secret_token');
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Create folder-1 inside the collection and set auth type for folder-1 as No Auth', async () => {
await createFolder(page, 'folder-1', collectionName, true);
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.NONE);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Create an HTTP request inside folder-1 and set auth type for the request as Inherit', async () => {
const requestName = 'http-request-1';
await createRequest(page, requestName, 'folder-1', {
inFolder: true,
requestType: 'http',
method: 'GET',
url: 'https://testbench-sanity.usebruno.com/api/auth/bearer/protected'
});
await openRequest(page, collectionName, requestName);
await selectRequestPaneTab(page, 'Auth');
await selectAuthMode(page, AUTH_MODE_LABELS.INHERIT);
await saveRequest(page);
});
await test.step('Send the request and open the Timeline tab', async () => {
await sendRequest(page);
await selectResponsePaneTab(page, 'Timeline');
});
await test.step('Verify the response status code is 401 Unauthorized', async () => {
await expect(locators.response.statusCode()).toContainText('401');
});
await test.step('Open the latest timeline entry and verify no Authorization header was sent', async () => {
const timelineItem = locators.timeline.lastItem();
await locators.timeline.itemHeader(timelineItem).click();
await expect(timelineItem).toContainText('No Headers found');
await locators.timeline.clearButton().click();
});
await test.step('Change folder-1 auth type to Bearer Token with the expected token', async () => {
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BEARER);
await typeIntoField(page, 'Token', 'your_secret_token');
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Send the request again and verify the response status code is 200', async () => {
await openRequest(page, collectionName, 'http-request-1');
await sendRequest(page);
await selectResponsePaneTab(page, 'Timeline');
await expect(locators.response.statusCode()).toContainText('200');
});
await test.step('Open the latest timeline entry and verify the Bearer token was sent', async () => {
const timelineItem = locators.timeline.lastItem();
await locators.timeline.itemHeader(timelineItem).click();
await expect(timelineItem).toContainText('Bearer your_secret_token');
});
});

View File

@@ -0,0 +1,147 @@
import { test, expect } from '../../../playwright';
import {
buildCommonLocators,
closeAllCollections,
createCollection,
createFolder,
createRequest,
openRequest,
saveRequest,
selectAuthMode,
selectRequestPaneTab
} from '../../utils/page';
import { AUTH_MODE_LABELS } from '../../utils/constants';
test.describe('Modified indicator for auth tab', () => {
test.afterEach(async ({ page }) => {
await closeAllCollections(page);
});
test('Folder Auth tab indicator dot reflects effective auth (shows on inherit, hides on No Auth)', async ({ page, createTmpDir }) => {
const collectionName = 'modified-indicator-collection';
const locators = buildCommonLocators(page);
await test.step('Create a collection', async () => {
await createCollection(page, collectionName, await createTmpDir());
});
await test.step('Set auth type for the collection as Bearer Token', async () => {
await locators.paneTabs.collectionSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BEARER);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Verify the collection auth mode shows Bearer Token', async () => {
await expect(locators.auth.modeSelector()).toContainText(AUTH_MODE_LABELS.BEARER);
});
await test.step('Create folder-1 inside the collection and set auth type for folder-1 as Inherit', async () => {
await createFolder(page, 'folder-1', collectionName, true);
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.INHERIT);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Verify folder-1 inherits Bearer Token from the collection', async () => {
await expect(page.getByText('Auth inherited from Collection:')).toBeVisible();
await expect(locators.auth.inheritedMode()).toHaveText(AUTH_MODE_LABELS.BEARER);
});
await test.step('Verify the Auth tab shows the status dot for folder-1 (inheriting Bearer Token)', async () => {
await expect(
locators.paneTabs.folderSettingsTab('auth').getByTestId('status-dot-auth')
).toBeVisible();
});
await test.step('Change folder-1 auth type to No Auth', async () => {
await selectAuthMode(page, AUTH_MODE_LABELS.NONE);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Verify the Auth tab does NOT show the status dot for folder-1 (No Auth)', async () => {
await expect(
locators.paneTabs.folderSettingsTab('auth').getByTestId('status-dot-auth')
).toBeHidden();
});
});
const requestProtocolCases = [
{ protocol: 'HTTP', requestType: 'http' as const, requestName: 'http-request-1', url: 'https://example.com/api' },
{ protocol: 'gRPC', requestType: 'grpc' as const, requestName: 'grpc-request-1', url: 'grpc://localhost:50051' },
{ protocol: 'WebSocket', requestType: 'ws' as const, requestName: 'ws-request-1', url: 'ws://localhost:8080' },
{ protocol: 'GraphQL', requestType: 'graphql' as const, requestName: 'graphql-request-1', url: 'https://example.com/graphql' }
];
for (const { protocol, requestType, requestName, url } of requestProtocolCases) {
test(`${protocol} request inheriting auth from its folder shows the modified indicator dot`, async ({ page, createTmpDir }) => {
const collectionName = `${protocol.toLowerCase()}-inherit-indicator-collection`;
const locators = buildCommonLocators(page);
await test.step('Create a collection', async () => {
await createCollection(page, collectionName, await createTmpDir());
});
await test.step('Set auth type for the collection as Bearer Token', async () => {
await locators.paneTabs.collectionSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BEARER);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step('Create folder-1 inside the collection and set auth type for folder-1 as Basic Auth', async () => {
await createFolder(page, 'folder-1', collectionName, true);
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.BASIC);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step(`Create a ${protocol} request inside folder-1 and set auth type for the request as Inherit`, async () => {
await createRequest(page, requestName, 'folder-1', { inFolder: true, requestType, url });
await openRequest(page, collectionName, requestName);
await selectRequestPaneTab(page, 'Auth');
await selectAuthMode(page, AUTH_MODE_LABELS.INHERIT);
await saveRequest(page);
});
await test.step(`Verify the ${protocol} request Auth tab shows the status dot (inheriting Basic Auth from folder-1)`, async () => {
await expect(
locators.paneTabs.responsiveTab('auth').getByTestId('status-dot-auth')
).toBeVisible();
});
await test.step(`Change the ${protocol} request auth type to No Auth and verify the dot disappears`, async () => {
await selectAuthMode(page, AUTH_MODE_LABELS.NONE);
await saveRequest(page);
await expect(
locators.paneTabs.responsiveTab('auth').getByTestId('status-dot-auth')
).toBeHidden();
});
await test.step(`Change the ${protocol} request auth type to Basic Auth and verify the dot appears`, async () => {
await selectAuthMode(page, AUTH_MODE_LABELS.BASIC);
await saveRequest(page);
await expect(
locators.paneTabs.responsiveTab('auth').getByTestId('status-dot-auth')
).toBeVisible();
});
await test.step('Change folder-1 auth type to No Auth', async () => {
await locators.sidebar.folder('folder-1').dblclick();
await locators.paneTabs.folderSettingsTab('auth').click();
await selectAuthMode(page, AUTH_MODE_LABELS.NONE);
await page.getByRole('button', { name: 'Save' }).click();
});
await test.step(`Set the ${protocol} request auth back to Inherit and verify the dot is hidden (folder is No Auth)`, async () => {
await openRequest(page, collectionName, requestName);
await selectRequestPaneTab(page, 'Auth');
await selectAuthMode(page, AUTH_MODE_LABELS.INHERIT);
await saveRequest(page);
await expect(
locators.paneTabs.responsiveTab('auth').getByTestId('status-dot-auth')
).toBeHidden();
});
});
}
});