@suffolklitlab/alkiln 5.0.0-hotfixupload11 → 5.0.0-hotfixupload12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/scope.js +35 -46
  2. package/package.json +1 -1
package/lib/scope.js CHANGED
@@ -1781,63 +1781,51 @@ module.exports = {
1781
1781
  *
1782
1782
  * Returns whether the row was used or not.
1783
1783
  */
1784
- console.log( process.cwd() );
1785
1784
 
1786
- // First make sure the list of files is of the correct format
1787
- // Allow a typo where someone forgot to include a space after a comma
1785
+ // First make sure the list of files was defined. Don't remove spaces yet -
1786
+ // allow a typo where someone forgot to include a space after a comma.
1788
1787
  let uploads_names = answer.split(`,`);
1789
1788
  if ( uploads_names.length === 0 ) {
1790
1789
  await scope.addToReport( scope, {
1791
1790
  type: `error`,
1792
1791
  value: `Your list of files to upload is empty.`
1793
1792
  });
1794
- return false;
1793
+ return false; // The row wasn't used
1794
+ }
1795
+
1796
+ let dirs = [];
1797
+ if ( session_vars.get_origin() === `playground` ) {
1798
+ let files_playground = fg.sync(
1799
+ [ `/usr/share/docassemble/files/playgroundsources/${session_vars.get_user_id()}/${session_vars.get_user_project_name()}` ],
1800
+ { onlyFiles: false, suppressErrors: true }
1801
+ );
1802
+
1803
+ let files_s3 = fg.sync(
1804
+ [ `/tmp/playgroundsources/${session_vars.get_user_id()}/${session_vars.get_user_project_name()}` ],
1805
+ { onlyFiles: false, suppressErrors: true }
1806
+ );
1807
+
1808
+ dirs = files_playground.concat( files_s3 );
1809
+ } else {
1810
+ dirs = fg.sync(
1811
+ [ `**/docassemble/**/data/sources` ],
1812
+ { onlyFiles: false, suppressErrors: true }
1813
+ );
1795
1814
  }
1796
1815
 
1797
- // `**/docassemble/**/data/sources`
1798
- // `/usr/share/docassemble/files/playgroundsources/${session_vars.get_user_id()}/${session_vars.get_user_project_name()}/*.feature`);
1799
- // `/tmp/playgroundsources/${session_vars.get_user_id()}/${session_vars.get_user_project_name()}/*.feature`);
1800
- // MUST have proj name for right upload files
1801
-
1802
- let dirs_playground = fg.sync(
1803
- [ `/usr/share/docassemble/files/playgroundsources/**/data/sources` ],
1804
- { onlyFiles: false, suppressErrors: true }
1805
- );
1806
- console.log(`\n=== dirs_playground ===`);
1807
- console.log(dirs_playground);
1808
-
1809
- let dirs_playground_all = fg.sync(
1810
- [ `/usr/share/docassemble/**/data/sources` ],
1811
- { onlyFiles: false, suppressErrors: true }
1812
- );
1813
- console.log(`\n=== dirs_playground_all ===`);
1814
- console.log(dirs_playground_all);
1815
-
1816
- let dirs_s3 = fg.sync(
1817
- [ `/tmp/playgroundsources/**/data/sources` ],
1818
- { onlyFiles: false, suppressErrors: true }
1819
- );
1820
- console.log(`\n=== dirs_s3 ===`);
1821
- console.log(dirs_s3);
1822
-
1823
- let dirs_repo = fg.sync(
1824
- [ `${ process.cwd() }/**/docassemble/**/data/sources` ],
1825
- { onlyFiles: false, suppressErrors: true }
1826
- );
1827
- console.log(`\n=== dirs_repo ===`);
1828
- console.log(dirs_repo);
1829
-
1830
- // Make sure sources directory exists
1831
- let dirs = fg.sync([ `${ process.cwd() }/**/docassemble/**/data/sources` ], { onlyFiles: false });
1816
+ // Make sure sources directory exists and has files in it
1832
1817
  if ( dirs.length === 0 ) {
1833
1818
  await scope.addToReport( scope, {
1834
1819
  type: `warning`,
1835
- value: `The test files need to be in the "sources" directory anywhere within "${ process.cwd() }", but ALKiln couldn't find it.`
1820
+ value: `The test files need to be in the "sources" directory, `
1821
+ + `but ALKiln couldn't find the directory or it was empty.`
1822
+ // Should this say the full directory glob used to try to find the files?
1836
1823
  });
1837
- return false;
1824
+ return false; // The row wasn't used
1838
1825
  }
1839
- let dir = null;
1840
1826
 
1827
+ // Get the full paths of the files
1828
+ let dir = null;
1841
1829
  let paths = [];
1842
1830
  let missing_files = []; // For any user warnings
1843
1831
  for ( let name of uploads_names ) {
@@ -1848,6 +1836,7 @@ module.exports = {
1848
1836
  // console.log( one_dir );
1849
1837
  matching_paths = fg.sync([ `${ one_dir }/${ trimmed_name }` ]);
1850
1838
  if ( matching_paths.length > 0 ) {
1839
+ // Once we've found the file, we've got the right directory
1851
1840
  dir = one_dir;
1852
1841
  break;
1853
1842
  }
@@ -1872,7 +1861,7 @@ module.exports = {
1872
1861
 
1873
1862
  // If all files missing, return that the row wasn't used
1874
1863
  if ( missing_files.length === uploads_names.length ) {
1875
- return false;
1864
+ return false; // The row wasn't used
1876
1865
  }
1877
1866
 
1878
1867
  // Prepare to wait for upload to complete
@@ -1881,9 +1870,9 @@ module.exports = {
1881
1870
  let disabled_selector = `${ selector }[disabled]`;
1882
1871
  let enabled_selector = `${ selector }:not([disabled])`;
1883
1872
 
1884
- // This comes before the upload starts
1885
- // Notice `await` is absent. Don't actually wait here.
1886
- // Just start looking for it now. That way we'll catch it before it's gone
1873
+ // This comes before the upload starts.
1874
+ // Notice `await` is absent. Don't actually wait here yet.
1875
+ // Start looking for it before it exists or we might miss it.
1887
1876
  let wait_for_disable = scope.page.waitForSelector( disabled_selector );
1888
1877
 
1889
1878
  // Upload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suffolklitlab/alkiln",
3
- "version": "5.0.0-hotfixupload11",
3
+ "version": "5.0.0-hotfixupload12",
4
4
  "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {