Skip to content

Commit 2677f94

Browse files
added cypress #17
1 parent 779c403 commit 2677f94

18 files changed

+2484
-2
lines changed

doc/src/SUMMARY.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
- [Rest]()
2323
- [`/api/upload-form`](./backend/rest/upload-form.md)
2424
- [`/api/upload-attachment`](./backend/rest/upload-attachment.md)
25+
- [Integration tests]()
26+
- [Cypress](./cypress/README.md)
2527

2628
# Administration notes

doc/src/cypress

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../frontend/nix/tools/cypress

flake.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
in
3838
rec {
3939
nixosConfigurations = {
40-
4140
lifeline = nixpkgs.lib.nixosSystem (lib.mergeAttrs commonAttrs {
4241
modules = commonModules ++ [
4342
./deployment/hosts/lifeline/configuration.nix
@@ -47,7 +46,10 @@
4746
#./deployment/modules/jenkins.nix
4847
];
4948
});
50-
49+
};
50+
legacyPackages.x86_64-linux = {
51+
inherit pkgs;
52+
cypress = import ./frontend/nix/tools/cypress/override.nix { inherit pkgs; };
5153
};
5254
};
5355
}

frontend/nix/tools/cypress/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Cypress
2+
3+
## Setup
4+
5+
Ensure you use the same `cypress` version in `node-packages.json` as the version of the cypress-binary provided by flake.nix.
6+
7+
`default.nix`, `node-env.nix` and `node-packages.nix` can be updated by:
8+
9+
```bash
10+
cd frontend/nix/tools/cypress
11+
12+
nix run ../../../..#pkgs.nodePackages.node2nix -- -i node-packages.json
13+
```
14+
15+
## Usage
16+
17+
```bash
18+
cd frontend/submission
19+
20+
nix run ../..#cypress -- run ## ci run
21+
nix run ../..#cypress -- open ## gui
22+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## from https://gist.github.com/r-k-b/2485f977b476aa3f76a47329ce7f9ad4
2+
3+
# When Cypress starts, it copies some files into `~/.config/Cypress/cy/production/browsers/chrome-stable/interactive/CypressExtension/`
4+
# from the Nix Store, one of which it attempts to modify immediately after.
5+
# As-is, this fails because the copied file keeps the read-only flag it had in
6+
# the Store.
7+
# Luckily, the code responsible is a plain text script that we can easily patch:
8+
final: prev: {
9+
# This has only been tested against Cypress 7.3.0 and 7.4.0
10+
cypress = prev.cypress.overrideAttrs (oldAttrs: {
11+
installPhase = let
12+
matchForChrome = "yield utils_1.default.copyExtension(pathToExtension, extensionDest);";
13+
appendForChrome = "yield fs_1.fs.chmodAsync(extensionBg, 0o0644);";
14+
15+
matchForFirefox = "copyExtension(pathToExtension, extensionDest)";
16+
replaceForFirefox = "copyExtension(pathToExtension, extensionDest).then(() => fs.chmodAsync(extensionBg, 0o0644))";
17+
in ''
18+
sed -i '/${matchForChrome}/a\${appendForChrome}' \
19+
./resources/app/packages/server/lib/browsers/chrome.js
20+
21+
sed -i 's/${matchForFirefox}/${replaceForFirefox}/' \
22+
./resources/app/packages/server/lib/browsers/utils.js
23+
'' + oldAttrs.installPhase;
24+
});
25+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file has been generated by node2nix 1.9.0. Do not edit!
2+
3+
{pkgs ? import <nixpkgs> {
4+
inherit system;
5+
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
6+
7+
let
8+
nodeEnv = import ./node-env.nix {
9+
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
10+
inherit pkgs nodejs;
11+
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
12+
};
13+
in
14+
import ./node-packages.nix {
15+
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
16+
inherit nodeEnv;
17+
}

0 commit comments

Comments
 (0)