alessandro trinca tornidor commited on
Commit
9c1561c
·
1 Parent(s): 8137781

refactor: rename occurrences of WordFreq to WordsFreq

Browse files
static/index.js CHANGED
@@ -122,7 +122,7 @@ const getWordsFrequency = async () => {
122
  setElementCssClass("waiting-for-be", "display-none")
123
  let freq = bodyResponseJson["words_frequency"]
124
  let nTotalRows = bodyResponseJson["n_total_rows"]
125
- console.log(`getWordFreq::nTotalRows: '${nTotalRows}'`)
126
  populateWordsFrequencyTables(freq, bodyResponseJson["n_total_rows"])
127
  } catch (err) {
128
  console.error("getWordsFrequency::err:", err, "#")
@@ -210,12 +210,12 @@ const populateWordsFrequencyTables = (wordsFrequencyObj, nTotalRows) => {
210
  * @param {object} wordsFrequency - A container element to hold all tables representing word frequencies.
211
  */
212
  const insertCurrentTable = (i, iReduced, nTotalRows, wordsFrequency) => {
213
- let currentTableWordFreq = document.createElement("table")
214
- currentTableWordFreq.setAttribute("class", "border-black")
215
- currentTableWordFreq.setAttribute("id", `id-table-${i}-nth`)
216
- currentTableWordFreq.setAttribute("aria-label", `id-table-${i}-nth`)
217
 
218
- let currentCaption = currentTableWordFreq.createCaption()
219
  currentCaption.setAttribute("aria-label", `id-table-${i}-caption`)
220
  currentCaption.innerText = `${iReduced["word_prefix"]}: ${iReduced["count"]} repetitions`
221
 
@@ -230,9 +230,9 @@ const insertCurrentTable = (i, iReduced, nTotalRows, wordsFrequency) => {
230
  for (let ii = 0; ii < offsetsArray.length; ii++) {
231
  insertCellIntoTRow(currentTBody, i, ii, offsetsArray[ii], nTotalRows)
232
  }
233
- currentTableWordFreq.appendChild(currentTHead)
234
- currentTableWordFreq.appendChild(currentTBody)
235
- wordsFrequency.appendChild(currentTableWordFreq)
236
  }
237
 
238
  /**
 
122
  setElementCssClass("waiting-for-be", "display-none")
123
  let freq = bodyResponseJson["words_frequency"]
124
  let nTotalRows = bodyResponseJson["n_total_rows"]
125
+ console.log(`getWordsFreq::nTotalRows: '${nTotalRows}'`)
126
  populateWordsFrequencyTables(freq, bodyResponseJson["n_total_rows"])
127
  } catch (err) {
128
  console.error("getWordsFrequency::err:", err, "#")
 
210
  * @param {object} wordsFrequency - A container element to hold all tables representing word frequencies.
211
  */
212
  const insertCurrentTable = (i, iReduced, nTotalRows, wordsFrequency) => {
213
+ let currentTableWordsFreq = document.createElement("table")
214
+ currentTableWordsFreq.setAttribute("class", "border-black")
215
+ currentTableWordsFreq.setAttribute("id", `id-table-${i}-nth`)
216
+ currentTableWordsFreq.setAttribute("aria-label", `id-table-${i}-nth`)
217
 
218
+ let currentCaption = currentTableWordsFreq.createCaption()
219
  currentCaption.setAttribute("aria-label", `id-table-${i}-caption`)
220
  currentCaption.innerText = `${iReduced["word_prefix"]}: ${iReduced["count"]} repetitions`
221
 
 
230
  for (let ii = 0; ii < offsetsArray.length; ii++) {
231
  insertCellIntoTRow(currentTBody, i, ii, offsetsArray[ii], nTotalRows)
232
  }
233
+ currentTableWordsFreq.appendChild(currentTHead)
234
+ currentTableWordsFreq.appendChild(currentTBody)
235
+ wordsFrequency.appendChild(currentTableWordsFreq)
236
  }
237
 
238
  /**
static/tests/test-words-frequency-1.spec.ts CHANGED
@@ -3,16 +3,16 @@ import { test, expect } from '@playwright/test';
3
  import { fileReader, loopOverTablesAndClickOnUrls } from './test-helper'
4
 
5
  test(`test: words frequency (short text input)`, async ({ page }) => {
6
- const wordFreqTable0AriaSnapshot1FilePath = `${import.meta.dirname}/test-words-frequency-1-table0-aria-snapshot.txt`
7
- const wordFreqTable13AriaSnapshot1FilePath = `${import.meta.dirname}/test-words-frequency-1-table13-aria-snapshot.txt`
8
  await page.goto(process.env.DOMAIN_PORT ?? "/");
9
  console.log(page.url())
10
 
11
  await page.getByRole('button', { name: 'btn4-get-words-frequency' }).click();
12
  let table0 = page.getByRole('table', { name: 'id-table-0-nth' })
13
- let dataTable0 = await fileReader(wordFreqTable0AriaSnapshot1FilePath)
14
  let table13 = page.getByRole('table', { name: 'id-table-13-nth' })
15
- let dataTableLast = await fileReader(wordFreqTable13AriaSnapshot1FilePath)
16
  await expect(table0).toMatchAriaSnapshot(dataTable0)
17
  await expect(table13).toMatchAriaSnapshot(dataTableLast)
18
 
 
3
  import { fileReader, loopOverTablesAndClickOnUrls } from './test-helper'
4
 
5
  test(`test: words frequency (short text input)`, async ({ page }) => {
6
+ const WordsFreqTable0AriaSnapshot1FilePath = `${import.meta.dirname}/test-words-frequency-1-table0-aria-snapshot.txt`
7
+ const WordsFreqTable13AriaSnapshot1FilePath = `${import.meta.dirname}/test-words-frequency-1-table13-aria-snapshot.txt`
8
  await page.goto(process.env.DOMAIN_PORT ?? "/");
9
  console.log(page.url())
10
 
11
  await page.getByRole('button', { name: 'btn4-get-words-frequency' }).click();
12
  let table0 = page.getByRole('table', { name: 'id-table-0-nth' })
13
+ let dataTable0 = await fileReader(WordsFreqTable0AriaSnapshot1FilePath)
14
  let table13 = page.getByRole('table', { name: 'id-table-13-nth' })
15
+ let dataTableLast = await fileReader(WordsFreqTable13AriaSnapshot1FilePath)
16
  await expect(table0).toMatchAriaSnapshot(dataTable0)
17
  await expect(table13).toMatchAriaSnapshot(dataTableLast)
18