mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.5 KiB
45 lines
1.5 KiB
5 months ago
|
import { expect } from '@playwright/test';
|
||
|
import { SettingsPage } from '.';
|
||
|
import BasePage from '../../Base';
|
||
|
|
||
|
export class SourcePage extends BasePage {
|
||
|
private readonly settings: SettingsPage;
|
||
|
|
||
|
constructor(settings: SettingsPage) {
|
||
|
super(settings.rootPage);
|
||
|
this.settings = settings;
|
||
|
}
|
||
|
|
||
|
get() {
|
||
|
return this.rootPage.getByTestId('nc-settings-datasources');
|
||
|
}
|
||
|
|
||
|
async openEditWindow({ sourceName }: { sourceName: string }) {
|
||
|
await this.get().locator('.ds-table-row', { hasText: sourceName }).click();
|
||
|
await this.get().getByTestId('nc-connection-tab').click();
|
||
|
}
|
||
|
|
||
|
async updateSchemaReadOnly({ sourceName, readOnly }: { sourceName: string; readOnly: boolean }) {
|
||
|
await this.openEditWindow({ sourceName });
|
||
|
const switchBtn = this.get().getByTestId('nc-allow-meta-write');
|
||
|
if (switchBtn.getAttribute('checked') !== readOnly.toString()) {
|
||
|
await switchBtn.click();
|
||
|
}
|
||
|
await this.saveConnection();
|
||
|
}
|
||
|
|
||
|
async updateDataReadOnly({ sourceName, readOnly = true }: { sourceName: string; readOnly?: boolean }) {
|
||
|
await this.openEditWindow({ sourceName });
|
||
|
const switchBtn = this.get().getByTestId('nc-allow-data-write');
|
||
|
if (switchBtn.getAttribute('checked') !== readOnly.toString()) {
|
||
|
await switchBtn.click();
|
||
|
}
|
||
|
await this.saveConnection();
|
||
|
}
|
||
|
|
||
|
async saveConnection() {
|
||
|
await this.get().locator('.nc-extdb-btn-test-connection').click();
|
||
|
await this.get().locator('.nc-extdb-btn-submit:enabled').click();
|
||
|
}
|
||
|
}
|