Skip to content

Commit

Permalink
[MS] Small fixes + tests on org status
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-7 authored and NicoTuxx committed Aug 10, 2024
1 parent ba8be57 commit a943543
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions client/src/views/client-area/ClientAreaPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
:organization="currentOrganization"
@page-selected="switchPage"
@organization-selected="onOrganizationSelected"
:key="refresh"
/>
</ion-menu>

Expand Down
10 changes: 7 additions & 3 deletions client/src/views/client-area/ClientAreaSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ async function goToPageClicked(page: ClientAreaPages): Promise<void> {
onMounted(async () => {
if (isDefaultOrganization(props.organization)) {
status.value = null;
} else {
const response = await BmsAccessInstance.get().getOrganizationStatus(props.organization.bmsId);
if (!response.isError && response.data) {
status.value = response.data as OrganizationStatusResultData;
}
}
status.value = (await BmsAccessInstance.get().getOrganizationStatus(props.organization.bmsId)).data as OrganizationStatusResultData;
});

async function openOrganizationChoice(event: Event): Promise<void> {
Expand All @@ -276,9 +280,9 @@ async function openOrganizationChoice(event: Event): Promise<void> {

async function goToHome(): Promise<void> {
if (isDefaultOrganization(props.organization)) {
await navigateTo(Routes.Home);
await navigateTo(Routes.Home, { skipHandle: true });
} else {
await navigateTo(Routes.Home, { query: { bmsOrganizationId: props.organization.parsecId } });
await navigateTo(Routes.Home, { skipHandle: true, query: { bmsOrganizationId: props.organization.parsecId } });
}
}
</script>
Expand Down
28 changes: 28 additions & 0 deletions client/tests/pw/e2e/client_area_login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,31 @@ msTest('Open settings modal', async ({ clientArea }) => {
await expect(modal).toBeVisible();
await expect(modal.locator('.ms-modal-header__title')).toHaveText('Settings');
});

for (const frozen of [false, true]) {
msTest(`Check org state ${frozen ? 'frozen' : 'active'}`, async ({ home }) => {
await MockBms.mockLogin(home);
await MockBms.mockUserRoute(home);
await MockBms.mockListOrganizations(home);
await MockBms.mockOrganizationStats(home);
await MockBms.mockBillingDetails(home);
await MockBms.mockGetInvoices(home);
await MockBms.mockOrganizationStatus(home, { isFrozen: frozen });

const button = home.locator('.topbar-buttons').locator('#trigger-customer-area-button');
await button.click();
await fillIonInput(home.locator('.input-container').nth(0).locator('ion-input'), DEFAULT_USER_INFORMATION.email);
await fillIonInput(home.locator('.input-container').nth(1).locator('ion-input'), DEFAULT_USER_INFORMATION.password);
await home.locator('.saas-login-button__item').click();
const orgSwitchButton = home.locator('.sidebar-header').locator('.card-header-title');
await expect(orgSwitchButton).toHaveText('All organizations');
await orgSwitchButton.click();
const popover = home.locator('.popover-switch');
const orgs = popover.locator('.organization-list').getByRole('listitem');
await orgs.nth(0).click();
await expect(orgSwitchButton).toHaveText(DEFAULT_ORGANIZATION_INFORMATION.name);

const orgState = home.locator('.sidebar').locator('.sidebar-header').locator('.organization-card-state');
await expect(orgState).toHaveText(frozen ? 'State: Frozen' : 'State: Active');
});
}
6 changes: 3 additions & 3 deletions client/tests/pw/helpers/bms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DateTime } from 'luxon';

async function mockRoute(
page: Page,
url: string,
url: string | RegExp,
options: MockRouteOptions | undefined,
handler: (route: Route) => Promise<void>,
): Promise<void> {
Expand Down Expand Up @@ -239,7 +239,7 @@ async function mockOrganizationStats(page: Page, overload: MockOrganizationStats
await mockRoute(
page,
// eslint-disable-next-line max-len
`**/users/${DEFAULT_USER_INFORMATION.id}/clients/${DEFAULT_USER_INFORMATION.clientId}/organizations/${DEFAULT_ORGANIZATION_INFORMATION.bmsId}/stats`,
`*/**/users/${DEFAULT_USER_INFORMATION.id}/clients/${DEFAULT_USER_INFORMATION.clientId}/organizations/*/stats`,
options,
async (route) => {
await route.fulfill({
Expand Down Expand Up @@ -280,7 +280,7 @@ async function mockOrganizationStatus(
): Promise<void> {
await mockRoute(
page,
`**/users/${DEFAULT_USER_INFORMATION.id}/clients/${DEFAULT_USER_INFORMATION.clientId}/organizations/status`,
`**/users/${DEFAULT_USER_INFORMATION.id}/clients/${DEFAULT_USER_INFORMATION.clientId}/organizations/*/status`,
options,
async (route) => {
await route.fulfill({
Expand Down

0 comments on commit a943543

Please sign in to comment.