Skip to content

Commit

Permalink
fix flaky tests
Browse files Browse the repository at this point in the history
Signed-off-by: Erick Wendel <[email protected]>
  • Loading branch information
ErickWendel committed Jul 29, 2024
1 parent 106284f commit 66b9c9a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: npm run docker:install-module

- name: Run Playwright tests
run: npm run playwright:headless
run: npm test
env:
GOOGLE_SHEETS_AUTH_FILE: ${{ secrets.GOOGLE_SHEETS_AUTH_FILE }}

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# nodered-google-sheets-to-json-stream

[![Build Status](https://github.com/ErickWendel/nodered-google-sheets-to-json-stream/workflows/Nodered%20Google%20Sheets%20to%20JSON%20Stream/badge.svg)](https://github.com/ErickWendel/nodered-google-sheets-to-json-stream/actions)

This Node-RED custom node let you consume google sheets spreadsheets on demand.

## Why:
## Why

My inspiration for creating this module was that the popular [node-red-contrib-google-sheets](https://flows.nodered.org/node/node-red-contrib-google-sheets) puts all the spreadsheet data in memory overloading Node.js and causing crashes while working with big sets of data (such as 10K+ sheets lines).

Expand Down
Binary file removed example.png
Binary file not shown.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
"docker:restart-nodered": "cd misc && docker-compose restart nodered",
"docker:install-module": "./misc/install-module.sh",
"docker:restart-nodered-on-change": "nodemon -e html,js,json,css --exec 'npm run copy-files && cd misc && npm run docker:restart-nodered && docker logs -f nodered'",
"playwright:web": "npx playwright test --ui --debug",
"playwright:headless": "npx playwright test",
"test": "npm run playwright:headless",
"test:dev": "export GOOGLE_SHEETS_AUTH_FILE=$(cat spreadsheets.json) && npm run playwright:headless"
"test": "npx playwright test",
"test:dev": "export GOOGLE_SHEETS_AUTH_FILE=$(cat spreadsheets.json) && npx playwright test --trace on",
"test:dev:ui": "export GOOGLE_SHEETS_AUTH_FILE=$(cat spreadsheets.json) && npx playwright test --ui --debug"
},
"author": "erickwendel",
"keywords": [
Expand Down
55 changes: 24 additions & 31 deletions tests/e2e/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ const TCP_PORT = 3000
const { version } = require('os')
const metaKey = version().includes('Darwin') ? 'Meta' : 'Control'

async function cleanField(input) {
await expect(input).toBeVisible();
await expect(input).toBeEnabled();

await input.focus();
await input.click({ clickCount: 3 });
await input.press('Backspace');

}
describe('Node-RED Interface', () => {
beforeAll(async () => {
await deleteAllFlows({
Expand Down Expand Up @@ -107,16 +116,13 @@ describe('Node-RED Interface', () => {
});

await test.step(`And I manually choose range as ${rangeOfTwoLines} and save`, async () => {
const range = editor.elements.sheetsToJSON.rangeInput()
await expect(range).toBeEnabled()
await range.focus()
const input = editor.elements.sheetsToJSON.rangeInput()

await range.press(metaKey + '+a');
await page.keyboard.press('Backspace');
await cleanField(input)

await range.type(rangeOfTwoLines)
await range.press('Enter')
await range.press(metaKey + '+Enter');
await input.type(rangeOfTwoLines)
await page.keyboard.press('Enter')
await page.keyboard.press(metaKey + '+Enter');
});

await test.step('And I can deploy Node-RED without errors', async () => {
Expand Down Expand Up @@ -179,24 +185,20 @@ describe('Node-RED Interface', () => {

await test.step(`And I change the range`, async () => {
const input = editor.elements.sheetsToJSON.rangeInput()
await expect(input).toBeEnabled()
await cleanField(input)

await input.press(metaKey + '+a');
await input.press('Backspace');

await input.type(expectedRange)
await input.press('Enter');
await page.keyboard.press('Enter');
});

await test.step(`And I change the columns`, async () => {
const input = editor.elements.sheetsToJSON.columnsInput()
await expect(input).toBeEnabled()

await input.press(metaKey + '+a');
await input.press('Backspace');
await cleanField(input)

await input.type(JSON.stringify(expectedJSONColumns))
await input.press('Enter');
await page.keyboard.press('Enter');
});

await test.step('And I deploy it', async () => {
Expand Down Expand Up @@ -262,24 +264,18 @@ describe('Node-RED Interface', () => {

await test.step(`And I change the range`, async () => {
const input = editor.elements.sheetsToJSON.rangeInput()
await expect(input).toBeEnabled()

await input.press(metaKey + '+a');
await input.press('Backspace');
await cleanField(input)

await input.type(expectedRange)
await input.press('Enter');
await page.keyboard.press('Enter');
});

await test.step(`And I change the columns`, async () => {
const input = editor.elements.sheetsToJSON.columnsInput()
await expect(input).toBeEnabled()

await input.press(metaKey + '+a');
await input.press('Backspace');
await cleanField(input)

await input.type(JSON.stringify(expectedJSONColumns))
await input.press('Enter');
await page.keyboard.press('Enter');
});

await test.step('And I deploy it', async () => {
Expand Down Expand Up @@ -551,13 +547,10 @@ describe('Node-RED Interface', () => {
const expectedRange = 'A1:B2'
await test.step(`And I change the range`, async () => {
const input = editor.elements.sheetsToJSON.rangeInput()
await expect(input).toBeEnabled()

await input.press(metaKey + '+a');
await input.press('Backspace');
await cleanField(input)

await input.type(expectedRange)
await input.press('Enter');
await page.keyboard.press('Enter');
});

await test.step('And I deploy it', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/util/nodered.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function generateValidConfigNode({ googleAuthCredentials }) {
return {
config: {
"id": nodeId,
"type": "gauth",
"type": "googleauth",
"name": googleAuthCredentials.client_email,
"credentials": {
"config": JSON.stringify(googleAuthCredentials)
Expand Down

0 comments on commit 66b9c9a

Please sign in to comment.