Browse Source

qr scanner: tests - WIP

pull/5114/head
Daniel Spaude 2 years ago
parent
commit
e332f3abaa
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 4
      packages/nc-gui/components/smartsheet/toolbar/QrScannerButton.vue
  2. 199
      tests/playwright/pages/Dashboard/FindRowByScanOverlay/index.ts
  3. 3
      tests/playwright/pages/Dashboard/index.ts
  4. 7
      tests/playwright/tests/findRowByScanner.spec.ts

4
packages/nc-gui/components/smartsheet/toolbar/QrScannerButton.vue

@ -92,7 +92,7 @@ const onDecode = async (codeValue: string) => {
</script> </script>
<template> <template>
<div> <div class="nc-overlay-find-row-by-scan">
<a-button class="nc-btn-find-row-by-scan nc-toolbar-btn" @click="showCodeScannerOverlay = true"> <a-button class="nc-btn-find-row-by-scan nc-toolbar-btn" @click="showCodeScannerOverlay = true">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">
<QrCodeScan /> <QrCodeScan />
@ -110,7 +110,7 @@ const onDecode = async (codeValue: string) => {
@cancel="scannerIsReady = false" @cancel="scannerIsReady = false"
> >
<div class="relative flex flex-col h-full"> <div class="relative flex flex-col h-full">
<a-form-item :label="$t('labels.columnToScanFor')"> <a-form-item :label="$t('labels.columnToScanFor')" class="nc-dropdown-scanner-column-id">
<a-select v-model:value="selectedCodeColumnIdToScanFor" class="w-full" :options="codeFieldOptions" /> <a-select v-model:value="selectedCodeColumnIdToScanFor" class="w-full" :options="codeFieldOptions" />
</a-form-item> </a-form-item>

199
tests/playwright/pages/Dashboard/FindRowByScanOverlay/index.ts

@ -0,0 +1,199 @@
import { expect, Locator } from '@playwright/test';
import BasePage from '../../Base';
import { DashboardPage } from '..';
import { ToolbarPage } from '../common/Toolbar';
export class FindRowByScanOverlay extends BasePage {
readonly dashboard: DashboardPage;
readonly toolbar: ToolbarPage;
readonly selectColumnDropdown: Locator;
constructor(dashboard: DashboardPage) {
super(dashboard.rootPage);
this.dashboard = dashboard;
this.toolbar = dashboard.grid.toolbar;
this.selectColumnDropdown = this.dashboard.get().locator('.nc-dropdown-scanner-column-id');
}
get() {
return this.dashboard.get().locator(`.nc-overlay-find-row-by-scan`);
}
async isVisible() {
return await this.get().isVisible();
}
// async create({ title, event, url = 'http://localhost:9090/hook' }: { title: string; event: string; url?: string }) {
// await this.toolbar.clickActions();
// await this.toolbar.actions.click('Webhooks');
// await this.addNewButton.click();
// await this.get().waitFor({ state: 'visible' });
// await this.configureHeader({
// key: 'Content-Type',
// value: 'application/json',
// });
// await this.configureWebhook({ title, event, url });
// await this.save();
// await this.close();
// }
// async configureWebhook({ title, event, url }: { title?: string; event?: string; url?: string }) {
// if (title) {
// await this.get().locator(`.nc-text-field-hook-title`).fill(title);
// }
// if (event) {
// await this.get().locator(`.nc-text-field-hook-event`).click();
// const modal = this.rootPage.locator(`.nc-dropdown-webhook-event`);
// await modal.locator(`.ant-select-item:has-text("${event}")`).click();
// }
// if (url) {
// await this.get().locator(`.nc-text-field-hook-url-path`).fill(url);
// }
// }
// async addCondition({
// column,
// operator,
// value,
// save,
// }: {
// column: string;
// operator: string;
// value: string;
// save: boolean;
// }) {
// await this.get().locator(`.nc-check-box-hook-condition`).click();
// const modal = await this.get().locator(`.menu-filter-dropdown`).last();
// // todo: All delays are for api calls that filter does, which rerenders
// await this.rootPage.waitForTimeout(1000);
// await modal.locator(`button:has-text("Add Filter")`).click();
// await this.rootPage.waitForTimeout(1500);
// await modal.locator('.nc-filter-field-select').click();
// const modalField = await this.dashboard.rootPage.locator('.nc-dropdown-toolbar-field-list:visible');
// await modalField.locator(`.ant-select-item:has-text("${column}")`).click();
// await this.rootPage.waitForTimeout(1500);
// await modal.locator('.nc-filter-operation-select').click();
// const modalOp = await this.dashboard.rootPage.locator('.nc-dropdown-filter-comp-op:visible');
// await modalOp.locator(`.ant-select-item:has-text("${operator}")`).click();
// await this.rootPage.waitForTimeout(1500);
// if (operator != 'is null' && operator != 'is not null') {
// await modal.locator('.nc-filter-value-select > input').fill(value);
// }
// if (save) {
// await this.save();
// await this.close();
// }
// }
// async deleteCondition(p: { save: boolean }) {
// await this.get().locator(`.nc-filter-item-remove-btn`).click();
// if (p.save) {
// await this.save();
// await this.close();
// }
// }
// async save() {
// const saveAction = () => this.saveButton.click();
// await this.waitForResponse({
// uiAction: saveAction,
// requestUrlPathToMatch: '/hooks',
// httpMethodsToMatch: ['POST', 'PATCH'],
// });
// await this.verifyToast({ message: 'Webhook details updated successfully' });
// }
// async test() {
// await this.testButton.click();
// await this.verifyToast({ message: 'Webhook tested successfully' });
// }
// async delete({ index }: { index: number }) {
// await this.toolbar.clickActions();
// await this.toolbar.actions.click('Webhooks');
// await this.get().locator(`.nc-hook-delete-icon`).nth(index).click();
// await this.verifyToast({ message: 'Hook deleted successfully' });
// // click escape to close the drawer
// await this.get().press('Escape');
// }
// async close() {
// // type esc key
// await this.get().press('Escape');
// }
// async open({ index }: { index: number }) {
// await this.toolbar.clickActions();
// await this.toolbar.actions.click('Webhooks');
// await this.dashboard.get().locator(`.nc-hook`).nth(index).click();
// }
// async openForm({ index }: { index: number }) {
// await this.dashboard.get().locator(`.nc-hook`).nth(index).click();
// }
// async click({ index }: { index: number }) {
// await this.dashboard.get().locator(`.nc-hook`).nth(index).click();
// }
// async configureHeader({ key, value }: { key: string; value: string }) {
// // hardcode "Content-type: application/json"
// await this.get().locator(`.ant-tabs-tab-btn:has-text("Headers")`).click();
// await this.get().locator('.nc-input-hook-header-key >> input').fill(key);
// await this.rootPage.locator(`.ant-select-item:has-text("${key}")`).click();
// await this.get().locator('.nc-input-hook-header-value').type(value);
// await this.get().press('Enter');
// await this.get().locator('.nc-hook-header-tab-checkbox').locator('input.ant-checkbox-input').click();
// }
// async verifyForm({
// title,
// hookEvent,
// url,
// notificationType,
// urlMethod,
// condition,
// }: {
// title: string;
// hookEvent: string;
// url: string;
// notificationType: string;
// urlMethod: string;
// condition: boolean;
// }) {
// await expect.poll(async () => await this.get().locator('input.nc-text-field-hook-title').inputValue()).toBe(title);
// await expect(this.get().locator('.nc-text-field-hook-event >> .ant-select-selection-item')).toHaveText(hookEvent);
// await expect(this.get().locator('.nc-select-hook-notification-type >> .ant-select-selection-item')).toHaveText(
// notificationType
// );
// await expect(this.get().locator('.nc-select-hook-url-method >> .ant-select-selection-item')).toHaveText(urlMethod);
// await expect.poll(async () => await this.get().locator('input.nc-text-field-hook-url-path').inputValue()).toBe(url);
// const conditionCheckbox = this.get().locator('label.nc-check-box-hook-condition >> input[type="checkbox"]');
// if (condition) {
// await expect(conditionCheckbox).toBeChecked();
// } else {
// await expect(conditionCheckbox).not.toBeChecked();
// }
// }
// async goBackFromForm() {
// await this.get().locator('svg.nc-icon-hook-navigate-left').click();
// }
}

3
tests/playwright/pages/Dashboard/index.ts

@ -15,6 +15,7 @@ import { ImportAirtablePage } from './Import/Airtable';
import { ImportTemplatePage } from './Import/ImportTemplate'; import { ImportTemplatePage } from './Import/ImportTemplate';
import { WebhookFormPage } from './WebhookForm'; import { WebhookFormPage } from './WebhookForm';
import { ProjectsPage } from '../ProjectsPage'; import { ProjectsPage } from '../ProjectsPage';
import { FindRowByScanOverlay } from './FindRowByScanOverlay';
export class DashboardPage extends BasePage { export class DashboardPage extends BasePage {
readonly project: any; readonly project: any;
@ -29,6 +30,7 @@ export class DashboardPage extends BasePage {
readonly map: MapPage; readonly map: MapPage;
readonly expandedForm: ExpandedFormPage; readonly expandedForm: ExpandedFormPage;
readonly webhookForm: WebhookFormPage; readonly webhookForm: WebhookFormPage;
readonly findRowByScanOverlay: FindRowByScanOverlay;
readonly childList: ChildList; readonly childList: ChildList;
readonly linkRecord: LinkRecord; readonly linkRecord: LinkRecord;
readonly settings: SettingsPage; readonly settings: SettingsPage;
@ -50,6 +52,7 @@ export class DashboardPage extends BasePage {
this.map = new MapPage(this); this.map = new MapPage(this);
this.expandedForm = new ExpandedFormPage(this); this.expandedForm = new ExpandedFormPage(this);
this.webhookForm = new WebhookFormPage(this); this.webhookForm = new WebhookFormPage(this);
this.findRowByScanOverlay = new FindRowByScanOverlay(this);
this.childList = new ChildList(this); this.childList = new ChildList(this);
this.linkRecord = new LinkRecord(this); this.linkRecord = new LinkRecord(this);
this.settings = new SettingsPage(this); this.settings = new SettingsPage(this);

7
tests/playwright/tests/findRowByScanner.spec.ts

@ -4,7 +4,7 @@ import { ToolbarPage } from '../pages/Dashboard/common/Toolbar';
import { FormPage } from '../pages/Dashboard/Form'; import { FormPage } from '../pages/Dashboard/Form';
import setup from '../setup'; import setup from '../setup';
test.describe('Find row by scanner', () => { test.describe.only('Find row by scanner', () => {
let dashboard: DashboardPage; let dashboard: DashboardPage;
let context: any; let context: any;
let toolbar: ToolbarPage; let toolbar: ToolbarPage;
@ -22,10 +22,11 @@ test.describe('Find row by scanner', () => {
// close 'Team & Auth' tab // close 'Team & Auth' tab
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'Country' }); await dashboard.treeView.openTable({ title: 'Country' });
// await toolbar.clickActions; await toolbar.clickFindRowByScanButton();
await dashboard.rootPage.pause();
}); });
test('opens the scanner overlay', async () => { test('opens the scanner overlay', async () => {
expect(2 + 2).toBe(4); expect(2 + 2).toBe(6);
}); });
}); });
}); });

Loading…
Cancel
Save