Browse Source

qrcode: add more playwright tests

pr-4468-qr-code-extraction
Daniel Spaude 2 years ago
parent
commit
3a315d840c
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 6
      packages/nc-gui/components/smartsheet/column/QrCodeOptions.vue
  2. 30
      tests/playwright/pages/Dashboard/Grid/Column/index.ts
  3. 37
      tests/playwright/tests/columnQrCode.spec.ts
  4. 14
      tests/playwright/tests/tableColumnOperation.spec.ts

6
packages/nc-gui/components/smartsheet/column/QrCodeOptions.vue

@ -54,7 +54,11 @@ setAdditionalValidations({
<template>
<a-row>
<a-col :span="24">
<a-form-item class="flex w-1/2 pb-2" :label="$t('labels.qrCodeValueColumn')" v-bind="validateInfos.fk_qr_value_column_id">
<a-form-item
class="flex w-1/2 pb-2 nc-qr-code-value-column-select"
:label="$t('labels.qrCodeValueColumn')"
v-bind="validateInfos.fk_qr_value_column_id"
>
<a-select
v-model:value="vModel.fk_qr_value_column_id"
:options="columnsAllowedAsQrValue"

30
tests/playwright/pages/Dashboard/Grid/Column/index.ts

@ -150,6 +150,36 @@ export class ColumnPageObject extends BasePage {
await this.rootPage.locator(`text=${type}`).nth(1).click();
}
async changeReferencedColumnForQrCode({ titleOfReferencedColumn }: { titleOfReferencedColumn: string }) {
// await this.get().locator('.ant-select-selector > .ant-select-selection-item:nth-child(2').click();
// await this.get().locator('.ant-select-single').nth(1).click();
// await this.get().locator('.ant-select-single').nth(1).click();
// await this.rootPage
// .locator(`.ant-select-item`, {
// hasText: qrCodeValueColumnTitle,
// })
// .click();
await this.get().locator('.nc-qr-code-value-column-select .ant-select-single').click();
await this.rootPage
.locator(`.ant-select-item`, {
hasText: titleOfReferencedColumn,
})
.click();
await this.save();
// await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').waitFor();
// await this.get().locator('.ant-select-selection-search-input[aria-expanded="true"]').fill(type);
// // Select column type
// await this.rootPage.locator(`text=${type}`).nth(1).click();
}
async delete({ title }: { title: string }) {
await this.grid.get().locator(`th[data-title="${title}"] >> svg.ant-dropdown-trigger`).click();
// await this.rootPage.locator('li[role="menuitem"]:has-text("Delete")').waitFor();

37
tests/playwright/tests/columnQrCode.spec.ts

@ -22,7 +22,7 @@ test.describe('Virtual Columns', () => {
test.describe('QrCode Column', () => {
async function qrCodeColumnVerify(qrColumnTitle: string, expectedQrCodeData: ExpectedQrCodeData[]) {
for (let i = 0; i < expectedQrCodeData.length; i++) {
await dashboard.grid.cell.verifyQrCodeCell({
await grid.cell.verifyQrCodeCell({
index: i,
columnHeader: qrColumnTitle,
expectedSrcValue: expectedQrCodeData[i].base64EncodedSrc,
@ -62,7 +62,7 @@ test.describe('Virtual Columns', () => {
await dashboard.treeView.openTable({ title: 'City' });
await dashboard.grid.column.create({
await grid.column.create({
title: 'QrCode1',
type: 'QrCode',
qrCodeValueColumnTitle: 'City',
@ -73,14 +73,14 @@ test.describe('Virtual Columns', () => {
// Clicking on qr code in first row and expect it shows a
// popup with an enlarged version of the qr code
await dashboard.grid.cell.get({ columnHeader: 'QrCode1', index: 0 }).click();
const qrGridOverlay = dashboard.grid.qrCodeOverlay;
await grid.cell.get({ columnHeader: 'QrCode1', index: 0 }).click();
const qrGridOverlay = grid.qrCodeOverlay;
await qrGridOverlay.verifyQrValueLabel(expectedQrCodeCellValues[0].referencedValue);
await qrGridOverlay.clickCloseButton();
// Change the value in the referenced column, first row
// and expect respective QR changes accordingly
await dashboard.grid.cell.fillText({ columnHeader: 'City', index: 0, text: 'Hamburg' })
await grid.cell.fillText({ columnHeader: 'City', index: 0, text: 'Hamburg' })
const expectedQrCodeCellValuesAfterCityNameChange = [
{
referencedValue: 'Hamburg',
@ -91,20 +91,31 @@ test.describe('Virtual Columns', () => {
await qrCodeColumnVerify('QrCode1', expectedQrCodeCellValuesAfterCityNameChange);
// Change the QR Code column title
await dashboard.grid.column.openEdit({ title: 'QrCode1' });
await dashboard.grid.column.fillTitle({ title: 'QrCode1 Renamed' });
await dashboard.grid.column.save({ isUpdated: true });
await grid.column.openEdit({ title: 'QrCode1' });
await grid.column.fillTitle({ title: 'QrCode1 Renamed' });
await grid.column.save({ isUpdated: true });
await qrCodeColumnVerify('QrCode1 Renamed', expectedQrCodeCellValuesAfterCityNameChange);
// Change the referenced column title
await dashboard.grid.column.openEdit({ title: 'City' });
await dashboard.grid.column.fillTitle({ title: 'City Renamed' });
await dashboard.grid.column.save({ isUpdated: true });
await grid.column.openEdit({ title: 'City' });
await grid.column.fillTitle({ title: 'City Renamed' });
await grid.column.save({ isUpdated: true });
await qrCodeColumnVerify('QrCode1 Renamed', expectedQrCodeCellValuesAfterCityNameChange);
// Change to another referenced column
await grid.column.create({ title: 'New City Column' });
await grid.cell.fillText({ columnHeader: 'New City Column', index: 0, text: 'Hamburg' })
await grid.column.openEdit({ title: 'QrCode1 Renamed' });
await grid.column.changeReferencedColumnForQrCode({ titleOfReferencedColumn: 'New City Column'});
await qrCodeColumnVerify('QrCode1 Renamed', [{
referencedValue: 'Hamburg',
base64EncodedSrc: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAAAXNSR0IArs4c6QAAB1FJREFUeF7tndF2GjEMRMP/f3R6IG1ZNms08kjeQG6fZUseXcuyCeXy+fn5+cE/FChW4AJYxYoy3U0BwAKEFgUAq0VWJgUsGGhRALBaZGVSwIKBFgUAq0VWJgUsGGhRALBaZGVSwIKBFgUAq0VWJgUsGGhRALBaZGVSwIKBFgUAq0VWJgUsGGhRALBaZGVSwIKBFgUAq0VWJgUsGGhRoAWsy+XSEuzspO73RZz1jHw7c87q8Gycq9F+bsASsuRAAFiCwKqJkwjVR8bO3Y3OegArk6nA1klEYRj/pwKsWFVXI47CWONvFs5GoWJNCD4acpSI6h1R4VsF5ih2d43ueCddK3wva94B6xGFFcmt2HyzAAOWoBwVSxBpZwJYgmaAJYgEWHcF6LHuWlS3KlQsYTNSsQSRflrFUqvG0dLOTLjbfKvjq/W56qj6zuO0OQ06/n+sTODVwmV8Hwmnjlft3JtZ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VkWByrVghxutQFw4HDGQtYajYNO8AyxAuGchQWapupJBlbjsLCJK2YiorVp3JLxapOmLv8zPXcid2pQu4a3fEZjRRfgCW8bSlCjppiB1TVb4UdYE2omBHNAYGKdU8OFYuKdVMgs/mUvQ1YgPXaYFXviNGuyXxep+y8jJ/MfM6x6Wq5QqNlFcsVQ03aCtGusTi9mNvou1qu0AiwVGILj0zAKhTd3WVqKCt2IxUrzgYVK9bo0IKj8Llwp4PlJEhtgN0vU6gxqvGMUqKOV6u/GvdLPzdkkqsWETcR6rGpJkiNB7DUDAuNLWDFYqpgUrE2WgIWYMUKBBbqEePertwdrsbJUZhH4lc370dyqbDlpX4cofrpgFo9Sp01ApbRH1rCi78eBlgbldXdePZRSMVytgbvWKk/CclsCictqh8qFhUrxRlgpeT6MlZFO/soVOOsthtJ6lSnTJrU9WTm3Nv+6uZdFbjaDrAmkVUTQcWKnyCOUuA+F2TyM4nAul//ereXd/dxVr2RAtYLNu/qzq224yicrINqIianfzrM9e2OV9e0ws/oMuAepcoaT2/elSAzNm7C3PFqrCv8AJaaDcHOTZg7Xggx/SSjzvntyj/47zmpWBOKumC449WQV/ihYqnZEOzchLnjhRCpWKpISgleUX5H72IZ34A1m/Xdm1zHDwioH03ULCGeJfOG5rxPZaCs1kiNe6RWZvPFin+seyBVgumyAaxYWcCKNfpmAVixaIAVawRYfxXIHLeABViHCvyKHmsi9wx5MwVaPtJ5M41YzoQCgDUhGkNiBQAr1giLCQUAa0I0hsQKAFasERYTCgDWhGgMiRUArFgjLCYUAKwJ0RgSKwBYsUZYTCgAWBOiMSRWALBijbCYUACwJkRjSKwAYMUaYTGhAGBNiMaQWAHAijXCYkIBwJoQjSGxAoAVa4TFhAKANSEaQ2IFACvWCIsJBf4ABVN/xpCpplAAAAAASUVORK5CYII='
}]);
// Change to another referenced column
await dashboard.closeTab({ title: 'City' });
});
@ -117,7 +128,7 @@ test.describe('Virtual Columns', () => {
await grid.column.create({ title: 'column_name_a' });
await grid.column.verify({ title: 'column_name_a' });
await dashboard.grid.column.create({
await grid.column.create({
title: 'QrCode2',
type: 'QrCode',
qrCodeValueColumnTitle: 'column_name_a',

14
tests/playwright/tests/tableColumnOperation.spec.ts

@ -36,25 +36,13 @@ test.describe('Table Column Operations', () => {
columnTitle: 'Title',
value: 'value_a',
});
await dashboard.expandedForm.save({ saveAndExitMode: true });
await dashboard.expandedForm.save();
await grid.cell.verify({
index: 0,
columnHeader: 'Title',
value: 'value_a',
});
await grid.openExpandedRow({ index: 0 });
await dashboard.expandedForm.fillField({
columnTitle: 'Title',
value: 'value_a_a',
});
await dashboard.expandedForm.save({ saveAndExitMode: false });
await grid.cell.verify({
index: 0,
columnHeader: 'Title',
value: 'value_a_a',
});
await grid.deleteRow(0);
await grid.verifyRowDoesNotExist({ index: 0 });

Loading…
Cancel
Save