2024-05-31 11:01:10 +05:30
|
|
|
/*
|
|
|
|
* Copyright 2024 Collate.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
import { expect, Page } from '@playwright/test';
|
|
|
|
import { Domain } from '../support/domain/Domain';
|
|
|
|
|
|
|
|
export const assignDomain = async (page: Page, domain: Domain['data']) => {
|
|
|
|
await page.getByTestId('add-domain').click();
|
2024-06-11 16:57:09 +05:30
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
2024-05-31 11:01:10 +05:30
|
|
|
await page
|
|
|
|
.getByTestId('selectable-list')
|
|
|
|
.getByTestId('searchbar')
|
|
|
|
.fill(domain.name);
|
|
|
|
await page.waitForResponse(
|
|
|
|
`/api/v1/search/query?q=*${encodeURIComponent(domain.name)}*`
|
|
|
|
);
|
|
|
|
await page.getByRole('listitem', { name: domain.displayName }).click();
|
|
|
|
|
|
|
|
await expect(page.getByTestId('domain-link')).toContainText(
|
|
|
|
domain.displayName
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const updateDomain = async (page: Page, domain: Domain['data']) => {
|
|
|
|
await page.getByTestId('add-domain').click();
|
2024-06-11 16:57:09 +05:30
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
2024-05-31 11:01:10 +05:30
|
|
|
await page.getByTestId('selectable-list').getByTestId('searchbar').clear();
|
|
|
|
await page
|
|
|
|
.getByTestId('selectable-list')
|
|
|
|
.getByTestId('searchbar')
|
|
|
|
.fill(domain.name);
|
|
|
|
await page.waitForResponse(
|
|
|
|
`/api/v1/search/query?q=*${encodeURIComponent(domain.name)}*`
|
|
|
|
);
|
|
|
|
await page.getByRole('listitem', { name: domain.displayName }).click();
|
|
|
|
|
|
|
|
await expect(page.getByTestId('domain-link')).toContainText(
|
|
|
|
domain.displayName
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const removeDomain = async (page: Page) => {
|
|
|
|
await page.getByTestId('add-domain').click();
|
2024-06-11 16:57:09 +05:30
|
|
|
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });
|
2024-05-31 11:01:10 +05:30
|
|
|
|
|
|
|
await expect(page.getByTestId('remove-owner').locator('path')).toBeVisible();
|
|
|
|
|
|
|
|
await page.getByTestId('remove-owner').locator('svg').click();
|
|
|
|
|
|
|
|
await expect(page.getByTestId('no-domain-text')).toContainText('No Domain');
|
|
|
|
};
|